@Test
    public void testToString() {
        KafkaFutureImpl<Integer> success = new KafkaFutureImpl<>();
        assertEquals("KafkaFuture{value=null,exception=null,done=false}", success.toString());
        success.complete(12);
        assertEquals("KafkaFuture{value=12,exception=null,done=true}", success.toString());

        KafkaFutureImpl<Integer> failure = new KafkaFutureImpl<>();
        failure.completeExceptionally(new RuntimeException("foo"));
        assertEquals("KafkaFuture{value=null,exception=java.lang.RuntimeException: foo,done=true}", failure.toString());

        KafkaFutureImpl<Integer> tricky1 = new KafkaFutureImpl<>();
        tricky1.completeExceptionally(new CompletionException(new CancellationException()));
        assertEquals("KafkaFuture{value=null,exception=java.util.concurrent.CompletionException: java.util.concurrent.CancellationException,done=true}", tricky1.toString());

        KafkaFutureImpl<Integer> cancelled = new KafkaFutureImpl<>();
        cancelled.cancel(true);
        assertEquals("KafkaFuture{value=null,exception=java.util.concurrent.CancellationException,done=true}", cancelled.toString());
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java