@Test
    public void testThenApplyOnCancelledFuture() {
        KafkaFutureImpl<Integer> future = new KafkaFutureImpl<>();
        KafkaFuture<Integer> dependantFuture = future.thenApply(integer -> 2 * integer);
        future.cancel(true);
        assertIsCancelled(future);
        assertIsCancelled(dependantFuture);
        awaitAndAssertCancelled(future, null);
        awaitAndAssertCancelled(dependantFuture, null);
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java