@Override public SELF isNotEqualTo(Object other) { return super.isNotEqualTo(other); }
@Override public SELF isNotEqualTo(Object other) { return super.isNotEqualTo(other); }
@Test public void testNotEqualDifferentObjects() throws Exception { final CallbackWeakReference reference = new CallbackWeakReference(callback); assertThat(reference).isNotEqualTo(null); assertThat(reference).isNotEqualTo(callback); }
@Test @SuppressWarnings("unchecked") public void rateLimiterPositiveWithSupplier() throws Exception { RateLimiterRegistry registry = new InMemoryRateLimiterRegistry(config); Supplier<RateLimiterConfig> rateLimiterConfigSupplier = mock(Supplier.class); when(rateLimiterConfigSupplier.get()) .thenReturn(config); RateLimiter firstRateLimiter = registry.rateLimiter("test", rateLimiterConfigSupplier); verify(rateLimiterConfigSupplier, times(1)).get(); RateLimiter sameAsFirst = registry.rateLimiter("test", rateLimiterConfigSupplier); verify(rateLimiterConfigSupplier, times(1)).get(); RateLimiter anotherLimit = registry.rateLimiter("test1", rateLimiterConfigSupplier); verify(rateLimiterConfigSupplier, times(2)).get(); then(firstRateLimiter).isEqualTo(sameAsFirst); then(firstRateLimiter).isNotEqualTo(anotherLimit); }
@Test public void clone_shouldCloneAutocompleteCandidate(){ //given AutocompleteCandidate aParent = new AutocompleteCandidate(1, keys); //when AutocompleteCandidate clone = aParent.clone(); //then Assertions.assertThat(clone).isNotNull(); Assertions.assertThat(clone.getKey()).isEqualTo(aParent.getKey()); Assertions.assertThat(clone.getType()).isEqualTo(aParent.getType()); Assertions.assertThat(clone.getChildrens().size()).isEqualTo(aParent.getChildrens().size()); Assertions.assertThat(clone).isNotEqualTo(aParent); } }
@Test public void testProcessSpan_withValidLongValueReturnsThatValue() throws Exception { // Given addServletParameter("123"); ClientSpanTagProcessor clientSpanLongTagProcessor = new ClientSpanLongTagProcessor(TYPE_ALL, TAG, REQUEST_PARAMETER_NAME); // When SpanWrapper span = runProcessor(clientSpanLongTagProcessor); // Then assertThat(mockTracer.finishedSpans()).hasSize(1); MockSpan mockSpan = mockTracer.finishedSpans().get(0); assertThat(mockSpan.tags().get(TAG)).isEqualTo(123L); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testNoDoNotTrackHeader() throws Exception { when(servletPlugin.isHonorDoNotTrackHeader()).thenReturn(true); final MockHttpServletRequest request = new MockHttpServletRequest(); Scope activeScope = new MonitoredHttpRequest(request, mock(StatusExposingByteCountingServletResponse.class), mock(FilterChain.class), configuration, mock(ExecutorService.class)).createScope(); SpanWrapper span = SpanContextInformation.getCurrent().getSpanWrapper(); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); activeScope.close(); }
@Test public void testNotEqualReferences() throws Exception { final CallbackWeakReference reference = new CallbackWeakReference(callback); final CallbackWeakReference anotherReference = new CallbackWeakReference(anotherCallback); assertThat(reference).isNotEqualTo(anotherReference); }
@Test public void testDifferentLocaleUpdatesResourceCache() { Configuration configuration = new Configuration(RuntimeEnvironment.application.getResources().getConfiguration()); setLocale(configuration, new Locale("en")); ResourceCache cache = ResourceCache.getLatest(configuration); setLocale(configuration, new Locale("it")); assertThat(cache).isNotEqualTo(ResourceCache.getLatest(configuration)); }
@Test public void testDoNotTrackDisabled() throws Exception { when(servletPlugin.isHonorDoNotTrackHeader()).thenReturn(true); final MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("dnt", "0"); Scope activeScope = new MonitoredHttpRequest(request, mock(StatusExposingByteCountingServletResponse.class), mock(FilterChain.class), configuration, mock(ExecutorService.class)).createScope(); SpanWrapper span = SpanContextInformation.getCurrent().getSpanWrapper(); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); activeScope.close(); }
@Test public void testDontHonorDoNotTrack() throws Exception { when(servletPlugin.isHonorDoNotTrackHeader()).thenReturn(false); final MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("dnt", "1"); Scope activeScope = new MonitoredHttpRequest(request, mock(StatusExposingByteCountingServletResponse.class), mock(FilterChain.class), configuration, mock(ExecutorService.class)).createScope(); SpanWrapper span = SpanContextInformation.getCurrent().getSpanWrapper(); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); activeScope.close(); }
@Test public void testProcessSpan_withUpperBoundAllowingIfEquals() throws Exception { // Given addServletParameter("6"); ClientSpanTagProcessor clientSpanLongTagProcessor = new ClientSpanLongTagProcessor(TYPE_ALL, TAG, REQUEST_PARAMETER_NAME) .upperBound(6L) .discardSpanOnBoundViolation(true); // When SpanWrapper span = runProcessor(clientSpanLongTagProcessor); // Then assertThat(mockTracer.finishedSpans()).hasSize(1); MockSpan mockSpan = mockTracer.finishedSpans().get(0); assertThat(mockSpan.tags().get(TAG)).isEqualTo(6L); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testProcessSpan_withLowerBoundAllowingIfEquals() throws Exception { // Given addServletParameter("5"); ClientSpanTagProcessor clientSpanLongTagProcessor = new ClientSpanLongTagProcessor(TYPE_ALL, TAG, REQUEST_PARAMETER_NAME) .lowerBound(5L) .discardSpanOnBoundViolation(true); // When SpanWrapper span = runProcessor(clientSpanLongTagProcessor); // Then assertThat(mockTracer.finishedSpans()).hasSize(1); MockSpan mockSpan = mockTracer.finishedSpans().get(0); assertThat(mockSpan.tags().get(TAG)).isEqualTo(5L); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testProcessSpan_withInvalidValueReturnsNull() throws Exception { // Given addServletParameter("invalid"); ClientSpanTagProcessor clientSpanLongTagProcessor = new ClientSpanLongTagProcessor(TYPE_ALL, TAG, REQUEST_PARAMETER_NAME); // When SpanWrapper span = runProcessor(clientSpanLongTagProcessor); // Then assertThat(mockTracer.finishedSpans()).hasSize(1); MockSpan mockSpan = mockTracer.finishedSpans().get(0); assertThat(mockSpan.tags()).doesNotContainKey(TAG); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testRequestMonitorNonMvcRequestDoMonitor() throws Exception { when(servletPlugin.isMonitorOnlySpringMvcRequests()).thenReturn(false); final MonitoredHttpRequest monitoredRequest = createMonitoredHttpRequest(nonMvcRequest); SpanContextInformation spanContext = requestMonitor.monitor(monitoredRequest); assertEquals("GET *.js", spanContext.getOperationName()); assertEquals("GET *.js", spanContext.getOperationName()); assertThat(registry.getTimers()).doesNotContainKey(getResponseTimeMetricName(spanContext.getOperationName(), "http")); assertThat(registry.getTimers()).containsKey(getResponseTimeMetricName("All", "http")); verify(monitoredRequest, times(1)).getRequestName(); assertThat(tags.get(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testProcessSpan_withUpperIgnoresIfGreater() throws Exception { // Given addServletParameter("6"); ClientSpanTagProcessor clientSpanLongTagProcessor = new ClientSpanLongTagProcessor(TYPE_ALL, TAG, REQUEST_PARAMETER_NAME) .upperBound(5L); // When SpanWrapper span = runProcessor(clientSpanLongTagProcessor); // Then assertThat(mockTracer.finishedSpans()).hasSize(1); MockSpan mockSpan = mockTracer.finishedSpans().get(0); assertThat(mockSpan.tags()).doesNotContainKeys(TAG); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testProcessSpan_withLowerBoundIgnoresIfLower() throws Exception { // Given addServletParameter("4"); ClientSpanTagProcessor clientSpanLongTagProcessor = new ClientSpanLongTagProcessor(TYPE_ALL, TAG, REQUEST_PARAMETER_NAME) .lowerBound(5L); // When SpanWrapper span = runProcessor(clientSpanLongTagProcessor); // Then assertThat(mockTracer.finishedSpans()).hasSize(1); MockSpan mockSpan = mockTracer.finishedSpans().get(0); assertThat(mockSpan.tags()).doesNotContainKeys(TAG); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void rateLimiterPositive() throws Exception { RateLimiterRegistry registry = RateLimiterRegistry.of(config); RateLimiter firstRateLimiter = registry.rateLimiter("test"); RateLimiter anotherLimit = registry.rateLimiter("test1"); RateLimiter sameAsFirst = registry.rateLimiter("test"); then(firstRateLimiter).isEqualTo(sameAsFirst); then(firstRateLimiter).isNotEqualTo(anotherLimit); }
@Test public void newShellWhenAddJars() { //given ScalaEvaluatorGlue shell = scalaEvaluator.getShell(); ClassLoader classLoader = scalaEvaluator.getClassLoader(); //when scalaEvaluator.addJarsToClasspath(singletonList(new PathToJar(DEMO_JAR))); //then assertThat(scalaEvaluator.getShell()).isNotEqualTo(shell); assertThat(scalaEvaluator.getClassLoader()).isEqualTo(classLoader); assertThat(shell.interpreter().lastRequest().lineRep().lineId()) .isEqualTo(scalaEvaluator.getShell().interpreter().lastRequest().lineRep().lineId()); }
@Test public void copyNotClone() { BreakpointInfo info = new BreakpointInfo(0, "", new File(""), null); info.addBlock(new BlockInfo(0, 0)); info.setChunked(true); final BreakpointInfo copy = info.copy(); assertThat(info.getBlock(0)).isNotEqualTo(copy.getBlock(0)); assertThat(copy.isChunked()).isTrue(); }