use of com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceV1Beta1ClientTest method annotateAssessmentTest2.
@Test
public void annotateAssessmentTest2() throws Exception {
AnnotateAssessmentResponse expectedResponse = AnnotateAssessmentResponse.newBuilder().build();
mockRecaptchaEnterpriseServiceV1Beta1.addResponse(expectedResponse);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertEquals(annotation, actualRequest.getAnnotation());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest 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.AnnotateAssessmentRequest 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.AnnotateAssessmentRequest in project java-recaptchaenterprise by googleapis.
the class AnnotateAssessment method annotateAssessment.
/**
* Pre-requisite: Create an assessment before annotating.
*
* <p>Annotate an assessment to provide feedback on the correctness of recaptcha prediction.
*
* @param projectID: GCloud Project id
* @param assessmentId: Value of the 'name' field returned from the CreateAssessment call.
*/
public static void annotateAssessment(String projectID, String assessmentId) throws IOException {
// clean up any remaining background resources.
try (RecaptchaEnterpriseServiceClient client = RecaptchaEnterpriseServiceClient.create()) {
// Build the annotation request.
// For more info on when/how to annotate, see:
// https://cloud.google.com/recaptcha-enterprise/docs/annotate-assessment#when_to_annotate
AnnotateAssessmentRequest annotateAssessmentRequest = AnnotateAssessmentRequest.newBuilder().setName(AssessmentName.of(projectID, assessmentId).toString()).setAnnotation(Annotation.FRAUDULENT).addReasons(Reason.FAILED_TWO_FACTOR).build();
// Empty response is sent back.
AnnotateAssessmentResponse response = client.annotateAssessment(annotateAssessmentRequest);
System.out.println("Annotated response sent successfully ! " + response);
}
}
use of com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method annotateAssessmentTest2.
@Test
public void annotateAssessmentTest2() throws Exception {
AnnotateAssessmentResponse expectedResponse = AnnotateAssessmentResponse.newBuilder().build();
mockRecaptchaEnterpriseService.addResponse(expectedResponse);
String name = "name3373707";
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, actualRequest.getName());
Assert.assertEquals(annotation, actualRequest.getAnnotation());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations