### Question:
HasHeader 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(), ", ") + "]"); } } HasHeader(String name); @Override void describeTo(Description description);  }### Answer:
@Test public void matcherShouldDescribeMismatchCorrectlyWithNoHeaders() { Description description = new StringDescription(); Response mockResponse = mock(Response.class); matcher.describeMismatchSafely(mockResponse, description); assertThat(description.toString(), is("Response has no headers")); }
@Test public void matcherShouldDescribeMismatchCorrectlyWithHeaders() { List<Header> headers = Arrays.asList(new Header("This: that"), new Header("The: other")); Description description = new StringDescription(); Response mockResponse = mock(Response.class); when(mockResponse.getHeaders()).thenReturn(headers); matcher.describeMismatchSafely(mockResponse, description); assertThat(description.toString(), is("Response has headers [This: that, The: other]")); }