use of com.google.api.services.storage.model.TestIamPermissionsResponse in project google-cloud-java by GoogleCloudPlatform.
the class StorageImplTest method testTestIamPermissionsNull.
@Test
public void testTestIamPermissionsNull() {
ImmutableList<Boolean> expectedPermissions = ImmutableList.of(false, false, false);
ImmutableList<String> checkedPermissions = ImmutableList.of("storage.buckets.get", "storage.buckets.getIamPolicy", "storage.objects.list");
EasyMock.expect(storageRpcMock.testIamPermissions(BUCKET_NAME1, checkedPermissions)).andReturn(new TestIamPermissionsResponse());
EasyMock.replay(storageRpcMock);
initializeService();
assertEquals(expectedPermissions, storage.testIamPermissions(BUCKET_NAME1, checkedPermissions));
}
use of com.google.api.services.storage.model.TestIamPermissionsResponse in project google-cloud-java by GoogleCloudPlatform.
the class StorageImpl method testIamPermissions.
@Override
public List<Boolean> testIamPermissions(final String bucket, final List<String> permissions) {
try {
TestIamPermissionsResponse response = runWithRetries(new Callable<TestIamPermissionsResponse>() {
@Override
public TestIamPermissionsResponse call() {
return storageRpc.testIamPermissions(bucket, permissions);
}
}, getOptions().getRetrySettings(), EXCEPTION_HANDLER, getOptions().getClock());
final Set<String> heldPermissions = response.getPermissions() != null ? ImmutableSet.copyOf(response.getPermissions()) : ImmutableSet.<String>of();
return Lists.transform(permissions, new Function<String, Boolean>() {
@Override
public Boolean apply(String permission) {
return heldPermissions.contains(permission);
}
});
} catch (RetryHelperException e) {
throw StorageException.translateAndThrow(e);
}
}
Aggregations