public void checkNoSymbolExists(SensorContextTester context, int line, int column) { Collection<TextRange> foundReferences = context.referencesForSymbolAt(componentKey, line, column); String message = "no symbol is expected to exist at line " + line + " and column " + column; assertThat(foundReferences).as(message).isNull(); }
@Test public void doChannelInactive_does_not_explode_if_span_is_missing() throws Exception { // given Assertions.assertThat(state.getDistributedTraceStack()).isNull(); // when PipelineContinuationBehavior result = handler.doChannelInactive(ctxMock); // then verify(requestInfoMock).releaseAllResources(); verify(proxyRouterStateMock).cancelRequestStreaming(any(), any()); verify(proxyRouterStateMock).cancelDownstreamRequest(any()); Assertions.assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when FunctionWithTracingAndMdcSupport instance = new FunctionWithTracingAndMdcSupport(functionMock, (Pair)null); // then assertThat(instance.origFunction).isSameAs(functionMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when CallableWithTracingAndMdcSupport instance = new CallableWithTracingAndMdcSupport(callableMock, (Pair)null); // then assertThat(instance.origCallable).isSameAs(callableMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void getCurrentSpanStackCopy_returns_null_if_original_is_null() { // given Tracer tracer = Tracer.getInstance(); assertThat(getSpanStackSize()).isEqualTo(0); // expect assertThat(tracer.getCurrentSpanStackCopy()).isNull(); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when BiFunctionWithTracingAndMdcSupport instance = new BiFunctionWithTracingAndMdcSupport(biFunctionMock, (Pair)null); // then assertThat(instance.origBiFunction).isSameAs(biFunctionMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when BiConsumerWithTracingAndMdcSupport instance = new BiConsumerWithTracingAndMdcSupport(consumerMock, (Pair)null); // then assertThat(instance.origBiConsumer).isSameAs(consumerMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when ConsumerWithTracingAndMdcSupport instance = new ConsumerWithTracingAndMdcSupport(consumerMock, (Pair)null); // then assertThat(instance.origConsumer).isSameAs(consumerMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when ChannelFutureListenerWithTracingAndMdc instance = new ChannelFutureListenerWithTracingAndMdc(consumerMock, (Pair)null); // then assertThat(instance.postCompleteOperation).isSameAs(consumerMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when SupplierWithTracingAndMdcSupport instance = new SupplierWithTracingAndMdcSupport(supplierMock, (Pair)null); // then assertThat(instance.origSupplier).isSameAs(supplierMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null() { // when RunnableWithTracingAndMdcSupport instance = new RunnableWithTracingAndMdcSupport(runnableMock, (Pair)null); // then assertThat(instance.origRunnable).isSameAs(runnableMock); assertThat(instance.distributedTraceStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void testGetAttributesSortedStringSetNotExists() throws Exception { final Attributes attrs = new BasicAttributes(); class TestableDirContextAdapter extends DirContextAdapter { public TestableDirContextAdapter() { super(attrs, null); } } tested = new TestableDirContextAdapter(); SortedSet s = tested.getAttributeSortedStringSet("abc"); assertThat(s).isNull(); }
@Test public void completeSubSpan_should_do_nothing_if_the_span_stack_is_null() { // given: a null span stack assertThat(Tracer.getInstance().getCurrentSpan()).isNull(); assertThat(getSpanStackSize()).isEqualTo(0); assertThat(getSpanStackFromTracer()).isNull(); // when: completeSubSpan() is called Tracer.getInstance().completeSubSpan(); // then: nothing should be done because the stack is null assertThat(Tracer.getInstance().getCurrentSpan()).isNull(); assertThat(getSpanStackSize()).isEqualTo(0); assertThat(getSpanStackFromTracer()).isNull(); }
@DataProvider(value = { "true", "false" }) @Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null(boolean useStaticFactory) { // when SupplierWithTracing instance = (useStaticFactory) ? withTracing(supplierMock, (Pair)null) : new SupplierWithTracing(supplierMock, (Pair)null); // then assertThat(instance.origSupplier).isSameAs(supplierMock); assertThat(instance.spanStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@DataProvider(value = { "true", "false" }) @Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null(boolean useStaticFactory) { // when RunnableWithTracing instance = (useStaticFactory) ? withTracing(runnableMock, (Pair)null) : new RunnableWithTracing(runnableMock, (Pair)null); // then assertThat(instance.origRunnable).isSameAs(runnableMock); assertThat(instance.spanStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@DataProvider(value = { "true", "false" }) @Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null(boolean useStaticFactory) { // when SuccessCallbackWithTracing instance = (useStaticFactory) ? withTracing(successCallbackMock, (Pair)null) : new SuccessCallbackWithTracing(successCallbackMock, (Pair)null); // then assertThat(instance.origSuccessCallback).isSameAs(successCallbackMock); assertThat(instance.spanStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@DataProvider(value = { "true", "false" }) @Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null(boolean useStaticFactory) { // when BiPredicateWithTracing instance = (useStaticFactory) ? withTracing(biPredicateMock, (Pair)null) : new BiPredicateWithTracing(biPredicateMock, (Pair)null); // then assertThat(instance.origBiPredicate).isSameAs(biPredicateMock); assertThat(instance.spanStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@DataProvider(value = { "true", "false" }) @Test public void pair_constructor_sets_fields_as_expected_when_pair_is_null(boolean useStaticFactory) { // when CallableWithTracing instance = (useStaticFactory) ? withTracing(callableMock, (Pair)null) : new CallableWithTracing(callableMock, (Pair)null); // then assertThat(instance.origCallable).isSameAs(callableMock); assertThat(instance.spanStackForExecution).isNull(); assertThat(instance.mdcContextMapForExecution).isNull(); }
@Test public void registerWithThread_should_reset_everything_if_passed_null() { // given Tracer tracer = Tracer.getInstance(); tracer.startRequestWithRootSpan("foo"); Span subspan = tracer.startSubSpan("bar", SpanPurpose.LOCAL_ONLY); assertThat(MDC.get(Tracer.TRACE_ID_MDC_KEY)).isEqualTo(subspan.getTraceId()); assertThat(MDC.get(Tracer.SPAN_JSON_MDC_KEY)).isEqualTo(subspan.toJSON()); // when tracer.registerWithThread(null); // then assertThat(getSpanStackThreadLocal().get()).isNull(); assertThat(MDC.get(Tracer.TRACE_ID_MDC_KEY)).isNull(); assertThat(MDC.get(Tracer.SPAN_JSON_MDC_KEY)).isNull(); }
@Test public void getDefaultValue() { assertThat(rxPreferences.getBoolean("key1", false).asValue()).isFalse(); assertThat(rxPreferences.getFloat("key2", 0F).asValue()).isZero(); assertThat(rxPreferences.getInt("key3", 0).asValue()).isZero(); assertThat(rxPreferences.getLong("key4", 0L).asValue()).isZero(); assertThat(rxPreferences.getString("key5", null).asValue()).isNull(); assertThat(rxPreferences.getStringSet("key6", null).asValue()).isNull(); }