use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse in project gapic-generator-java by googleapis.
the class KeyManagementServiceClientTest method listCryptoKeysTest.
@Test
public void listCryptoKeysTest() throws Exception {
CryptoKey responsesElement = CryptoKey.newBuilder().build();
ListCryptoKeysResponse expectedResponse = ListCryptoKeysResponse.newBuilder().setNextPageToken("").addAllCryptoKeys(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
ListCryptoKeysPagedResponse pagedListResponse = client.listCryptoKeys(parent);
List<CryptoKey> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCryptoKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCryptoKeysRequest actualRequest = ((ListCryptoKeysRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse in project java-kms by googleapis.
the class KeyManagementServiceClientTest method listCryptoKeysTest.
@Test
public void listCryptoKeysTest() throws Exception {
CryptoKey responsesElement = CryptoKey.newBuilder().build();
ListCryptoKeysResponse expectedResponse = ListCryptoKeysResponse.newBuilder().setNextPageToken("").addAllCryptoKeys(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
ListCryptoKeysPagedResponse pagedListResponse = client.listCryptoKeys(parent);
List<CryptoKey> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCryptoKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCryptoKeysRequest actualRequest = ((ListCryptoKeysRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse in project java-kms by googleapis.
the class KeyManagementServiceClientTest method listCryptoKeysTest2.
@Test
public void listCryptoKeysTest2() throws Exception {
CryptoKey responsesElement = CryptoKey.newBuilder().build();
ListCryptoKeysResponse expectedResponse = ListCryptoKeysResponse.newBuilder().setNextPageToken("").addAllCryptoKeys(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListCryptoKeysPagedResponse pagedListResponse = client.listCryptoKeys(parent);
List<CryptoKey> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCryptoKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCryptoKeysRequest actualRequest = ((ListCryptoKeysRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListCryptoKeysPagedResponse in project gapic-generator-java by googleapis.
the class KeyManagementServiceClientTest method listCryptoKeysTest2.
@Test
public void listCryptoKeysTest2() throws Exception {
CryptoKey responsesElement = CryptoKey.newBuilder().build();
ListCryptoKeysResponse expectedResponse = ListCryptoKeysResponse.newBuilder().setNextPageToken("").addAllCryptoKeys(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListCryptoKeysPagedResponse pagedListResponse = client.listCryptoKeys(parent);
List<CryptoKey> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCryptoKeysList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCryptoKeysRequest actualRequest = ((ListCryptoKeysRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations