Search in sources :

Example 16 with Assessment

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

the class RecaptchaEnterpriseServiceClientTest method createAssessmentTest2.

@Test
public void createAssessmentTest2() throws Exception {
    Assessment expectedResponse = Assessment.newBuilder().setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString()).setEvent(Event.newBuilder().build()).setRiskAnalysis(RiskAnalysis.newBuilder().build()).setTokenProperties(TokenProperties.newBuilder().build()).setAccountDefenderAssessment(AccountDefenderAssessment.newBuilder().build()).build();
    mockRecaptchaEnterpriseService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    Assessment assessment = Assessment.newBuilder().build();
    Assessment actualResponse = client.createAssessment(parent, assessment);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseService.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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Assessment(com.google.recaptchaenterprise.v1.Assessment) AccountDefenderAssessment(com.google.recaptchaenterprise.v1.AccountDefenderAssessment) CreateAssessmentRequest(com.google.recaptchaenterprise.v1.CreateAssessmentRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 Assessment (com.google.recaptchaenterprise.v1beta1.Assessment)8 Assessment (com.google.recaptchaenterprise.v1.Assessment)6 CreateAssessmentRequest (com.google.recaptchaenterprise.v1beta1.CreateAssessmentRequest)6 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)5 AbstractMessage (com.google.protobuf.AbstractMessage)5 StatusRuntimeException (io.grpc.StatusRuntimeException)5 AccountDefenderAssessment (com.google.recaptchaenterprise.v1.AccountDefenderAssessment)4 CreateAssessmentRequest (com.google.recaptchaenterprise.v1.CreateAssessmentRequest)3 ProjectName (com.google.recaptchaenterprise.v1beta1.ProjectName)3 Test (org.junit.jupiter.api.Test)3 ByteString (com.google.protobuf.ByteString)2 Event (com.google.recaptchaenterprise.v1.Event)2 ProjectName (com.google.recaptchaenterprise.v1.ProjectName)2 AnnotateAssessmentRequest (com.google.recaptchaenterprise.v1beta1.AnnotateAssessmentRequest)2 AssessmentName (com.google.recaptchaenterprise.v1beta1.AssessmentName)2 ArrayList (java.util.ArrayList)2 RecaptchaEnterpriseServiceClient (com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient)1 RecaptchaEnterpriseServiceV1Beta1Client (com.google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client)1 ClassificationReason (com.google.recaptchaenterprise.v1.RiskAnalysis.ClassificationReason)1