@After public void afterMethod() { resetTracing(); }
@Before public void beforeMethod() { supplierMock = mock(Supplier.class); outObj = new Object(); throwExceptionDuringCall = false; currentSpanStackWhenSupplierWasCalled = new ArrayList<>(); currentMdcInfoWhenSupplierWasCalled = new ArrayList<>(); doAnswer(invocation -> { currentSpanStackWhenSupplierWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy()); currentMdcInfoWhenSupplierWasCalled.add(MDC.getCopyOfContextMap()); if (throwExceptionDuringCall) throw new RuntimeException("kaboom"); return outObj; }).when(supplierMock).get(); resetTracing(); }
supplierMock, spanStack, mdcInfo ); resetTracing(); assertThat(Tracer.getInstance().getCurrentSpanStackCopy()).isNull(); assertThat(MDC.getCopyOfContextMap()).isNullOrEmpty();