WingtipsRequestSpanCompletionAsyncListener implements AsyncListener { @Override public void onStartAsync(AsyncEvent event) { AsyncContext eventAsyncContext = event.getAsyncContext(); if (eventAsyncContext != null) { eventAsyncContext.addListener(this, event.getSuppliedRequest(), event.getSuppliedResponse()); } } WingtipsRequestSpanCompletionAsyncListener(
        TracingState originalRequestTracingState,
        HttpTagAndSpanNamingStrategy<HttpServletRequest, HttpServletResponse> tagAndNamingStrategy,
        HttpTagAndSpanNamingAdapter<HttpServletRequest, HttpServletResponse> tagAndNamingAdapter
    ); @Override void onComplete(AsyncEvent event); @Override void onTimeout(AsyncEvent event); @Override void onError(AsyncEvent event); @Override void onStartAsync(AsyncEvent event);  }
@Test public void onStartAsync_propagates_the_listener_to_the_new_AsyncContext() { AsyncContext asyncContextMock = mock(AsyncContext.class); doReturn(asyncContextMock).when(asyncEventMock).getAsyncContext(); implSpy.onStartAsync(asyncEventMock); verify(asyncContextMock).addListener(implSpy, requestMock, responseMock); }
@Test public void onStartAsync_does_nothing_if_asyncEvent_has_null_AsyncContext() { doReturn(null).when(asyncEventMock).getAsyncContext(); implSpy.onStartAsync(asyncEventMock); verify(implSpy).onStartAsync(asyncEventMock); verifyNoMoreInteractions(implSpy); }