@Test
    public void testThenApplyOnSucceededFutureAndFunctionThrows() {
        KafkaFutureImpl<Integer> future = new KafkaFutureImpl<>();
        KafkaFuture<Integer> dependantFuture = future.thenApply(integer -> {
            throw new RuntimeException("We require more vespene gas");
        });
        future.complete(21);
        assertIsSuccessful(future);
        assertIsFailed(dependantFuture);
        awaitAndAssertResult(future, 21, null);
        awaitAndAssertFailure(dependantFuture, RuntimeException.class, "We require more vespene gas");
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java