use of com.google.cloud.storage.Storage.BlobGetOption in project google-cloud-java by GoogleCloudPlatform.
the class StorageBatchTest method testGetWithOptions.
@Test
public void testGetWithOptions() {
EasyMock.reset(storage, batchMock, optionsMock);
EasyMock.expect(storage.getOptions()).andReturn(optionsMock).times(2);
EasyMock.expect(optionsMock.getService()).andReturn(storage);
Capture<RpcBatch.Callback<StorageObject>> callback = Capture.newInstance();
Capture<Map<StorageRpc.Option, Object>> capturedOptions = Capture.newInstance();
batchMock.addGet(EasyMock.eq(BLOB_INFO.toPb()), EasyMock.capture(callback), EasyMock.capture(capturedOptions));
EasyMock.replay(storage, batchMock, optionsMock);
StorageBatchResult<Blob> batchResult = storageBatch.get(BLOB_ID, BLOB_GET_OPTIONS);
assertNotNull(callback.getValue());
assertEquals(2, capturedOptions.getValue().size());
for (BlobGetOption option : BLOB_GET_OPTIONS) {
assertEquals(option.getValue(), capturedOptions.getValue().get(option.getRpcOption()));
}
RpcBatch.Callback<StorageObject> capturedCallback = callback.getValue();
capturedCallback.onSuccess(BLOB_INFO.toPb());
assertEquals(new Blob(storage, new Blob.BuilderImpl(BLOB_INFO)), batchResult.get());
}
Aggregations