/** * Delegates to {@link * ServletRuntime#setupTracingCompletionWhenAsyncRequestCompletes(HttpServletRequest, HttpServletResponse, * TracingState, HttpTagAndSpanNamingStrategy, HttpTagAndSpanNamingAdapter)}, with the {@link ServletRuntime} * retrieved via {@link #getServletRuntime(ServletRequest)}. This method is here to allow easy overriding by * subclasses if needed, where {@link ServletRuntime} is not in scope. * * @param asyncRequest The async servlet request (guaranteed to be async since this method will only be called when * {@link #isAsyncRequest(HttpServletRequest)} returns true). * @param asyncResponse The servlet response object - needed for span tagging. * @param originalRequestTracingState The {@link TracingState} that was generated when this request started, and * which should be completed when the given async servlet request finishes. * @param tagAndNamingStrategy The {@link HttpTagAndSpanNamingStrategy} that should be used for final span name * and tagging. * @param tagAndNamingAdapter The {@link HttpTagAndSpanNamingAdapter} that should be used by * {@code tagAndNamingStrategy} for final span name and tagging. */ protected void setupTracingCompletionWhenAsyncRequestCompletes( HttpServletRequest asyncRequest, HttpServletResponse asyncResponse, TracingState originalRequestTracingState, HttpTagAndSpanNamingStrategy<HttpServletRequest, HttpServletResponse> tagAndNamingStrategy, HttpTagAndSpanNamingAdapter<HttpServletRequest,HttpServletResponse> tagAndNamingAdapter ) { getServletRuntime(asyncRequest).setupTracingCompletionWhenAsyncRequestCompletes( asyncRequest, asyncResponse, originalRequestTracingState, tagAndNamingStrategy, tagAndNamingAdapter ); }
@Test public void setupTracingCompletionWhenAsyncRequestCompletes_delegates_to_ServletRuntime() { // given RequestTracingFilter filterSpy = spy(getBasicFilter()); doReturn(servletRuntimeMock).when(filterSpy).getServletRuntime(any(HttpServletRequest.class)); TracingState tracingStateMock = mock(TracingState.class); // when filterSpy.setupTracingCompletionWhenAsyncRequestCompletes( requestMock, responseMock, tracingStateMock, tagAndNamingStrategy, tagAndNamingAdapterMock ); // then verify(filterSpy).setupTracingCompletionWhenAsyncRequestCompletes( requestMock, responseMock, tracingStateMock, tagAndNamingStrategy, tagAndNamingAdapterMock ); verify(filterSpy).getServletRuntime(requestMock); verify(servletRuntimeMock).setupTracingCompletionWhenAsyncRequestCompletes( requestMock, responseMock, tracingStateMock, tagAndNamingStrategy, tagAndNamingAdapterMock ); verifyNoMoreInteractions(filterSpy, servletRuntimeMock, requestMock, tracingStateMock); }