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()));
}
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;
}
}
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()));
}
Aggregations