Search in sources :

Example 1 with ListEkmConnectionsPagedResponse

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()));
}
Also used : ListEkmConnectionsPagedResponse(com.google.cloud.kms.v1.EkmServiceClient.ListEkmConnectionsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with ListEkmConnectionsPagedResponse

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()));
}
Also used : ListEkmConnectionsPagedResponse(com.google.cloud.kms.v1.EkmServiceClient.ListEkmConnectionsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

ListEkmConnectionsPagedResponse (com.google.cloud.kms.v1.EkmServiceClient.ListEkmConnectionsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1