HeaderAccessUtils { public static Collection<String> caseInsensitiveGet(Map<String, Collection<String>> headers, String headerName) { Collection<String> result = new LinkedList<>(); boolean neverFound = true; for (Map.Entry<String, Collection<String>> entry : headers.entrySet()) { String key = entry.getKey(); if (headerName.equalsIgnoreCase(key)) { neverFound = false; result.addAll(entry.getValue()); } } return neverFound ? null : result; } private  HeaderAccessUtils(); static boolean caseInsensitiveContains(Map<String, Collection<String>> headers, String headerName); static Collection<String> caseInsensitiveGet(Map<String, Collection<String>> headers, String headerName);  }
@Test public void caseInsensitiveGetReturnsNullForNotExistingHeader() { assertThat(HeaderAccessUtils.caseInsensitiveGet(TEST_HEADERS_MAP, "invalid")) .isNull(); }
@Test public void caseInsensitiveGetReturnsAllExistingHeaders() { assertThat(HeaderAccessUtils.caseInsensitiveGet(TEST_HEADERS_MAP, "HeADER")) .contains("value1", "value2", "value3", "value4", "value5"); }