Search in sources :

Example 1 with AssessmentName

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

the class RecaptchaEnterpriseServiceClientTest method annotateAssessmentExceptionTest.

@Test
public void annotateAssessmentExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockRecaptchaEnterpriseService.addException(exception);
    try {
        AssessmentName name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]");
        AnnotateAssessmentRequest.Annotation annotation = AnnotateAssessmentRequest.Annotation.forNumber(0);
        client.annotateAssessment(name, annotation);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : AnnotateAssessmentRequest(com.google.recaptchaenterprise.v1.AnnotateAssessmentRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) AssessmentName(com.google.recaptchaenterprise.v1.AssessmentName) Test(org.junit.Test)

Example 2 with AssessmentName

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

the class RecaptchaEnterpriseServiceV1Beta1ClientTest method annotateAssessmentTest.

@Test
public void annotateAssessmentTest() throws Exception {
    AnnotateAssessmentResponse expectedResponse = AnnotateAssessmentResponse.newBuilder().build();
    mockRecaptchaEnterpriseServiceV1Beta1.addResponse(expectedResponse);
    AssessmentName name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]");
    AnnotateAssessmentRequest.Annotation annotation = AnnotateAssessmentRequest.Annotation.forNumber(0);
    AnnotateAssessmentResponse actualResponse = client.annotateAssessment(name, annotation);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseServiceV1Beta1.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    AnnotateAssessmentRequest actualRequest = ((AnnotateAssessmentRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(annotation, actualRequest.getAnnotation());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AnnotateAssessmentRequest(com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest) AbstractMessage(com.google.protobuf.AbstractMessage) AnnotateAssessmentResponse(com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse) AssessmentName(com.google.recaptchaenterprise.v1beta1.AssessmentName) Test(org.junit.Test)

Example 3 with AssessmentName

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

the class RecaptchaEnterpriseServiceClientTest method annotateAssessmentTest.

@Test
public void annotateAssessmentTest() throws Exception {
    AnnotateAssessmentResponse expectedResponse = AnnotateAssessmentResponse.newBuilder().build();
    mockRecaptchaEnterpriseService.addResponse(expectedResponse);
    AssessmentName name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]");
    AnnotateAssessmentRequest.Annotation annotation = AnnotateAssessmentRequest.Annotation.forNumber(0);
    AnnotateAssessmentResponse actualResponse = client.annotateAssessment(name, annotation);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    AnnotateAssessmentRequest actualRequest = ((AnnotateAssessmentRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(annotation, actualRequest.getAnnotation());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AnnotateAssessmentRequest(com.google.recaptchaenterprise.v1.AnnotateAssessmentRequest) AbstractMessage(com.google.protobuf.AbstractMessage) AnnotateAssessmentResponse(com.google.recaptchaenterprise.v1.AnnotateAssessmentResponse) AssessmentName(com.google.recaptchaenterprise.v1.AssessmentName) Test(org.junit.Test)

Example 4 with AssessmentName

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

the class RecaptchaEnterpriseServiceV1Beta1ClientTest method annotateAssessmentExceptionTest.

@Test
public void annotateAssessmentExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockRecaptchaEnterpriseServiceV1Beta1.addException(exception);
    try {
        AssessmentName name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]");
        AnnotateAssessmentRequest.Annotation annotation = AnnotateAssessmentRequest.Annotation.forNumber(0);
        client.annotateAssessment(name, annotation);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : AnnotateAssessmentRequest(com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) AssessmentName(com.google.recaptchaenterprise.v1beta1.AssessmentName) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 AnnotateAssessmentRequest (com.google.recaptchaenterprise.v1.AnnotateAssessmentRequest)2 AssessmentName (com.google.recaptchaenterprise.v1.AssessmentName)2 AnnotateAssessmentRequest (com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest)2 AssessmentName (com.google.recaptchaenterprise.v1beta1.AssessmentName)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 AnnotateAssessmentResponse (com.google.recaptchaenterprise.v1.AnnotateAssessmentResponse)1 AnnotateAssessmentResponse (com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentResponse)1