Search in sources :

Example 1 with ListImportJobsPagedResponse

use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse in project gapic-generator-java by googleapis.

the class KeyManagementServiceClientTest method listImportJobsTest.

@Test
public void listImportJobsTest() throws Exception {
    ImportJob responsesElement = ImportJob.newBuilder().build();
    ListImportJobsResponse expectedResponse = ListImportJobsResponse.newBuilder().setNextPageToken("").addAllImportJobs(Arrays.asList(responsesElement)).build();
    mockKeyManagementService.addResponse(expectedResponse);
    KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
    ListImportJobsPagedResponse pagedListResponse = client.listImportJobs(parent);
    List<ImportJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getImportJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListImportJobsRequest actualRequest = ((ListImportJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListImportJobsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse) Test(org.junit.Test)

Example 2 with ListImportJobsPagedResponse

use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse in project gapic-generator-java by googleapis.

the class KeyManagementServiceClientTest method listImportJobsTest2.

@Test
public void listImportJobsTest2() throws Exception {
    ImportJob responsesElement = ImportJob.newBuilder().build();
    ListImportJobsResponse expectedResponse = ListImportJobsResponse.newBuilder().setNextPageToken("").addAllImportJobs(Arrays.asList(responsesElement)).build();
    mockKeyManagementService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListImportJobsPagedResponse pagedListResponse = client.listImportJobs(parent);
    List<ImportJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getImportJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListImportJobsRequest actualRequest = ((ListImportJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListImportJobsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with ListImportJobsPagedResponse

use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse in project java-kms by googleapis.

the class KeyManagementServiceClientTest method listImportJobsTest.

@Test
public void listImportJobsTest() throws Exception {
    ImportJob responsesElement = ImportJob.newBuilder().build();
    ListImportJobsResponse expectedResponse = ListImportJobsResponse.newBuilder().setNextPageToken("").addAllImportJobs(Arrays.asList(responsesElement)).build();
    mockKeyManagementService.addResponse(expectedResponse);
    KeyRingName parent = KeyRingName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]");
    ListImportJobsPagedResponse pagedListResponse = client.listImportJobs(parent);
    List<ImportJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getImportJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListImportJobsRequest actualRequest = ((ListImportJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListImportJobsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse) Test(org.junit.Test)

Example 4 with ListImportJobsPagedResponse

use of com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse in project java-kms by googleapis.

the class KeyManagementServiceClientTest method listImportJobsTest2.

@Test
public void listImportJobsTest2() throws Exception {
    ImportJob responsesElement = ImportJob.newBuilder().build();
    ListImportJobsResponse expectedResponse = ListImportJobsResponse.newBuilder().setNextPageToken("").addAllImportJobs(Arrays.asList(responsesElement)).build();
    mockKeyManagementService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListImportJobsPagedResponse pagedListResponse = client.listImportJobs(parent);
    List<ImportJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getImportJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKeyManagementService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListImportJobsRequest actualRequest = ((ListImportJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListImportJobsPagedResponse(com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

ListImportJobsPagedResponse (com.google.cloud.kms.v1.KeyManagementServiceClient.ListImportJobsPagedResponse)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ByteString (com.google.protobuf.ByteString)2