use of com.google.cloud.kms.v1.EkmServiceClient.ListEkmConnectionsPagedResponse in project java-kms by googleapis.
the class EkmServiceClientTest method listEkmConnectionsTest.
@Test
public void listEkmConnectionsTest() throws Exception {
EkmConnection responsesElement = EkmConnection.newBuilder().build();
ListEkmConnectionsResponse expectedResponse = ListEkmConnectionsResponse.newBuilder().setNextPageToken("").addAllEkmConnections(Arrays.asList(responsesElement)).build();
mockEkmService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListEkmConnectionsPagedResponse pagedListResponse = client.listEkmConnections(parent);
List<EkmConnection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEkmConnectionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEkmService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEkmConnectionsRequest actualRequest = ((ListEkmConnectionsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.kms.v1.EkmServiceClient.ListEkmConnectionsPagedResponse in project java-kms by googleapis.
the class EkmServiceClientTest method listEkmConnectionsTest2.
@Test
public void listEkmConnectionsTest2() throws Exception {
EkmConnection responsesElement = EkmConnection.newBuilder().build();
ListEkmConnectionsResponse expectedResponse = ListEkmConnectionsResponse.newBuilder().setNextPageToken("").addAllEkmConnections(Arrays.asList(responsesElement)).build();
mockEkmService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListEkmConnectionsPagedResponse pagedListResponse = client.listEkmConnections(parent);
List<EkmConnection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEkmConnectionsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEkmService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEkmConnectionsRequest actualRequest = ((ListEkmConnectionsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations