Search in sources :

Example 1 with CreateSubmissionRequest

use of com.google.webrisk.v1.CreateSubmissionRequest in project java-webrisk by googleapis.

the class WebRiskServiceClientTest method createSubmissionTest.

@Test
public void createSubmissionTest() throws Exception {
    Submission expectedResponse = Submission.newBuilder().setUri("uri116076").build();
    mockWebRiskService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    Submission submission = Submission.newBuilder().build();
    Submission actualResponse = client.createSubmission(parent, submission);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockWebRiskService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSubmissionRequest actualRequest = ((CreateSubmissionRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(submission, actualRequest.getSubmission());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Submission(com.google.webrisk.v1.Submission) ProjectName(com.google.webrisk.v1.ProjectName) CreateSubmissionRequest(com.google.webrisk.v1.CreateSubmissionRequest) Test(org.junit.Test)

Example 2 with CreateSubmissionRequest

use of com.google.webrisk.v1.CreateSubmissionRequest in project java-webrisk by googleapis.

the class SubmitUriExample method submitUriExample.

// [START webrisk_submit_uri]
public static Submission submitUriExample(String uri) throws IOException {
    // create-webrisk-client
    try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
        Submission submission = Submission.newBuilder().setUri(uri).build();
        CreateSubmissionRequest submissionRequest = CreateSubmissionRequest.newBuilder().setParent("projects/your-project-id").setSubmission(submission).build();
        Submission submissionResponse = webRiskServiceClient.createSubmission(submissionRequest);
        webRiskServiceClient.shutdownNow();
        System.out.println("The submitted " + submissionResponse);
        return submissionResponse;
    }
}
Also used : Submission(com.google.webrisk.v1.Submission) WebRiskServiceClient(com.google.cloud.webrisk.v1.WebRiskServiceClient) CreateSubmissionRequest(com.google.webrisk.v1.CreateSubmissionRequest)

Example 3 with CreateSubmissionRequest

use of com.google.webrisk.v1.CreateSubmissionRequest in project java-webrisk by googleapis.

the class WebRiskServiceClientTest method createSubmissionTest2.

@Test
public void createSubmissionTest2() throws Exception {
    Submission expectedResponse = Submission.newBuilder().setUri("uri116076").build();
    mockWebRiskService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    Submission submission = Submission.newBuilder().build();
    Submission actualResponse = client.createSubmission(parent, submission);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockWebRiskService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSubmissionRequest actualRequest = ((CreateSubmissionRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(submission, actualRequest.getSubmission());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Submission(com.google.webrisk.v1.Submission) ByteString(com.google.protobuf.ByteString) CreateSubmissionRequest(com.google.webrisk.v1.CreateSubmissionRequest) Test(org.junit.Test)

Aggregations

CreateSubmissionRequest (com.google.webrisk.v1.CreateSubmissionRequest)3 Submission (com.google.webrisk.v1.Submission)3 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 WebRiskServiceClient (com.google.cloud.webrisk.v1.WebRiskServiceClient)1 ByteString (com.google.protobuf.ByteString)1 ProjectName (com.google.webrisk.v1.ProjectName)1