@Test
public void testThenApply() throws Throwable {

    TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
    DeferredResult<Integer> original = new DeferredResult<>();
    DeferredResult<Integer> result = original
            .thenApply(i -> i + 1);
    result.whenComplete(ctx.getCompletionDeferred());
    runAfter(10, () -> original.complete(1));
    ctx.await();
    Assert.assertEquals(2, result.getNow(0).intValue());
}