use of com.google.recaptchaenterprise.v1.Assessment in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method createAssessmentExceptionTest2.
@Test
public void createAssessmentExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockRecaptchaEnterpriseService.addException(exception);
try {
String parent = "parent-995424086";
Assessment assessment = Assessment.newBuilder().build();
client.createAssessment(parent, assessment);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.recaptchaenterprise.v1.Assessment 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.v1.Assessment in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceV1Beta1ClientTest method createAssessmentTest2.
@Test
public void createAssessmentTest2() throws Exception {
Assessment expectedResponse = Assessment.newBuilder().setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString()).setEvent(Event.newBuilder().build()).setScore(109264530).setTokenProperties(TokenProperties.newBuilder().build()).addAllReasons(new ArrayList<Assessment.ClassificationReason>()).build();
mockRecaptchaEnterpriseServiceV1Beta1.addResponse(expectedResponse);
String parent = "parent-995424086";
Assessment assessment = Assessment.newBuilder().build();
Assessment actualResponse = client.createAssessment(parent, assessment);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseServiceV1Beta1.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateAssessmentRequest actualRequest = ((CreateAssessmentRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertEquals(assessment, actualRequest.getAssessment());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.recaptchaenterprise.v1.Assessment in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method createAssessmentExceptionTest.
@Test
public void createAssessmentExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockRecaptchaEnterpriseService.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
Assessment assessment = Assessment.newBuilder().build();
client.createAssessment(parent, assessment);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.recaptchaenterprise.v1.Assessment 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()));
}
Aggregations