@Test
    public void testCompleteFutures() throws Exception {
        KafkaFutureImpl<Integer> future123 = new KafkaFutureImpl<>();
        assertTrue(future123.complete(123));
        assertFalse(future123.complete(456));
        assertFalse(future123.cancel(true));
        assertEquals(Integer.valueOf(123), future123.get());
        assertIsSuccessful(future123);

        KafkaFuture<Integer> future456 = KafkaFuture.completedFuture(456);
        assertFalse(future456.complete(789));
        assertFalse(future456.cancel(true));
        assertEquals(Integer.valueOf(456), future456.get());
        assertIsSuccessful(future456);
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java