@Test
public void testHandle() throws Throwable {

    TestContext ctx = new TestContext(1, TestContext.DEFAULT_WAIT_DURATION);
    AtomicInteger invocations = new AtomicInteger();
    DeferredResult<Integer> original = new DeferredResult<>();
    DeferredResult<Integer> result = original
            .handle((x, ex) -> {
                Assert.assertNull(ex);
                invocations.incrementAndGet();
                return x + 1;
            });
    result.whenComplete(ctx.getCompletionDeferred());
    runAfter(10, () -> original.complete(1));
    ctx.await();
    Assert.assertEquals(1, invocations.get());
    Assert.assertEquals(2, result.getNow(exceptionSupplier()).intValue());
}