@After public void afterMethod() { resetTracing(); }
@Before public void beforeMethod() { biConsumerMock = mock(BiConsumer.class); inObj1 = new Object(); inObj2 = new Object(); throwExceptionDuringCall = false; currentSpanStackWhenBiConsumerWasCalled = new ArrayList<>(); currentMdcInfoWhenBiConsumerWasCalled = new ArrayList<>(); doAnswer(invocation -> { currentSpanStackWhenBiConsumerWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy()); currentMdcInfoWhenBiConsumerWasCalled.add(MDC.getCopyOfContextMap()); if (throwExceptionDuringCall) throw new RuntimeException("kaboom"); return null; }).when(biConsumerMock).accept(inObj1, inObj2); resetTracing(); }
biConsumerMock, spanStack, mdcInfo ); resetTracing(); assertThat(Tracer.getInstance().getCurrentSpanStackCopy()).isNull(); assertThat(MDC.getCopyOfContextMap()).isNullOrEmpty();