Search in sources :

Example 1 with ListKeysResponse

use of com.google.recaptchaenterprise.v1beta1.ListKeysResponse in project java-recaptchaenterprise by googleapis.

the class RecaptchaEnterpriseServiceClientTest method listKeysTest.

@Test
public void listKeysTest() throws Exception {
    Key responsesElement = Key.newBuilder().build();
    ListKeysResponse expectedResponse = ListKeysResponse.newBuilder().setNextPageToken("").addAllKeys(Arrays.asList(responsesElement)).build();
    mockRecaptchaEnterpriseService.addResponse(expectedResponse);
    ListKeysRequest request = ListKeysRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();
    ListKeysPagedResponse pagedListResponse = client.listKeys(request);
    List<Key> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getKeysList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListKeysRequest actualRequest = ((ListKeysRequest) actualRequests.get(0));
    Assert.assertEquals(request.getParent(), actualRequest.getParent());
    Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
    Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListKeysPagedResponse(com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient.ListKeysPagedResponse) ListKeysRequest(com.google.recaptchaenterprise.v1.ListKeysRequest) ListKeysResponse(com.google.recaptchaenterprise.v1.ListKeysResponse) Key(com.google.recaptchaenterprise.v1.Key) Test(org.junit.Test)

Example 2 with ListKeysResponse

use of com.google.recaptchaenterprise.v1beta1.ListKeysResponse in project java-recaptchaenterprise by googleapis.

the class RecaptchaEnterpriseServiceV1Beta1ClientTest method listKeysTest.

@Test
public void listKeysTest() throws Exception {
    Key responsesElement = Key.newBuilder().build();
    ListKeysResponse expectedResponse = ListKeysResponse.newBuilder().setNextPageToken("").addAllKeys(Arrays.asList(responsesElement)).build();
    mockRecaptchaEnterpriseServiceV1Beta1.addResponse(expectedResponse);
    ListKeysRequest request = ListKeysRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();
    ListKeysPagedResponse pagedListResponse = client.listKeys(request);
    List<Key> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getKeysList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseServiceV1Beta1.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListKeysRequest actualRequest = ((ListKeysRequest) actualRequests.get(0));
    Assert.assertEquals(request.getParent(), actualRequest.getParent());
    Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize());
    Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListKeysPagedResponse(com.google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.ListKeysPagedResponse) ListKeysRequest(com.google.recaptchaenterprise.v1beta1.ListKeysRequest) ListKeysResponse(com.google.recaptchaenterprise.v1beta1.ListKeysResponse) Key(com.google.recaptchaenterprise.v1beta1.Key) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ListKeysPagedResponse (com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient.ListKeysPagedResponse)1 ListKeysPagedResponse (com.google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client.ListKeysPagedResponse)1 Key (com.google.recaptchaenterprise.v1.Key)1 ListKeysRequest (com.google.recaptchaenterprise.v1.ListKeysRequest)1 ListKeysResponse (com.google.recaptchaenterprise.v1.ListKeysResponse)1 Key (com.google.recaptchaenterprise.v1beta1.Key)1 ListKeysRequest (com.google.recaptchaenterprise.v1beta1.ListKeysRequest)1 ListKeysResponse (com.google.recaptchaenterprise.v1beta1.ListKeysResponse)1