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.
}
}
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()));
}
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()));
}
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.
}
}
Aggregations