diff --git a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java index d459ba73a0af..56c1f72dd84d 100644 --- a/src/test/java/com/google/gcloud/storage/BatchRequestTest.java +++ b/src/test/java/com/google/gcloud/storage/BatchRequestTest.java @@ -16,33 +16,54 @@ package com.google.gcloud.storage; -import com.google.gcloud.storage.BatchRequest.Builder; +import static com.google.gcloud.storage.StorageService.PredefinedAcl.PUBLIC_READ; +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.Iterables; import com.google.gcloud.storage.StorageService.BlobSourceOption; +import com.google.gcloud.storage.StorageService.BlobTargetOption; import org.junit.Test; +import java.util.Iterator; +import java.util.Map.Entry; + public class BatchRequestTest { @Test public void testRequest() throws Exception { - Builder builder = BatchRequest.builder(); - builder.delete("b1", "o1") - BatchRequest.builder().delete("b1", "o1", - BlobSourceOption.generationMatch(), BlobSourceOption.metagenerationMatch()); - } + BatchRequest request = BatchRequest.builder() + .delete("b1", "o1") + .delete("b1", "o2", BlobSourceOption.generationMatch(1), + BlobSourceOption.metagenerationMatch(2)) + .update(Blob.of("b2", "o1"), BlobTargetOption.predefinedAcl(PUBLIC_READ)) + .update(Blob.of("b2", "o2")) + .get("b3", "o1") + .get("b3", "o2", BlobSourceOption.generationMatch(1)) + .get("b3", "o3") + .build(); - @Test - public void testToUpdate() throws Exception { - - } + Iterator>> deletes = request + .toDelete().entrySet().iterator(); + Entry> delete = deletes.next(); + assertEquals(Blob.of("b1", "o1"), delete.getKey()); + assertTrue(Iterables.isEmpty(delete.getValue())); + delete = deletes.next(); + assertEquals(Blob.of("b1", "o2"), delete.getKey()); + assertEquals(2, Iterables.size(delete.getValue())); + assertFalse(deletes.hasNext()); - @Test - public void testToGet() throws Exception { - - } - - @Test - public void testBuilder() throws Exception { + Iterator>> updates = request + .toDelete().entrySet().iterator(); + Entry> update = updates.next(); + assertEquals(Blob.of("b1", "o1"), update.getKey()); + assertTrue(Iterables.isEmpty(update.getValue())); + update = updates.next(); + assertEquals(Blob.of("b1", "o2"), update.getKey()); + assertEquals(2, Iterables.size(update.getValue())); + assertFalse(updates.hasNext()); } }