use of com.google.storage.v2.Bucket in project gapic-generator-java by googleapis.
the class StorageClientTest method listBucketsTest.
@Test
public void listBucketsTest() throws Exception {
Bucket responsesElement = Bucket.newBuilder().build();
ListBucketsResponse expectedResponse = ListBucketsResponse.newBuilder().setNextPageToken("").addAllBuckets(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListBucketsPagedResponse pagedListResponse = client.listBuckets(parent);
List<Bucket> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getBucketsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBucketsRequest actualRequest = ((ListBucketsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.Bucket in project gapic-generator-java by googleapis.
the class SyncGetObject method syncGetObject.
public static void syncGetObject() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
GetObjectRequest request = GetObjectRequest.newBuilder().setBucket("bucket-1378203158").setObject("object-1023368385").setGeneration(305703192).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).setReadMask(FieldMask.newBuilder().build()).build();
Object response = storageClient.getObject(request);
}
}
use of com.google.storage.v2.Bucket in project gapic-generator-java by googleapis.
the class SyncGetObjectStringString method syncGetObjectStringString.
public static void syncGetObjectStringString() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
String bucket = "bucket-1378203158";
String object = "object-1023368385";
Object response = storageClient.getObject(bucket, object);
}
}
Aggregations