Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
aozarov committed May 15, 2015
1 parent 56ceb52 commit b941c08
Showing 1 changed file with 38 additions and 17 deletions.
55 changes: 38 additions & 17 deletions src/test/java/com/google/gcloud/storage/BatchRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Entry<Blob, Iterable<BlobSourceOption>>> deletes = request
.toDelete().entrySet().iterator();
Entry<Blob, Iterable<BlobSourceOption>> 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<Entry<Blob, Iterable<BlobSourceOption>>> updates = request
.toDelete().entrySet().iterator();
Entry<Blob, Iterable<BlobSourceOption>> 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());

}
}

0 comments on commit b941c08

Please sign in to comment.