use of com.google.storage.v2.StorageClient.ListObjectsPagedResponse in project gapic-generator-java by googleapis.
the class StorageClientTest method listObjectsTest.
@Test
public void listObjectsTest() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.StorageClient.ListObjectsPagedResponse in project java-storage by googleapis.
the class StorageClientTest method listObjectsTest.
@Test
public void listObjectsTest() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.StorageClient.ListObjectsPagedResponse in project java-storage by googleapis.
the class StorageClientTest method listObjectsTest2.
@Test
public void listObjectsTest2() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
String parent = "parent-995424086";
ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.StorageClient.ListObjectsPagedResponse in project gapic-generator-java by googleapis.
the class StorageClientTest method listObjectsTest2.
@Test
public void listObjectsTest2() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
String parent = "parent-995424086";
ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations