@Test
public void testRewriteObject() throws Exception {

  StorageObject object = new StorageObject().setName(OBJECT_NAME);
  Storage.Objects.Rewrite rewrite =
      newStorage()
          .objects()
          .rewrite(BUCKET_NAME, OBJECT_NAME, BUCKET_NAME_DST, OBJECT_NAME_DST, object);
  StorageRequestAuthorizer authorizer = new StorageRequestAuthorizer(mockHandler);
  authorizer.authorize(rewrite);
  ArgumentCaptor<URI> sourceCaptor = ArgumentCaptor.forClass(URI.class);
  ArgumentCaptor<URI> destinationCaptor = ArgumentCaptor.forClass(URI.class);
  verify(mockHandler).handleRewriteObject(sourceCaptor.capture(), destinationCaptor.capture());
  assertThat(sourceCaptor.getValue().getAuthority()).isEqualTo(BUCKET_NAME);
  assertThat(sourceCaptor.getValue().getPath()).isEqualTo(OBJECT_NAME);
  assertThat(destinationCaptor.getValue().getAuthority()).isEqualTo(BUCKET_NAME_DST);
  assertThat(destinationCaptor.getValue().getPath()).isEqualTo(OBJECT_NAME_DST);
}