@Test
public void testChain() throws Exception {

    GridFutureAdapter<String> fut0 = new GridFutureAdapter<>();
    IgniteFutureImpl<String> fut = createFuture(fut0);
    IgniteFuture<Integer> chained = fut.chain(new C1<IgniteFuture<String>, Integer>() {
        @Override public Integer apply(IgniteFuture<String> fut) {
            return Integer.valueOf(fut.get());
        }
    });
    assertFalse(chained.isDone());
    U.sleep(100);
    final AtomicInteger lsnrCnt = new AtomicInteger();
    chained.listen(new CI1<IgniteFuture<Integer>>() {
        @Override public void apply(IgniteFuture<Integer> fut) {
            assertEquals(10, (int)fut.get());
            lsnrCnt.incrementAndGet();
        }
    });
    fut0.onDone("10");
    assertTrue(chained.isDone());
    assertEquals(10, (int)chained.get());
    assertEquals(1, lsnrCnt.get());
    assertTrue(fut.isDone());
    assertEquals("10", fut.get());
}