### Question:
HasHeaderWithValue extends TypeSafeMatcher<Response> { @Override protected void describeMismatchSafely(Response response, Description mismatchDescription) { List<Header> headers = response.getHeaders(); if (headers.isEmpty()) { mismatchDescription.appendText("Response has no headers"); } else { mismatchDescription.appendText("Response has headers [" + StringUtils.join(response.getHeaders(), ", ") + "]"); } } HasHeaderWithValue(String name, Matcher<String> valueMatcher); @Override void describeTo(Description description);  }### Answer:
@Test public void matcherShouldDescribeMismatchCorrectlyIfResponseHasNoHeaders() { Response mockResponse = mock(Response.class); Description description = new StringDescription(); matcher.describeMismatchSafely(mockResponse, description); assertThat(description.toString(), is("Response has no headers")); }
@Test public void matcherShouldDescribeMismatchCorrectlyIfResponseHasHeaders() { Response mockResponse = mock(Response.class); when(mockResponse.getHeaders()).thenReturn(Arrays.asList(new Header("Header1: value"), new Header("Header2: value"))); Description description = new StringDescription(); matcher.describeMismatchSafely(mockResponse, description); assertThat(description.toString(), is("Response has headers [Header1: value, Header2: value]")); }