@Test
public void getItemInfoReturnsCorrectItemInfo() throws Exception {

  fakeService.setObject(
      FakeService.DEFAULT_OBJECT.toBuilder()
          .setSize(9)
          .setGeneration(1)
          .setMetageneration(2)
          .setTimeCreated(Timestamp.newBuilder().setSeconds(1560485630).setNanos(7000000))
          .setUpdated(Timestamp.newBuilder().setSeconds(1560495630).setNanos(123000000))
          .setContentEncoding("content-encoding")
          .putMetadata("metadata-key-1", "dGVzdC1tZXRhZGF0YQ==")
          .setMd5Hash("k0K1eqORVuY208nAADpz6w==")
          .setCrc32C(UInt32Value.newBuilder().setValue(uInt32Value(863614154)))
          .build());
  GoogleCloudStorageGrpcWriteChannel writeChannel = newWriteChannel();
  ByteString data = ByteString.copyFromUtf8("test data");
  writeChannel.initialize();
  writeChannel.write(data.asReadOnlyByteBuffer());
  writeChannel.close();
  GoogleCloudStorageItemInfo itemInfo = writeChannel.getItemInfo();
  byte[] expectedMd5Hash = {
    -109, 66, -75, 122, -93, -111, 86, -26, 54, -45, -55, -64, 0, 58, 115, -21
  };
  byte[] expectedCrc32C = {51, 121, -76, -54};
  Map<String, byte[]> expectedMetadata =
      ImmutableMap.of(
          "metadata-key-1",
          new byte[] {116, 101, 115, 116, 45, 109, 101, 116, 97, 100, 97, 116, 97});
  GoogleCloudStorageItemInfo expectedItemInfo =
      new GoogleCloudStorageItemInfo(
          new StorageResourceId(BUCKET_NAME, OBJECT_NAME),
          1560485630007L,
          1560495630123L,
          /* size= */ 9,
          /* location= */ null,
          /* storageClass= */ null,
          CONTENT_TYPE,
          "content-encoding",
          expectedMetadata,
          1,
          2,
          new VerificationAttributes(expectedMd5Hash, expectedCrc32C));
  assertThat(itemInfo).isEqualTo(expectedItemInfo);
}