@Test
public void getInputStreamReturnsErrorStreamWhenHttpURLConnectionReturnsErrorStream() throws Exception {

    InputStream expected = new ByteArrayInputStream(new byte[0]);
    HttpURLConnection connection = mock(HttpURLConnection.class);
    when(connection.getErrorStream()).thenReturn(expected);
    HttpResponse httpResponse = new HttpResponse(connection);
    InputStream actual = httpResponse.getInputStream();
    assertThat(actual, is(not(nullValue())));
    assertThat(actual, is(sameInstance(expected)));
}