private void assertIsCancelled(KafkaFuture<?> future) {
        assertTrue(future.isDone());
        assertTrue(future.isCancelled());
        assertTrue(future.isCompletedExceptionally());
        assertThrows(CancellationException.class, () -> future.getNow(null));
        assertThrows(CancellationException.class, () -> future.get(0, TimeUnit.MILLISECONDS));
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java