use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testCompositeFutureToList.
@Test
public void testCompositeFutureToList() {
Future<String> f1 = Future.future();
Future<Integer> f2 = Future.future();
CompositeFuture composite = CompositeFuture.all(f1, f2);
assertEquals(Arrays.asList(null, null), composite.list());
f1.complete("foo");
assertEquals(Arrays.asList("foo", null), composite.list());
f2.complete(4);
assertEquals(Arrays.asList("foo", 4), composite.list());
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testJoinFailed2.
private void testJoinFailed2(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();
Throwable cause = new Throwable();
f1.fail(cause);
checker.assertNotCompleted();
f2.complete(10);
assertSame(cause, checker.assertFailed());
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAllSucceeded.
private void testAllSucceeded(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);
checker.assertNotCompleted();
assertEquals(null, composite.<String>resultAt(0));
assertEquals(null, composite.<Integer>resultAt(1));
f1.complete("something");
checker.assertNotCompleted();
assertEquals("something", composite.resultAt(0));
assertEquals(null, composite.<Integer>resultAt(1));
f2.complete(3);
checker.assertSucceeded(composite);
assertEquals("something", composite.resultAt(0));
assertEquals(3, (int) composite.resultAt(1));
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testCompositeFail.
@Test
public void testCompositeFail() {
Throwable cause = new Throwable();
Future<Object> f1 = Future.future();
Future<Object> f2 = Future.future();
CompositeFuture composite = CompositeFuture.all(f1, f2);
Checker<CompositeFuture> checker = new Checker<>(composite);
composite.fail(cause);
checker.assertFailed(cause);
f1.complete();
f2.complete();
checker.assertFailed(cause);
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAnySucceeded2.
private void testAnySucceeded2(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);
f1.fail("failure");
checker.assertNotCompleted();
f2.complete(3);
checker.assertSucceeded(composite);
}
Aggregations