use of com.google.cloud.kms.v1.ListKeyRingsResponse in project gapic-generator-java by googleapis.
the class KeyManagementServiceClientTest method listKeyRingsTest2.
@Test
public void listKeyRingsTest2() throws Exception {
KeyRing responsesElement = KeyRing.newBuilder().build();
ListKeyRingsResponse expectedResponse = ListKeyRingsResponse.newBuilder().setNextPageToken("").addAllKeyRings(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListKeyRingsPagedResponse pagedListResponse = client.listKeyRings(parent);
List<KeyRing> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getKeyRingsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListKeyRingsRequest actualRequest = ((ListKeyRingsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.ListKeyRingsResponse in project gapic-generator-java by googleapis.
the class KeyManagementServiceClientTest method listKeyRingsTest.
@Test
public void listKeyRingsTest() throws Exception {
KeyRing responsesElement = KeyRing.newBuilder().build();
ListKeyRingsResponse expectedResponse = ListKeyRingsResponse.newBuilder().setNextPageToken("").addAllKeyRings(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListKeyRingsPagedResponse pagedListResponse = client.listKeyRings(parent);
List<KeyRing> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getKeyRingsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListKeyRingsRequest actualRequest = ((ListKeyRingsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.ListKeyRingsResponse in project gapic-generator-java by googleapis.
the class AsyncListKeyRingsPaged method asyncListKeyRingsPaged.
public static void asyncListKeyRingsPaged() throws Exception {
// It may require modifications to work in your environment.
try (KeyManagementServiceClient keyManagementServiceClient = KeyManagementServiceClient.create()) {
ListKeyRingsRequest request = ListKeyRingsRequest.newBuilder().setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").setFilter("filter-1274492040").setOrderBy("orderBy-1207110587").build();
while (true) {
ListKeyRingsResponse response = keyManagementServiceClient.listKeyRingsCallable().call(request);
for (KeyRing element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
}
use of com.google.cloud.kms.v1.ListKeyRingsResponse in project java-kms by googleapis.
the class KeyManagementServiceClientTest method listKeyRingsTest2.
@Test
public void listKeyRingsTest2() throws Exception {
KeyRing responsesElement = KeyRing.newBuilder().build();
ListKeyRingsResponse expectedResponse = ListKeyRingsResponse.newBuilder().setNextPageToken("").addAllKeyRings(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListKeyRingsPagedResponse pagedListResponse = client.listKeyRings(parent);
List<KeyRing> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getKeyRingsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListKeyRingsRequest actualRequest = ((ListKeyRingsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.ListKeyRingsResponse in project java-kms by googleapis.
the class KeyManagementServiceClientTest method listKeyRingsTest.
@Test
public void listKeyRingsTest() throws Exception {
KeyRing responsesElement = KeyRing.newBuilder().build();
ListKeyRingsResponse expectedResponse = ListKeyRingsResponse.newBuilder().setNextPageToken("").addAllKeyRings(Arrays.asList(responsesElement)).build();
mockKeyManagementService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListKeyRingsPagedResponse pagedListResponse = client.listKeyRings(parent);
List<KeyRing> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getKeyRingsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListKeyRingsRequest actualRequest = ((ListKeyRingsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations