@Test
public void testAwaitCompletionStage() throws InterruptedException, ExecutionException {

    CompletableFuture<List<Object>> emitted = new CompletableFuture<>();
    EventSource<Integer> src = new EventSource<>();
    AwaitingEventStream<Try<Integer>> squares = src.mapToCompletionStage(x -> async(x*x)).await(executor);
    executor.execute(() -> {
        List<Object> res = aggregate(EventStreams.merge(
                squares.map(Try::get),
                EventStreams.valuesOf(squares.pendingProperty())));
        src.push(1);
        src.push(2);
        src.push(3);
        src.push(4);
        executor.execute(() -> executor.execute(() -> emitted.complete(res)));
    });
    assertEquals(Arrays.asList(false, true, 1, 4, 9, 16, false), emitted.get());
}