@Test public void shouldAddTraceeHeaderToResponse() { Tracee.getBackend().put(INVOCATION_ID_KEY, "mySuperValue"); final HttpServletRequest request = mock(HttpServletRequest.class); final HttpServletResponse response = mock(HttpServletResponse.class); advice.beforeBodyWrite(null, null, null, null, new ServletServerHttpRequest(request), new ServletServerHttpResponse(response)); verify(response).setHeader(eq(TraceeConstants.TPIC_HEADER), eq(INVOCATION_ID_KEY + "=mySuperValue")); }
@Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest springHttpRequest, ServerHttpResponse springHttpResponse) { if (springHttpRequest instanceof ServletServerHttpRequest && springHttpResponse instanceof ServletServerHttpResponse) { final HttpServletRequest request = ((ServletServerHttpRequest) springHttpRequest).getServletRequest(); final HttpServletResponse response = ((ServletServerHttpResponse) springHttpResponse).getServletResponse(); interceptor.afterCompletion(request, response, null, null); } return body; }
TraceeResponseBodyAdvice implements ResponseBodyAdvice<Object> { @Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest springHttpRequest, ServerHttpResponse springHttpResponse) { if (springHttpRequest instanceof ServletServerHttpRequest && springHttpResponse instanceof ServletServerHttpResponse) { final HttpServletRequest request = ((ServletServerHttpRequest) springHttpRequest).getServletRequest(); final HttpServletResponse response = ((ServletServerHttpResponse) springHttpResponse).getServletResponse(); interceptor.afterCompletion(request, response, null, null); } return body; } }
TraceeResponseBodyAdvice implements ResponseBodyAdvice<Object> { @Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest springHttpRequest, ServerHttpResponse springHttpResponse) { if (springHttpRequest instanceof ServletServerHttpRequest && springHttpResponse instanceof ServletServerHttpResponse) { final HttpServletRequest request = ((ServletServerHttpRequest) springHttpRequest).getServletRequest(); final HttpServletResponse response = ((ServletServerHttpResponse) springHttpResponse).getServletResponse(); interceptor.afterCompletion(request, response, null, null); } return body; } TraceeResponseBodyAdvice();   TraceeResponseBodyAdvice(TraceeInterceptor interceptor); }
TraceeResponseBodyAdvice implements ResponseBodyAdvice<Object> { @Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest springHttpRequest, ServerHttpResponse springHttpResponse) { if (springHttpRequest instanceof ServletServerHttpRequest && springHttpResponse instanceof ServletServerHttpResponse) { final HttpServletRequest request = ((ServletServerHttpRequest) springHttpRequest).getServletRequest(); final HttpServletResponse response = ((ServletServerHttpResponse) springHttpResponse).getServletResponse(); interceptor.afterCompletion(request, response, null, null); } return body; } TraceeResponseBodyAdvice();   TraceeResponseBodyAdvice(TraceeInterceptor interceptor); @Override boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType); @Override Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
																Class<? extends HttpMessageConverter<?>> selectedConverterType,
																ServerHttpRequest springHttpRequest, ServerHttpResponse springHttpResponse); }
TraceeResponseBodyAdvice implements ResponseBodyAdvice<Object> { @Override public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest springHttpRequest, ServerHttpResponse springHttpResponse) { if (springHttpRequest instanceof ServletServerHttpRequest && springHttpResponse instanceof ServletServerHttpResponse) { final HttpServletRequest request = ((ServletServerHttpRequest) springHttpRequest).getServletRequest(); final HttpServletResponse response = ((ServletServerHttpResponse) springHttpResponse).getServletResponse(); interceptor.afterCompletion(request, response, null, null); } return body; } TraceeResponseBodyAdvice();   TraceeResponseBodyAdvice(TraceeInterceptor interceptor); @Override boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType); @Override Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType,
																Class<? extends HttpMessageConverter<?>> selectedConverterType,
																ServerHttpRequest springHttpRequest, ServerHttpResponse springHttpResponse);  }