Search in sources :

Example 1 with ListCertificateTemplatesPagedResponse

use of com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListCertificateTemplatesPagedResponse in project java-security-private-ca by googleapis.

the class CertificateAuthorityServiceClientTest method listCertificateTemplatesTest2.

@Test
public void listCertificateTemplatesTest2() throws Exception {
    CertificateTemplate responsesElement = CertificateTemplate.newBuilder().build();
    ListCertificateTemplatesResponse expectedResponse = ListCertificateTemplatesResponse.newBuilder().setNextPageToken("").addAllCertificateTemplates(Arrays.asList(responsesElement)).build();
    mockCertificateAuthorityService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListCertificateTemplatesPagedResponse pagedListResponse = client.listCertificateTemplates(parent);
    List<CertificateTemplate> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getCertificateTemplatesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCertificateAuthorityService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListCertificateTemplatesRequest actualRequest = ((ListCertificateTemplatesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCertificateTemplatesPagedResponse(com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListCertificateTemplatesPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 2 with ListCertificateTemplatesPagedResponse

use of com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListCertificateTemplatesPagedResponse in project java-security-private-ca by googleapis.

the class CertificateAuthorityServiceClientTest method listCertificateTemplatesTest.

@Test
public void listCertificateTemplatesTest() throws Exception {
    CertificateTemplate responsesElement = CertificateTemplate.newBuilder().build();
    ListCertificateTemplatesResponse expectedResponse = ListCertificateTemplatesResponse.newBuilder().setNextPageToken("").addAllCertificateTemplates(Arrays.asList(responsesElement)).build();
    mockCertificateAuthorityService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListCertificateTemplatesPagedResponse pagedListResponse = client.listCertificateTemplates(parent);
    List<CertificateTemplate> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getCertificateTemplatesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCertificateAuthorityService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListCertificateTemplatesRequest actualRequest = ((ListCertificateTemplatesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCertificateTemplatesPagedResponse(com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListCertificateTemplatesPagedResponse) Test(org.junit.Test)

Aggregations

ListCertificateTemplatesPagedResponse (com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient.ListCertificateTemplatesPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ByteString (com.google.protobuf.ByteString)1