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