Search in sources :

Example 6 with CreateAssessmentRequest

use of com.google.recaptchaenterprise.v1beta1.CreateAssessmentRequest 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

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 Assessment (com.google.recaptchaenterprise.v1.Assessment)3 CreateAssessmentRequest (com.google.recaptchaenterprise.v1.CreateAssessmentRequest)3 Assessment (com.google.recaptchaenterprise.v1beta1.Assessment)3 CreateAssessmentRequest (com.google.recaptchaenterprise.v1beta1.CreateAssessmentRequest)3 AccountDefenderAssessment (com.google.recaptchaenterprise.v1.AccountDefenderAssessment)2 ProjectName (com.google.recaptchaenterprise.v1beta1.ProjectName)2 ArrayList (java.util.ArrayList)2 RecaptchaEnterpriseServiceClient (com.google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseServiceClient)1 RecaptchaEnterpriseServiceV1Beta1Client (com.google.cloud.recaptchaenterprise.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client)1 ByteString (com.google.protobuf.ByteString)1 Event (com.google.recaptchaenterprise.v1.Event)1 ProjectName (com.google.recaptchaenterprise.v1.ProjectName)1 ClassificationReason (com.google.recaptchaenterprise.v1.RiskAnalysis.ClassificationReason)1 Event (com.google.recaptchaenterprise.v1beta1.Event)1 List (java.util.List)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1