Search in sources :

Example 6 with RpcBatch

use of com.google.cloud.dns.spi.v1.RpcBatch in project google-cloud-java by GoogleCloudPlatform.

the class StorageImplTest method testUpdateAllIterable.

@Test
public void testUpdateAllIterable() {
    RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
    Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
    Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
    batchMock.addPatch(EasyMock.eq(BLOB_INFO1.toPb()), EasyMock.capture(callback1), EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
    batchMock.addPatch(EasyMock.eq(BLOB_INFO2.toPb()), EasyMock.capture(callback2), EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
    EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
    batchMock.submit();
    EasyMock.replay(storageRpcMock, batchMock);
    initializeService();
    List<Blob> resultBlobs = storage.update(ImmutableList.of(BLOB_INFO1, BLOB_INFO2));
    callback1.getValue().onSuccess(BLOB_INFO1.toPb());
    callback2.getValue().onFailure(new GoogleJsonError());
    assertEquals(2, resultBlobs.size());
    assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
    assertNull(resultBlobs.get(1));
    EasyMock.verify(batchMock);
}
Also used : BlobWriteOption(com.google.cloud.storage.Storage.BlobWriteOption) BucketSourceOption(com.google.cloud.storage.Storage.BucketSourceOption) BlobSourceOption(com.google.cloud.storage.Storage.BlobSourceOption) BlobTargetOption(com.google.cloud.storage.Storage.BlobTargetOption) StorageObject(com.google.api.services.storage.model.StorageObject) GoogleJsonError(com.google.api.client.googleapis.json.GoogleJsonError) RpcBatch(com.google.cloud.storage.spi.v1.RpcBatch) Test(org.junit.Test)

Example 7 with RpcBatch

use of com.google.cloud.dns.spi.v1.RpcBatch in project google-cloud-java by GoogleCloudPlatform.

the class StorageImplTest method testBatch.

@Test
public void testBatch() {
    RpcBatch batchMock = EasyMock.mock(RpcBatch.class);
    EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
    EasyMock.replay(batchMock, storageRpcMock);
    initializeService();
    StorageBatch batch = storage.batch();
    assertSame(options, batch.getOptions());
    assertSame(storageRpcMock, batch.getStorageRpc());
    assertSame(batchMock, batch.getBatch());
    EasyMock.verify(batchMock);
}
Also used : RpcBatch(com.google.cloud.storage.spi.v1.RpcBatch) Test(org.junit.Test)

Aggregations

RpcBatch (com.google.cloud.storage.spi.v1.RpcBatch)7 Test (org.junit.Test)7 GoogleJsonError (com.google.api.client.googleapis.json.GoogleJsonError)6 StorageObject (com.google.api.services.storage.model.StorageObject)6 BlobSourceOption (com.google.cloud.storage.Storage.BlobSourceOption)6 BlobTargetOption (com.google.cloud.storage.Storage.BlobTargetOption)6 BlobWriteOption (com.google.cloud.storage.Storage.BlobWriteOption)6 BucketSourceOption (com.google.cloud.storage.Storage.BucketSourceOption)6