WrappedResponseInputStream extends InputStream { @Override public int read() throws IOException { return delegate.read(); } WrappedResponseInputStream(
            @NonNull InputStream delegate, @NonNull Response delegateResponse); @Override int read(); @Override int read(final byte b[]); @Override int read(final byte b[], final int off, final int len); @Override long skip(final long n); @Override synchronized void mark(int readlimit); @Override synchronized void reset(); @Override int available(); @Override boolean markSupported(); @Override void close();  }
@Test public void testReadNoParam_withDelegateInputStream_shouldReadFromDelegate() throws Exception { final WrappedResponseInputStream streamUnderTest = new WrappedResponseInputStream(mockDelegateStream, mockRawResponseDelegate); streamUnderTest.read(); verify(mockDelegateStream).read(); }
@Test public void testReadWithByteParam_withDelegateInputStream_shouldReadFromDelegate() throws Exception { final WrappedResponseInputStream streamUnderTest = new WrappedResponseInputStream(mockDelegateStream, mockRawResponseDelegate); streamUnderTest.read(new byte[2]); verify(mockDelegateStream).read(isA(byte[].class)); }
@Test public void testReadWithOffset_withDelegateInputStream_shouldReadFromDelegate() throws Exception { final WrappedResponseInputStream streamUnderTest = new WrappedResponseInputStream(mockDelegateStream, mockRawResponseDelegate); streamUnderTest.read(new byte[2], 1, 2); verify(mockDelegateStream).read(isA(byte[].class), eq(1), eq(2)); }
@Test public void testRead_withIOException_shouldThrowException() throws Exception { thrown.expect(IOException.class); final InputStream mockedDelegateInputStream = mock(InputStream.class); when(mockedDelegateInputStream.read()).thenThrow(new IOException("Exception")); final WrappedResponseInputStream streamUnderTest = new WrappedResponseInputStream(mockedDelegateInputStream, mockRawResponseDelegate); streamUnderTest.read(); }