@Override public void call() throws Throwable { withTracing(null, spanStackMock, mdcInfoMock); } })).isInstanceOf(IllegalArgumentException.class);
@Override public void call() throws Throwable { withTracing(null); } })).isInstanceOf(IllegalArgumentException.class);
@Override public void call() throws Throwable { withTracing(null, Pair.of(spanStackMock, mdcInfoMock)); } })).isInstanceOf(IllegalArgumentException.class);
@DataProvider(value = { "true", "false" }) @Test public void kitchen_sink_constructor_sets_fields_as_expected(boolean useStaticFactory) { // given Deque<Span> spanStackMock = mock(Deque.class); Map<String, String> mdcInfoMock = mock(Map.class); // when RunnableWithTracing instance = (useStaticFactory) ? withTracing(runnableMock, spanStackMock, mdcInfoMock) : new RunnableWithTracing(runnableMock, spanStackMock, mdcInfoMock); // then assertThat(instance.origRunnable).isSameAs(runnableMock); assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock); assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock); }
@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 | true | true", "true | false | true", "false | true | true", "false | false | true", "true | true | false", "true | false | false", "false | true | false", "false | false | false", }, splitBy = "\\|") @Test public void pair_constructor_sets_fields_as_expected( boolean nullSpanStack, boolean nullMdcInfo, boolean useStaticFactory ) { // given Deque<Span> spanStackMock = (nullSpanStack) ? null : mock(Deque.class); Map<String, String> mdcInfoMock = (nullMdcInfo) ? null : mock(Map.class); // when RunnableWithTracing instance = (useStaticFactory) ? withTracing(runnableMock, Pair.of(spanStackMock, mdcInfoMock)) : new RunnableWithTracing(runnableMock, Pair.of(spanStackMock, mdcInfoMock) ); // then assertThat(instance.origRunnable).isSameAs(runnableMock); assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock); assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock); }
@DataProvider(value = { "true", "false" }) @Test public void current_thread_info_constructor_sets_fields_as_expected(boolean useStaticFactory) { // given Tracer.getInstance().startRequestWithRootSpan("request-" + UUID.randomUUID().toString()); Deque<Span> spanStackMock = Tracer.getInstance().getCurrentSpanStackCopy(); Map<String, String> mdcInfoMock = MDC.getCopyOfContextMap(); // when RunnableWithTracing instance = (useStaticFactory) ? withTracing(runnableMock) : new RunnableWithTracing(runnableMock); // then assertThat(instance.origRunnable).isSameAs(runnableMock); assertThat(instance.spanStackForExecution).isEqualTo(spanStackMock); assertThat(instance.mdcContextMapForExecution).isEqualTo(mdcInfoMock); }