use of com.google.webrisk.v1.Submission in project java-webrisk by googleapis.
the class WebRiskServiceClientTest method createSubmissionExceptionTest.
@Test
public void createSubmissionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockWebRiskService.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
Submission submission = Submission.newBuilder().build();
client.createSubmission(parent, submission);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.webrisk.v1.Submission in project java-webrisk by googleapis.
the class SubmitUriExample method submitUriExample.
public static void submitUriExample() throws IOException {
// The URL to be submitted
String uri = "http://testsafebrowsing.appspot.com/s/malware.html";
Submission response = submitUriExample(uri);
}
use of com.google.webrisk.v1.Submission in project oracle-db-examples by oracle.
the class SessionTest method testOperationGroup.
@Test
public void testOperationGroup() throws Exception {
try (DataSource ds = getDataSource();
Session se = ds.getSession()) {
AtomicInteger opCounter = new AtomicInteger();
se.rowCountOperation("INSERT INTO " + OP_GROUP_TABLE + " VALUES (0)").apply(rc -> opCounter.incrementAndGet()).submit();
Submission<List<Boolean>> opgSubmission = null;
try (OperationGroup<Boolean, List<Boolean>> opg = se.operationGroup()) {
opgSubmission = opg.collect(Collectors.toList()).timeout(getTimeout()).submit();
opg.rowOperation("SELECT c FROM " + OP_GROUP_TABLE).collect(Collectors.reducing(Boolean.TRUE, row -> opCounter.compareAndSet(1, 2), (b1, b2) -> b1 && b2)).submit();
opg.localOperation().onExecution(() -> opCounter.compareAndSet(2, 3)).submit();
opg.rowCountOperation("UPDATE " + OP_GROUP_TABLE + " SET c = 1 WHERE c = 0").apply(rc -> opCounter.compareAndSet(3, 4)).submit();
}
assertNotNull(opgSubmission);
List<Boolean> opgResult = opgSubmission.getCompletionStage().toCompletableFuture().get();
assertNotNull(opgResult);
assertEquals(3, opgResult.size());
for (Boolean memberResult : opgResult) assertTrue(memberResult);
se.rollback().toCompletableFuture().get(getTimeout().toMillis(), TimeUnit.MILLISECONDS);
}
}
Aggregations