HttpResponse { public int getStatusCode() throws IOException { return statusCode; } HttpResponse(HttpURLConnection httpURLConnection); int getStatusCode(); InputStream getInputStream(); String getContent(); void disconnect();  }
@Test public void getStatusCodeReturn404WhenHttpURLConnectionReturn404() throws Exception { HttpURLConnection connection = mock(HttpURLConnection.class); when(connection.getResponseCode()).thenReturn(404); HttpResponse httpResponse = new HttpResponse(connection); assertThat(httpResponse.getStatusCode(), is(404)); }
@Test public void getStatusCodeReturn200WhenHttpURLConnectionReturn200() throws Exception { HttpURLConnection connection = mock(HttpURLConnection.class); when(connection.getResponseCode()).thenReturn(200); HttpResponse httpResponse = new HttpResponse(connection); assertThat(httpResponse.getStatusCode(), is(200)); }