@Test
    public void testCompleteExceptionallyWithRecordErrors() {
        int recordCount = 5;
        RuntimeException topLevelException = new RuntimeException();

        Map<Integer, RuntimeException> recordExceptionMap = new HashMap<>();
        recordExceptionMap.put(0, new RuntimeException());
        recordExceptionMap.put(3, new RuntimeException());

        Function<Integer, RuntimeException> recordExceptions = batchIndex ->
            recordExceptionMap.getOrDefault(batchIndex, topLevelException);

        testCompleteExceptionally(recordCount, topLevelException, recordExceptions);
    }
A {@link ProducerBatch} configured using a timestamp preceding its create time is interpreted correctly
* as not expired by {@link ProducerBatch#hasReachedDeliveryTimeout(long, long)}.
clients/src/test/java/org/apache/kafka/clients/producer/internals/ProducerBatchTest.java