Code example for ByteArrayEntity

0
     */ 
    private HttpResponse createResponse(final String stringResponse) {
        final HttpResponse responseMock = Mockito.mock(HttpResponse.class);
        Mockito.when(responseMock.getHeaders("ETag")).thenReturn(new Header[]{new BasicHeader("ETag", "123")});
        Mockito.when(responseMock.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "All good"));        
        Mockito.when(responseMock.getEntity()).thenReturn(new ByteArrayEntity(stringResponse.getBytes()));
        return responseMock;
    } 
 
 
} 
Experience pair programming with AI  Get Codota for Java