@Override
  protected InputStream openObjectInputStream(
      long position, int bytesToRead) {
    GSObject object;
    try {
      object = mClient.getObject(mBucketName, mPath, null,
          null, null, null, position, position + bytesToRead - 1);
    } catch (ServiceException e) {
      String errorMessage = String
          .format("Failed to get object: %s bucket: %s", mPath, mBucketName);
      throw new RuntimeException(errorMessage, e);
    }
    try {
      return object.getDataInputStream();
    } catch (ServiceException e) {
      String errorMessage = String
          .format("Failed to open GCS InputStream");
      throw new RuntimeException(errorMessage, e);
    }
  }
@Test
  public void openObjectInputStream() throws Exception {
    GSObject object = Mockito.mock(GSObject.class);
    BufferedInputStream objectInputStream = Mockito.mock(BufferedInputStream.class);
    Mockito.when(mClient.getObject(Mockito.anyString(), Mockito.anyString(),
        Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
        Mockito.any(), Mockito.any())).thenReturn(object);
    Mockito.when(object.getDataInputStream()).thenReturn(objectInputStream);

    // test successful open object input stream
    long position = 0L;
    int bytesToRead = 10;
    InputStream inputStream = mPositionReader.openObjectInputStream(position, bytesToRead);
    Assert.assertTrue(inputStream instanceof BufferedInputStream);

    // test open object input stream with exception
    Mockito.when(mClient.getObject(ArgumentMatchers.anyString(), ArgumentMatchers.anyString()))
        .thenThrow(ServiceException.class);
    try {
      mPositionReader.openObjectInputStream(position, bytesToRead);
    } catch (Exception e) {
      Assert.assertTrue(e instanceof IOException);
      String errorMessage = String
          .format("Failed to get object: %s bucket: %s", mPath, mBucketName);
      Assert.assertEquals(errorMessage, e.getMessage());
    }
  }