Search in sources :

Example 1 with BlobSourceOption

use of com.google.cloud.storage.Storage.BlobSourceOption in project google-cloud-java by GoogleCloudPlatform.

the class StorageBatchTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() {
    EasyMock.reset(batchMock);
    Capture<RpcBatch.Callback<Void>> callback = Capture.newInstance();
    Capture<Map<StorageRpc.Option, Object>> capturedOptions = Capture.newInstance();
    batchMock.addDelete(EasyMock.eq(BLOB_INFO.toPb()), EasyMock.capture(callback), EasyMock.capture(capturedOptions));
    EasyMock.replay(batchMock);
    StorageBatchResult<Boolean> batchResult = storageBatch.delete(BLOB_ID, BLOB_SOURCE_OPTIONS);
    assertNotNull(callback.getValue());
    assertEquals(2, capturedOptions.getValue().size());
    for (BlobSourceOption option : BLOB_SOURCE_OPTIONS) {
        assertEquals(option.getValue(), capturedOptions.getValue().get(option.getRpcOption()));
    }
    RpcBatch.Callback<Void> capturedCallback = callback.getValue();
    capturedCallback.onSuccess(null);
    assertTrue(batchResult.get());
}
Also used : StorageRpc(com.google.cloud.storage.spi.v1.StorageRpc) BlobSourceOption(com.google.cloud.storage.Storage.BlobSourceOption) RpcBatch(com.google.cloud.storage.spi.v1.RpcBatch) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

BlobSourceOption (com.google.cloud.storage.Storage.BlobSourceOption)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