@Test
    public void testThenApplyOnFailedFutureFunctionNotCalled() {
        KafkaFutureImpl<Integer> future = new KafkaFutureImpl<>();
        boolean[] ran = {false};
        KafkaFuture<Integer> dependantFuture = future.thenApply(integer -> {
            // Because the top level future failed, this should never be called.
            ran[0] = true;
            return null;
        });
        future.completeExceptionally(new RuntimeException("We require more minerals"));
        assertIsFailed(future);
        assertIsFailed(dependantFuture);
        awaitAndAssertFailure(future, RuntimeException.class, "We require more minerals");
        awaitAndAssertFailure(dependantFuture, RuntimeException.class, "We require more minerals");
        assertFalse(ran[0]);
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java