@Test
public void testThenCompose() throws InterruptedException {

    CompletionStage<Void> firstCompletionStage = Async.supplyAsync(latchSupplier(latch1), executorA);
    latch1.countDown();
    firstCompletionStage.toCompletableFuture().join();
    assertHits(executorA, 1);
    
    Function<Void, CompletableFuture<Void>> fn = x -> CompletableFuture.completedFuture(x);
    CompletionStage<Void> secondCompletionStage = firstCompletionStage.thenCompose(fn);
    secondCompletionStage.toCompletableFuture().join();
    assertHits(executorA, 1);
    
    Function<Void, CompletableFuture<Void>> fn2 = Unchecked.function(x -> {
        latch2.await();
        return CompletableFuture.completedFuture(x);
    });
    CompletionStage<Void> thirdCompletionStage = secondCompletionStage.thenComposeAsync(fn2);
    latch2.countDown();
    thirdCompletionStage.toCompletableFuture().join();
    assertHits(executorA, 2);
    
    Function<Void, CompletableFuture<Void>> fn3 = Unchecked.function(x -> {
        latch3.await();
        return CompletableFuture.completedFuture(x);
    });
    CompletionStage<Void> fourthCompletionStage = thirdCompletionStage.thenComposeAsync(fn3, executorB);
    latch3.countDown();
    fourthCompletionStage.toCompletableFuture().join();
    assertHits(executorA, 2);
    assertHits(executorB, 1);
}