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