Skip to content

Commit 1f6e4da

Browse files
committed
---
yaml --- r: 6003 b: refs/heads/tswast-patch-1 c: 5ce009f h: refs/heads/master i: 6001: cc41b84 5999: 3694323
1 parent e87a818 commit 1f6e4da

2 files changed

Lines changed: 39 additions & 18 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 9eafeb436bccdf2142bb253b4f40b6f744d88c34
60+
refs/heads/tswast-patch-1: 5ce009facdac9595aad7be72394c3dd628f34c9e
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/src/test/java/com/google/gcloud/storage/BatchRequestTest.java

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,54 @@
1616

1717
package com.google.gcloud.storage;
1818

19-
import com.google.gcloud.storage.BatchRequest.Builder;
19+
import static com.google.gcloud.storage.StorageService.PredefinedAcl.PUBLIC_READ;
20+
import static junit.framework.TestCase.assertFalse;
21+
import static org.junit.Assert.assertEquals;
22+
import static org.junit.Assert.assertTrue;
23+
24+
import com.google.common.collect.Iterables;
2025
import com.google.gcloud.storage.StorageService.BlobSourceOption;
26+
import com.google.gcloud.storage.StorageService.BlobTargetOption;
2127

2228
import org.junit.Test;
2329

30+
import java.util.Iterator;
31+
import java.util.Map.Entry;
32+
2433
public class BatchRequestTest {
2534

2635
@Test
2736
public void testRequest() throws Exception {
28-
Builder builder = BatchRequest.builder();
29-
builder.delete("b1", "o1")
30-
BatchRequest.builder().delete("b1", "o1",
31-
BlobSourceOption.generationMatch(), BlobSourceOption.metagenerationMatch());
32-
}
37+
BatchRequest request = BatchRequest.builder()
38+
.delete("b1", "o1")
39+
.delete("b1", "o2", BlobSourceOption.generationMatch(1),
40+
BlobSourceOption.metagenerationMatch(2))
41+
.update(Blob.of("b2", "o1"), BlobTargetOption.predefinedAcl(PUBLIC_READ))
42+
.update(Blob.of("b2", "o2"))
43+
.get("b3", "o1")
44+
.get("b3", "o2", BlobSourceOption.generationMatch(1))
45+
.get("b3", "o3")
46+
.build();
3347

34-
@Test
35-
public void testToUpdate() throws Exception {
36-
37-
}
48+
Iterator<Entry<Blob, Iterable<BlobSourceOption>>> deletes = request
49+
.toDelete().entrySet().iterator();
50+
Entry<Blob, Iterable<BlobSourceOption>> delete = deletes.next();
51+
assertEquals(Blob.of("b1", "o1"), delete.getKey());
52+
assertTrue(Iterables.isEmpty(delete.getValue()));
53+
delete = deletes.next();
54+
assertEquals(Blob.of("b1", "o2"), delete.getKey());
55+
assertEquals(2, Iterables.size(delete.getValue()));
56+
assertFalse(deletes.hasNext());
3857

39-
@Test
40-
public void testToGet() throws Exception {
41-
42-
}
43-
44-
@Test
45-
public void testBuilder() throws Exception {
58+
Iterator<Entry<Blob, Iterable<BlobSourceOption>>> updates = request
59+
.toDelete().entrySet().iterator();
60+
Entry<Blob, Iterable<BlobSourceOption>> update = updates.next();
61+
assertEquals(Blob.of("b1", "o1"), update.getKey());
62+
assertTrue(Iterables.isEmpty(update.getValue()));
63+
update = updates.next();
64+
assertEquals(Blob.of("b1", "o2"), update.getKey());
65+
assertEquals(2, Iterables.size(update.getValue()));
66+
assertFalse(updates.hasNext());
4667

4768
}
4869
}

0 commit comments

Comments
 (0)