@Test
public void testThenCompose() throws Throwable {

    TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
    DeferredResult<String> result = DeferredResult.completed(12345)
            .thenCompose(ignore -> {
                DeferredResult<String> nested = new DeferredResult<>();
                runAfter(10, () -> nested.complete("foo"));
                return nested;
            });
    result.whenComplete(ctx.getCompletionDeferred());
    ctx.await();
    Assert.assertEquals("foo", result.getNow("bar"));
}