use of com.google.storage.v2.StorageClient.ListHmacKeysPagedResponse in project java-storage by googleapis.
the class StorageClientTest method listHmacKeysTest.
@Test
public void listHmacKeysTest() throws Exception {
HmacKeyMetadata responsesElement = HmacKeyMetadata.newBuilder().build();
ListHmacKeysResponse expectedResponse = ListHmacKeysResponse.newBuilder().setNextPageToken("").addAllHmacKeys(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
ProjectName project = ProjectName.of("[PROJECT]");
ListHmacKeysPagedResponse pagedListResponse = client.listHmacKeys(project);
List<HmacKeyMetadata> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getHmacKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListHmacKeysRequest actualRequest = ((ListHmacKeysRequest) actualRequests.get(0));
Assert.assertEquals(project.toString(), actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.StorageClient.ListHmacKeysPagedResponse in project java-storage by googleapis.
the class StorageClientTest method listHmacKeysTest2.
@Test
public void listHmacKeysTest2() throws Exception {
HmacKeyMetadata responsesElement = HmacKeyMetadata.newBuilder().build();
ListHmacKeysResponse expectedResponse = ListHmacKeysResponse.newBuilder().setNextPageToken("").addAllHmacKeys(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
String project = "project-309310695";
ListHmacKeysPagedResponse pagedListResponse = client.listHmacKeys(project);
List<HmacKeyMetadata> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getHmacKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListHmacKeysRequest actualRequest = ((ListHmacKeysRequest) actualRequests.get(0));
Assert.assertEquals(project, actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.StorageClient.ListHmacKeysPagedResponse in project gapic-generator-java by googleapis.
the class StorageClientTest method listHmacKeysTest2.
@Test
public void listHmacKeysTest2() throws Exception {
HmacKeyMetadata responsesElement = HmacKeyMetadata.newBuilder().build();
ListHmacKeysResponse expectedResponse = ListHmacKeysResponse.newBuilder().setNextPageToken("").addAllHmacKeys(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
String project = "project-309310695";
ListHmacKeysPagedResponse pagedListResponse = client.listHmacKeys(project);
List<HmacKeyMetadata> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getHmacKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListHmacKeysRequest actualRequest = ((ListHmacKeysRequest) actualRequests.get(0));
Assert.assertEquals(project, actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.StorageClient.ListHmacKeysPagedResponse in project gapic-generator-java by googleapis.
the class StorageClientTest method listHmacKeysTest.
@Test
public void listHmacKeysTest() throws Exception {
HmacKeyMetadata responsesElement = HmacKeyMetadata.newBuilder().build();
ListHmacKeysResponse expectedResponse = ListHmacKeysResponse.newBuilder().setNextPageToken("").addAllHmacKeys(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
ProjectName project = ProjectName.of("[PROJECT]");
ListHmacKeysPagedResponse pagedListResponse = client.listHmacKeys(project);
List<HmacKeyMetadata> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getHmacKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListHmacKeysRequest actualRequest = ((ListHmacKeysRequest) actualRequests.get(0));
Assert.assertEquals(project.toString(), actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations