@Test
public void readToBufferWithArrayOffset() throws Exception {

  fakeService.setObject(DEFAULT_OBJECT.toBuilder().setSize(100).build());
  GoogleCloudStorageGrpcReadChannel readChannel = newReadChannel();
  byte[] array = new byte[200];
  // `slice` generates a ByteBuffer with a non-zero `arrayOffset`.
  ByteBuffer buffer = ByteBuffer.wrap(array, 50, 150).slice();
  readChannel.read(buffer);
  verify(fakeService, times(1)).getObject(eq(GET_OBJECT_REQUEST), any());
  verify(fakeService, times(1)).getObjectMedia(eq(GET_OBJECT_MEDIA_REQUEST), any());
  byte[] expected = ByteString.copyFrom(array, 50, 100).toByteArray();
  assertArrayEquals(fakeService.data.substring(0, 100).toByteArray(), expected);
}