@Test
    public void testThenApplyOnFailedFutureTricky2() {
        KafkaFutureImpl<Integer> future = new KafkaFutureImpl<>();
        KafkaFuture<Integer> dependantFuture = future.thenApply(integer -> 2 * integer);
        future.completeExceptionally(new CompletionException(new CancellationException()));
        assertIsFailed(future);
        assertIsFailed(dependantFuture);
        awaitAndAssertFailure(future, CompletionException.class, "java.util.concurrent.CancellationException");
        awaitAndAssertFailure(dependantFuture, CompletionException.class, "java.util.concurrent.CancellationException");
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java