### Question:
URLFetchUtils { static String getSingleHeader(HTTPResponse resp, String headerName) { return Iterables.getOnlyElement(getHeaders(resp, headerName)).getValue(); } private  URLFetchUtils();   }### Answer:
@Test public void testGetSingleHeader() { HTTPResponse response = mock(HTTPResponse.class); try { URLFetchUtils.getSingleHeader(response, "k1"); fail("NoSuchElementException expected"); } catch (NoSuchElementException expected) { } List<HTTPHeader> headers = ImmutableList.of(new HTTPHeader("k3", "v3"), new HTTPHeader("k1", "v1")); when(response.getHeadersUncombined()).thenReturn(headers); assertEquals("v1", URLFetchUtils.getSingleHeader(response, "k1")); headers = ImmutableList.of(new HTTPHeader("k3", "v3"), new HTTPHeader("k1", "v1"), new HTTPHeader("k1", "v2")); when(response.getHeadersUncombined()).thenReturn(headers); try { URLFetchUtils.getSingleHeader(response, "k1"); fail("NoSuchElementException expected"); } catch (IllegalArgumentException expected) { } }