private <T> void awaitAndAssertResult(KafkaFuture<T> future,
                                          T expectedResult,
                                          T alternativeValue) {
        assertNotEquals(expectedResult, alternativeValue);
        try {
            assertEquals(expectedResult, future.get(5, TimeUnit.MINUTES));
        } catch (Exception e) {
            throw new AssertionError("Unexpected exception", e);
        }
        try {
            assertEquals(expectedResult, future.get());
        } catch (Exception e) {
            throw new AssertionError("Unexpected exception", e);
        }
        try {
            assertEquals(expectedResult, future.getNow(alternativeValue));
        } catch (Exception e) {
            throw new AssertionError("Unexpected exception", e);
        }
    }
Asserts that the given future is done, didn't fail and was cancelled.
clients/src/test/java/org/apache/kafka/common/KafkaFutureTest.java