### Question:
AndroidHttpClient extends StdHttpClient { @Override public HttpResponse post(String uri, InputStream content) { InputStreamEntity e = new InputStreamEntity(content, -1); e.setContentType("application/json"); HttpPost post = new HttpPost(uri); post.setEntity(e); return executeRequest(post, true); } AndroidHttpClient(org.apache.http.client.HttpClient hc);  AndroidHttpClient(org.apache.http.client.HttpClient hc, org.apache.http.client.HttpClient backend); @Override HttpResponse post(String uri, InputStream content);  }### Answer:
@Test public void shouldInvokeBackendWhenPostWithStringParamAndInputStreamParam() throws IOException { org.apache.http.HttpResponse expectedResponse = mock(org.apache.http.HttpResponse.class, new ThrowsException(new UnsupportedOperationException())); doReturn("mock expectedResponse").when(expectedResponse).toString(); doReturn(null).when(expectedResponse).getEntity(); doReturn(new FakeStatusLine()).when(expectedResponse).getStatusLine(); doReturn(null).when(expectedResponse).getFirstHeader("ETag"); org.apache.http.client.HttpClient client = mock(org.apache.http.client.HttpClient.class, new ThrowsException(new UnsupportedOperationException())); org.apache.http.client.HttpClient backend = mock(org.apache.http.client.HttpClient.class, new ThrowsException(new UnsupportedOperationException())); doReturn(expectedResponse).when(backend).execute(any(HttpUriRequest.class)); AndroidHttpClient service = new AndroidHttpClient(client, backend); HttpResponse androidHttpResponse = service.post("", new ByteArrayInputStream(new byte[0])); assertNotNull(androidHttpResponse); }
@Test public void shouldInvokeBackendWhenPostWithStringParamAndHttpEntityParam() throws IOException { org.apache.http.HttpResponse expectedResponse = mock(org.apache.http.HttpResponse.class, new ThrowsException(new UnsupportedOperationException())); doReturn("mock expectedResponse").when(expectedResponse).toString(); doReturn(null).when(expectedResponse).getEntity(); doReturn(new FakeStatusLine()).when(expectedResponse).getStatusLine(); doReturn(null).when(expectedResponse).getFirstHeader("ETag"); org.apache.http.client.HttpClient client = mock(org.apache.http.client.HttpClient.class, new ThrowsException(new UnsupportedOperationException())); org.apache.http.client.HttpClient backend = mock(org.apache.http.client.HttpClient.class, new ThrowsException(new UnsupportedOperationException())); doReturn(expectedResponse).when(backend).execute(any(HttpUriRequest.class)); AndroidHttpClient service = new AndroidHttpClient(client, backend); HttpEntity httpEntity = mock(HttpEntity.class, new ThrowsException(new UnsupportedOperationException())); HttpResponse androidHttpResponse = service.post("", httpEntity); assertNotNull(androidHttpResponse); }