use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAllLargeList.
private void testAllLargeList(int size) {
List<Future> list = new ArrayList<>();
for (int i = 0; i < size; i++) {
list.add(Future.succeededFuture());
}
CompositeFuture composite = CompositeFuture.all(list);
Checker<CompositeFuture> checker = new Checker<>(composite);
checker.assertSucceeded(composite);
for (int i = 0; i < size; i++) {
list.clear();
Throwable cause = new Exception();
for (int j = 0; j < size; j++) {
list.add(i == j ? Future.failedFuture(cause) : Future.succeededFuture());
}
composite = CompositeFuture.all(list);
checker = new Checker<>(composite);
checker.assertFailed(cause);
for (int j = 0; j < size; j++) {
if (i == j) {
assertTrue(composite.failed(j));
} else {
assertTrue(composite.succeeded(j));
}
}
}
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testCompositeComplete.
@Test
public void testCompositeComplete() {
CompositeFuture composite = CompositeFuture.all(Future.future(), Future.future());
Checker<CompositeFuture> checker = new Checker<>(composite);
composite.complete(composite);
checker.assertSucceeded(composite);
composite = CompositeFuture.all(Future.future(), Future.future());
checker = new Checker<>(composite);
composite.complete();
checker.assertSucceeded(composite);
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAllFailed.
private void testAllFailed(BiFunction<Future<String>, Future<Integer>, CompositeFuture> all) {
Future<String> f1 = Future.future();
Future<Integer> f2 = Future.future();
CompositeFuture composite = all.apply(f1, f2);
Checker<CompositeFuture> checker = new Checker<>(composite);
f1.complete("s");
Exception cause = new Exception();
f2.fail(cause);
checker.assertFailed(cause);
assertEquals("s", composite.resultAt(0));
assertEquals(null, composite.<Integer>resultAt(1));
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testJoinFailed1.
private void testJoinFailed1(BiFunction<Future<String>, Future<Integer>, CompositeFuture> join) {
Future<String> f1 = Future.future();
Future<Integer> f2 = Future.future();
CompositeFuture composite = join.apply(f1, f2);
Checker<CompositeFuture> checker = new Checker<>(composite);
checker.assertNotCompleted();
f1.complete("foo");
checker.assertNotCompleted();
Throwable cause = new Throwable();
f2.fail(cause);
assertSame(checker.assertFailed(), cause);
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAnySucceeded1.
private void testAnySucceeded1(BiFunction<Future<String>, Future<Integer>, CompositeFuture> any) {
Future<String> f1 = Future.future();
Future<Integer> f2 = Future.future();
CompositeFuture composite = any.apply(f1, f2);
Checker<CompositeFuture> checker = new Checker<>(composite);
checker.assertNotCompleted();
assertEquals(null, composite.<String>resultAt(0));
assertEquals(null, composite.<Integer>resultAt(1));
f1.complete("something");
checker.assertSucceeded(composite);
f2.complete(3);
checker.assertSucceeded(composite);
}
Aggregations