GoogleCloudStorageReadChannel implements SeekableByteChannel { private void initMetadata(GoogleCloudStorageItemInfo info) throws IOException { initMetadata(info.getContentEncoding(), info.getSize(), info.getContentGeneration()); } GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper);  GoogleCloudStorageReadChannel(
      Storage gcs,
      String bucketName,
      String objectName,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions);  GoogleCloudStorageReadChannel(
      Storage gcs,
      StorageResourceId resourceId,
      ApiErrorExtractor errorExtractor,
      ClientRequestHelper<StorageObject> requestHelper,
      @Nonnull GoogleCloudStorageReadOptions readOptions); protected  GoogleCloudStorageReadChannel(
      String bucketName, String objectName, @Nonnull GoogleCloudStorageReadOptions readOptions); void setMaxRetries(int maxRetries); @Override int read(ByteBuffer buffer); @Override SeekableByteChannel truncate(long size); @Override int write(ByteBuffer src); @Override boolean isOpen(); @Override void close(); @Override long position(); @Override SeekableByteChannel position(long newPosition); @Override long size();  }
@Test public void initMetadata_throwsException_whenReadConsistencyEnabledAndGenerationIsNull() throws IOException { Storage storage = new Storage(HTTP_TRANSPORT, JSON_FACTORY, r -> {}); GoogleCloudStorageReadOptions options = newLazyReadOptionsBuilder().build(); GoogleCloudStorageReadChannel readChannel = createReadChannel(storage, options); IllegalStateException e = assertThrows( IllegalStateException.class, () -> readChannel.initMetadata("gzip", 1, UNKNOWN_GENERATION_ID)); assertThat(e).hasMessageThat().contains("Generation parameter of -1 is invalid"); }
@Test public void initMetadata_succeeds_whenReadConsistencyEnabledAndGenerationIsValid() throws IOException { Storage storage = new Storage(HTTP_TRANSPORT, JSON_FACTORY, r -> {}); GoogleCloudStorageReadOptions options = newLazyReadOptionsBuilder() .build(); GoogleCloudStorageReadChannel readChannel = createReadChannel(storage, options); readChannel.initMetadata("gzip", 1, 1234L); }