GcsUtil { LinkedList<RewriteOp> makeRewriteOps( Iterable<String> srcFilenames, Iterable<String> destFilenames) throws IOException { List<String> srcList = Lists.newArrayList(srcFilenames); List<String> destList = Lists.newArrayList(destFilenames); checkArgument( srcList.size() == destList.size(), "Number of source files %s must equal number of destination files %s", srcList.size(), destList.size()); LinkedList<RewriteOp> rewrites = Lists.newLinkedList(); for (int i = 0; i < srcList.size(); i++) { final GcsPath sourcePath = GcsPath.fromUri(srcList.get(i)); final GcsPath destPath = GcsPath.fromUri(destList.get(i)); rewrites.addLast(new RewriteOp(sourcePath, destPath)); } return rewrites; } private  GcsUtil(
      Storage storageClient,
      HttpRequestInitializer httpRequestInitializer,
      ExecutorService executorService,
      Boolean shouldUseGrpc,
      @Nullable Integer uploadBufferSizeBytes); static String getNonWildcardPrefix(String globExp); static boolean isWildcard(GcsPath spec); List<GcsPath> expand(GcsPath gcsPattern); long fileSize(GcsPath path); StorageObject getObject(GcsPath gcsPath); List<StorageObjectOrIOException> getObjects(List<GcsPath> gcsPaths); Objects listObjects(String bucket, String prefix, @Nullable String pageToken); Objects listObjects(
      String bucket, String prefix, @Nullable String pageToken, @Nullable String delimiter); SeekableByteChannel open(GcsPath path); WritableByteChannel create(GcsPath path, String type); WritableByteChannel create(GcsPath path, String type, Integer uploadBufferSizeBytes); boolean bucketAccessible(GcsPath path); long bucketOwner(GcsPath path); void createBucket(String projectId, Bucket bucket); void copy(Iterable<String> srcFilenames, Iterable<String> destFilenames); void remove(Collection<String> filenames);  }
@Test public void testMakeRewriteOps() throws IOException { GcsOptions gcsOptions = gcsOptionsWithTestCredential(); GcsUtil gcsUtil = gcsOptions.getGcsUtil(); LinkedList<RewriteOp> rewrites = gcsUtil.makeRewriteOps(makeStrings("s", 1), makeStrings("d", 1)); assertEquals(1, rewrites.size()); RewriteOp rewrite = rewrites.pop(); assertTrue(rewrite.getReadyToEnqueue()); Storage.Objects.Rewrite request = rewrite.rewriteRequest; assertNull(request.getMaxBytesRewrittenPerCall()); assertEquals("bucket", request.getSourceBucket()); assertEquals("s0", request.getSourceObject()); assertEquals("bucket", request.getDestinationBucket()); assertEquals("d0", request.getDestinationObject()); }
@Test public void testMakeRewriteOpsWithOptions() throws IOException { GcsOptions gcsOptions = gcsOptionsWithTestCredential(); GcsUtil gcsUtil = gcsOptions.getGcsUtil(); gcsUtil.maxBytesRewrittenPerCall = 1337L; LinkedList<RewriteOp> rewrites = gcsUtil.makeRewriteOps(makeStrings("s", 1), makeStrings("d", 1)); assertEquals(1, rewrites.size()); RewriteOp rewrite = rewrites.pop(); assertTrue(rewrite.getReadyToEnqueue()); Storage.Objects.Rewrite request = rewrite.rewriteRequest; assertEquals(Long.valueOf(1337L), request.getMaxBytesRewrittenPerCall()); }
@Test public void testMakeRewriteOpsInvalid() throws IOException { GcsUtil gcsUtil = gcsOptionsWithTestCredential().getGcsUtil(); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Number of source files 3"); gcsUtil.makeRewriteOps(makeStrings("s", 3), makeStrings("d", 1)); }