@Test
public void testReadEntity_streamWithContentType() {

    Response response = mock(Response.class);
    Response.StatusType statusInfo = mock(Response.StatusType.class);
    MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
    List<Object> contentType = ImmutableList.<Object>of("text");
    InputStream mockStream = mock(InputStream.class);
    Class<InputStream> entityType = InputStream.class;
    when(response.getStatusInfo()).thenReturn(statusInfo);
    when(statusInfo.getFamily()).thenReturn(Response.Status.Family.SUCCESSFUL);
    when(response.getHeaders()).thenReturn(headers);
    headers.add(HttpHeaders.CONTENT_TYPE, contentType);
    when(response.readEntity(entityType)).thenReturn(mockStream);
    InputStream inputStream = ResponseHelper.readEntity(response, entityType);
    assertThat(inputStream, instanceOf(WrappedResponseInputStream.class));
    verify(response).getStatusInfo();
    verify(statusInfo).getFamily();
    verify(response, atLeastOnce()).getHeaders();
    verify(response).readEntity(entityType);
    verify(response, never()).bufferEntity();
    verify(response).getStringHeaders();
    verifyNoMoreInteractions(response, statusInfo, mockStream);
    assertEquals(ImmutableList.of(contentType), headers.get(HttpHeaders.CONTENT_TYPE));
}