### Question:
TagUtils { public static String convertHeadersToString(MultivaluedMap<String, ?> headers) { if (headers != null) { MultivaluedMap<String, ?> sanitizedHeaders = sanitizeHeaders(headers); return sanitizedHeaders.entrySet().stream() .map( entry -> join( "[", entry.getKey(), " = '", entry.getValue().stream() .map(Object::toString) .collect(Collectors.joining("', '")), "']")) .collect(Collectors.joining("; ")); } return null; } 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 shouldConvertSingleHeaderToString() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(LOCATION, singletonList("1")); String tag = convertHeadersToString(headers); assertThat(tag).isEqualTo("[Location = '1']"); }
@Test public void shouldConvertMultipleHeadersToString() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(LOCATION, singletonList("1")); headers.put(TRANSFER_ENCODING, singletonList("2")); String tag = convertHeadersToString(headers); assertThat(tag).isEqualTo("[Transfer-Encoding = '2']; [Location = '1']"); }
@Test public void shouldConvertMultiValueHeaderToString() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); headers.put(LOCATION, asList("1", "2")); String tag = convertHeadersToString(headers); assertThat(tag).isEqualTo("[Location = '1', '2']"); }
@Test public void shouldReturnEmptyStringIfNoHeaders() { MultivaluedMap<String, String> headers = new MultivaluedHashMap<>(); String tag = convertHeadersToString(headers); assertThat(tag).isEmpty(); }
@Test public void shouldReturnNullIfPassedNull() { String tag = convertHeadersToString(null); assertThat(tag).isNull(); }