@Test public void responseDeleteAbsentHeaders() { List<String> ignoredHeaders = Arrays.asList("simpleHeader", "host", "someOtherHeader"); logMaskerService.execute(POST_TYPE, false, false, true, ignoredHeaders); RequestResponseParser response = TraceContextHolder.getInstance().getActualTrace().getResponse(); assertNotNull(response.getBody()); assertNotNull(response.getUri()); assertNotNull(response.getHeaders()); assertNull(response.getHeaders().get("simpleHeader")); assertNull(response.getHeaders().get("host")); assertNull(response.getHeaders().get("someOtherHeader")); }
public void execute(String filterType, Boolean deleteBody, Boolean deleteUri, Boolean headers, List<String> ignoredHeaders) { RequestResponseParser requestResponseParser = null; switch (filterType) { case PRE_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getRequest(); break; case POST_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getResponse(); break; default: break; } if (requestResponseParser != null) { if (deleteBody) requestResponseParser.setBody(null); if (deleteUri) requestResponseParser.setUri(null); if (headers) { if (ignoredHeaders.isEmpty()) { requestResponseParser.setHeaders(null); } else { final Map<String, String> requestResponseHeaders = requestResponseParser.getHeaders(); ignoredHeaders.forEach(requestResponseHeaders::remove); } } } }
LogMaskerService { public void execute(String filterType, Boolean deleteBody, Boolean deleteUri, Boolean headers, List<String> ignoredHeaders) { RequestResponseParser requestResponseParser = null; switch (filterType) { case PRE_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getRequest(); break; case POST_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getResponse(); break; default: break; } if (requestResponseParser != null) { if (deleteBody) requestResponseParser.setBody(null); if (deleteUri) requestResponseParser.setUri(null); if (headers) { if (ignoredHeaders.isEmpty()) { requestResponseParser.setHeaders(null); } else { final Map<String, String> requestResponseHeaders = requestResponseParser.getHeaders(); ignoredHeaders.forEach(requestResponseHeaders::remove); } } } } }
LogMaskerService { public void execute(String filterType, Boolean deleteBody, Boolean deleteUri, Boolean headers, List<String> ignoredHeaders) { RequestResponseParser requestResponseParser = null; switch (filterType) { case PRE_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getRequest(); break; case POST_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getResponse(); break; default: break; } if (requestResponseParser != null) { if (deleteBody) requestResponseParser.setBody(null); if (deleteUri) requestResponseParser.setUri(null); if (headers) { if (ignoredHeaders.isEmpty()) { requestResponseParser.setHeaders(null); } else { final Map<String, String> requestResponseHeaders = requestResponseParser.getHeaders(); ignoredHeaders.forEach(requestResponseHeaders::remove); } } } }  }
LogMaskerService { public void execute(String filterType, Boolean deleteBody, Boolean deleteUri, Boolean headers, List<String> ignoredHeaders) { RequestResponseParser requestResponseParser = null; switch (filterType) { case PRE_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getRequest(); break; case POST_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getResponse(); break; default: break; } if (requestResponseParser != null) { if (deleteBody) requestResponseParser.setBody(null); if (deleteUri) requestResponseParser.setUri(null); if (headers) { if (ignoredHeaders.isEmpty()) { requestResponseParser.setHeaders(null); } else { final Map<String, String> requestResponseHeaders = requestResponseParser.getHeaders(); ignoredHeaders.forEach(requestResponseHeaders::remove); } } } }  void execute(String filterType,
                        Boolean deleteBody,
                        Boolean deleteUri,
                        Boolean headers,
                        List<String> ignoredHeaders); }
LogMaskerService { public void execute(String filterType, Boolean deleteBody, Boolean deleteUri, Boolean headers, List<String> ignoredHeaders) { RequestResponseParser requestResponseParser = null; switch (filterType) { case PRE_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getRequest(); break; case POST_TYPE: requestResponseParser = TraceContextHolder.getInstance().getActualTrace().getResponse(); break; default: break; } if (requestResponseParser != null) { if (deleteBody) requestResponseParser.setBody(null); if (deleteUri) requestResponseParser.setUri(null); if (headers) { if (ignoredHeaders.isEmpty()) { requestResponseParser.setHeaders(null); } else { final Map<String, String> requestResponseHeaders = requestResponseParser.getHeaders(); ignoredHeaders.forEach(requestResponseHeaders::remove); } } } }  void execute(String filterType,
                        Boolean deleteBody,
                        Boolean deleteUri,
                        Boolean headers,
                        List<String> ignoredHeaders);  }