use of com.google.cloud.dns.spi.v1.RpcBatch in project google-cloud-java by GoogleCloudPlatform.
the class StorageImplTest method testDeleteAllArray.
@Test
public void testDeleteAllArray() {
BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
Capture<RpcBatch.Callback<Void>> callback1 = Capture.newInstance();
Capture<RpcBatch.Callback<Void>> callback2 = Capture.newInstance();
batchMock.addDelete(EasyMock.eq(blobId1.toPb()), EasyMock.capture(callback1), EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
batchMock.addDelete(EasyMock.eq(blobId2.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<Boolean> result = storage.delete(blobId1, blobId2);
callback1.getValue().onSuccess(null);
callback2.getValue().onFailure(new GoogleJsonError());
assertEquals(2, result.size());
assertTrue(result.get(0));
assertFalse(result.get(1));
EasyMock.verify(batchMock);
}
use of com.google.cloud.dns.spi.v1.RpcBatch in project google-cloud-java by GoogleCloudPlatform.
the class StorageImplTest method testGetAllArray.
@Test
public void testGetAllArray() {
BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
batchMock.addGet(EasyMock.eq(blobId1.toPb()), EasyMock.capture(callback1), EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
batchMock.addGet(EasyMock.eq(blobId2.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.get(blobId1, blobId2);
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);
}
use of com.google.cloud.dns.spi.v1.RpcBatch in project google-cloud-java by GoogleCloudPlatform.
the class StorageImplTest method testGetAllArrayIterable.
@Test
public void testGetAllArrayIterable() {
BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
batchMock.addGet(EasyMock.eq(blobId1.toPb()), EasyMock.capture(callback1), EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
batchMock.addGet(EasyMock.eq(blobId2.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.get(ImmutableList.of(blobId1, blobId2));
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);
}
use of com.google.cloud.dns.spi.v1.RpcBatch in project google-cloud-java by GoogleCloudPlatform.
the class StorageImplTest method testDeleteAllIterable.
@Test
public void testDeleteAllIterable() {
BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
Capture<RpcBatch.Callback<Void>> callback1 = Capture.newInstance();
Capture<RpcBatch.Callback<Void>> callback2 = Capture.newInstance();
batchMock.addDelete(EasyMock.eq(blobId1.toPb()), EasyMock.capture(callback1), EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
batchMock.addDelete(EasyMock.eq(blobId2.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<Boolean> result = storage.delete(blobId1, blobId2);
callback1.getValue().onSuccess(null);
callback2.getValue().onFailure(new GoogleJsonError());
assertEquals(2, result.size());
assertTrue(result.get(0));
assertFalse(result.get(1));
EasyMock.verify(batchMock);
}
use of com.google.cloud.dns.spi.v1.RpcBatch in project google-cloud-java by GoogleCloudPlatform.
the class StorageImplTest method testUpdateAllArray.
@Test
public void testUpdateAllArray() {
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(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);
}
Aggregations