@Test
public void testComposeObject() throws Exception {

  // Test with three source objects
  List<ComposeRequest.SourceObjects> sourceObjects =
      Stream.of(0, 1, 2)
          .map(x -> new ComposeRequest.SourceObjects().setName(OBJECT_NAME + "-" + x))
          .collect(toImmutableList());
  ComposeRequest request = new ComposeRequest().setSourceObjects(sourceObjects);
  Storage.Objects.Compose compose =
      newStorage().objects().compose(BUCKET_NAME, OBJECT_NAME, request);
  StorageRequestAuthorizer authorizer = new StorageRequestAuthorizer(mockHandler);
  authorizer.authorize(compose);
  ArgumentCaptor<URI> captor = ArgumentCaptor.forClass(URI.class);
  ArgumentCaptor<List<URI>> listCaptor = ArgumentCaptor.forClass(ArrayList.class);
  verify(mockHandler).handleComposeObject(captor.capture(), listCaptor.capture());
  assertThat(captor.getValue().getAuthority()).isEqualTo(BUCKET_NAME);
  assertThat(captor.getValue().getPath()).isEqualTo(OBJECT_NAME);
  for (int i = 0; i < 3; ++i) {
    assertThat(listCaptor.getValue().get(i).getAuthority()).isEqualTo(BUCKET_NAME);
    assertThat(listCaptor.getValue().get(i).getPath()).isEqualTo(OBJECT_NAME + "-" + i);
  }
}