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