PerformanceCachingGoogleCloudStorage extends ForwardingGoogleCloudStorage { @Override public GoogleCloudStorageItemInfo composeObjects( List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options) throws IOException { GoogleCloudStorageItemInfo item = super.composeObjects(sources, destination, options); cache.putItem(item); return item; } PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate, PerformanceCachingGoogleCloudStorageOptions options); @VisibleForTesting  PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate,
      PrefixMappedItemCache cache); @Override WritableByteChannel create(StorageResourceId resourceId); @Override void deleteBuckets(List<String> bucketNames); @Override void deleteObjects(List<StorageResourceId> resourceIds); @Override List<GoogleCloudStorageItemInfo> listBucketInfo(); @Override List<String> listObjectNames(String bucketName, String objectNamePrefix); @Override List<String> listObjectNames(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions); @Override List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix); @Override List<GoogleCloudStorageItemInfo> listObjectInfo(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions); @Override ListPage<GoogleCloudStorageItemInfo> listObjectInfoPage(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions, String pageToken); @Override GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId); @Override List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds); @Override List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList); @Override void close(); @Override GoogleCloudStorageItemInfo composeObjects(
      List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options); @VisibleForTesting void invalidateCache();  }
@Test public void testComposeObjects() throws IOException { List<StorageResourceId> ids = Lists.newArrayList(ITEM_A_A.getResourceId(), ITEM_A_B.getResourceId()); GoogleCloudStorageItemInfo result = gcs.composeObjects(ids, ITEM_A_AA.getResourceId(), CREATE_OBJECT_OPTIONS); verify(gcsDelegate) .composeObjects(eq(ids), eq(ITEM_A_AA.getResourceId()), eq(CREATE_OBJECT_OPTIONS)); assertThat(result).isEqualTo(ITEM_A_AA); assertThat(cache.getAllItemsRaw()).containsExactly(ITEM_A_AA); }