@After public void afterMethod() { resetTracing(); }
@Before public void beforeMethod() { predicateMock = mock(Predicate.class); inObj = new Object(); throwExceptionDuringCall = false; returnValIfNoException = true; currentSpanStackWhenPredicateWasCalled = new ArrayList<>(); currentMdcInfoWhenPredicateWasCalled = new ArrayList<>(); doAnswer(invocation -> { currentSpanStackWhenPredicateWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy()); currentMdcInfoWhenPredicateWasCalled.add(MDC.getCopyOfContextMap()); if (throwExceptionDuringCall) throw new RuntimeException("kaboom"); return returnValIfNoException; }).when(predicateMock).test(inObj); resetTracing(); }
predicateMock, spanStack, mdcInfo ); resetTracing(); assertThat(Tracer.getInstance().getCurrentSpanStackCopy()).isNull(); assertThat(MDC.getCopyOfContextMap()).isNullOrEmpty();