### Question:
TagUtils { public static <T> MultivaluedMap<String, T> sanitizeHeaders(MultivaluedMap<String, T> headers) { MultivaluedMap<String, T> sanitizedHeaders = new MultivaluedHashMap<>(); headers.forEach( (key, value) -> { if (AUTHORIZATION.equalsIgnoreCase(key)) { sanitizedHeaders.put( key, value.stream() .map(h -> (T) sanitizeAuthorizationHeader(h.toString())) .collect(Collectors.toList())); } else if (SET_COOKIE.equalsIgnoreCase(key) || COOKIE.equalsIgnoreCase(key)) { sanitizedHeaders.putSingle(key, (T) "…"); } else { sanitizedHeaders.put(key, value); } }); return sanitizedHeaders; } private  TagUtils(); static String convertHeadersToString(MultivaluedMap<String, ?> headers); static MultivaluedMap<String, T> sanitizeHeaders(MultivaluedMap<String, T> headers); static final StringTag HTTP_REQUEST_HEADERS; static final StringTag HTTP_RESPONSE_HEADERS; }### Answer:
@Test public void shouldSanitizeSetCookieHeader() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(SET_COOKIE, singletonList("1234")); MultivaluedMap<String, ?> sanitizedHeaders = sanitizeHeaders(headers); assertThat(sanitizedHeaders.getFirst(SET_COOKIE)).isEqualTo("…"); }
@Test public void shouldSanitizeCookieHeader() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(COOKIE, singletonList("1234")); MultivaluedMap<String, ?> sanitizedHeaders = sanitizeHeaders(headers); assertThat(sanitizedHeaders.getFirst(COOKIE)).isEqualTo("…"); }
@Test public void shouldSanitizeAuthorizationHeader() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(AUTHORIZATION, singletonList("1234")); MultivaluedMap<String, ?> sanitizedHeaders = sanitizeHeaders(headers); assertThat(sanitizedHeaders.getFirst(AUTHORIZATION)).isEqualTo("…"); }
@Test public void shouldSanitizeBearerTokenInAuthorizationHeader() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(AUTHORIZATION, singletonList("Bearer 1234")); MultivaluedMap<String, ?> sanitizedHeaders = sanitizeHeaders(headers); assertThat(sanitizedHeaders.getFirst(AUTHORIZATION)).isEqualTo("Bearer …"); }