@Test public void getInputStreamReturnsErrorStreamWhenHttpConnectionReturnsBothErrorStreamAndInputStream() throws Exception { InputStream inputStream = new ByteArrayInputStream(new byte[0]); InputStream errorStream = new ByteArrayInputStream(new byte[0]); HttpURLConnection connection = mock(HttpURLConnection.class); when(connection.getErrorStream()).thenReturn(errorStream); when(connection.getInputStream()).thenReturn(inputStream); HttpResponse httpResponse = new HttpResponse(connection); InputStream actual = httpResponse.getInputStream(); assertThat(actual, is(not(nullValue()))); assertThat(actual, is(sameInstance(errorStream))); }
public InputStream getInputStream() { return inputStream; }
HttpResponse { public InputStream getInputStream() { return inputStream; } }
HttpResponse { public InputStream getInputStream() { return inputStream; } HttpResponse(HttpURLConnection httpURLConnection); }
HttpResponse { public InputStream getInputStream() { return inputStream; } HttpResponse(HttpURLConnection httpURLConnection); int getStatusCode(); InputStream getInputStream(); String getContent(); void disconnect(); }
HttpResponse { public InputStream getInputStream() { return inputStream; } HttpResponse(HttpURLConnection httpURLConnection); int getStatusCode(); InputStream getInputStream(); String getContent(); void disconnect();  }