Search in sources :

Example 1 with BlobGetOption

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());
}
Also used : StorageRpc(com.google.cloud.storage.spi.v1.StorageRpc) StorageObject(com.google.api.services.storage.model.StorageObject) BlobGetOption(com.google.cloud.storage.Storage.BlobGetOption) RpcBatch(com.google.cloud.storage.spi.v1.RpcBatch) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

StorageObject (com.google.api.services.storage.model.StorageObject)1 BlobGetOption (com.google.cloud.storage.Storage.BlobGetOption)1 RpcBatch (com.google.cloud.storage.spi.v1.RpcBatch)1 StorageRpc (com.google.cloud.storage.spi.v1.StorageRpc)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 Test (org.junit.Test)1