public void test(I finalImage, List<ApiMessageAndVersion> fromRecords) {
            for (int numRecordsForfirstImage = 1; numRecordsForfirstImage <= fromRecords.size(); ++numRecordsForfirstImage) {
                // create first image from first numRecordsForfirstImage records
                D delta = createDeltaUponImage(getEmptyImage());
                RecordTestUtils.replayAll(delta, fromRecords.subList(0, numRecordsForfirstImage));
                I firstImage = createImageByApplyingDelta(delta);
                // for all possible further batch sizes, apply as many batches as it takes to get to the final image
                int remainingRecords = fromRecords.size() - numRecordsForfirstImage;
                if (remainingRecords == 0) {
                    assertEquals(finalImage, firstImage);
                } else {
                    // for all possible further batch sizes...
                    for (int maxRecordsForSuccessiveBatches = 1; maxRecordsForSuccessiveBatches <= remainingRecords; ++maxRecordsForSuccessiveBatches) {
                        I latestIntermediateImage = firstImage;
                        // ... apply as many batches as it takes to get to the final image
                        int numAdditionalBatches = (int) Math.ceil(remainingRecords * 1.0 / maxRecordsForSuccessiveBatches);
                        for (int additionalBatchNum = 0; additionalBatchNum < numAdditionalBatches; ++additionalBatchNum) {
                            // apply up to maxRecordsForSuccessiveBatches records on top of the latest intermediate image
                            // to obtain the next intermediate image.
                            delta = createDeltaUponImage(latestIntermediateImage);
                            int applyFromIndex = numRecordsForfirstImage + additionalBatchNum * maxRecordsForSuccessiveBatches;
                            int applyToIndex = Math.min(fromRecords.size(), applyFromIndex + maxRecordsForSuccessiveBatches);
                            RecordTestUtils.replayAll(delta, fromRecords.subList(applyFromIndex, applyToIndex));
                            latestIntermediateImage = createImageByApplyingDelta(delta);
                        }
                        // The final intermediate image received should be the expected final image
                        assertEquals(finalImage, latestIntermediateImage);
                    }
                }
            }
        }
Replay a list of records.

@param target                The object to invoke the replay function on.
@param recordsAndVersions    A list of records.
metadata/src/test/java/org/apache/kafka/metadata/RecordTestUtils.java