@After public void afterMethod() { resetTracing(); }
@Before public void beforeMethod() { functionMock = mock(Function.class); inObj = 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(functionMock).apply(inObj); resetTracing(); }
functionMock, spanStack, mdcInfo ); resetTracing(); assertThat(Tracer.getInstance().getCurrentSpanStackCopy()).isNull(); assertThat(MDC.getCopyOfContextMap()).isNullOrEmpty();