frankvicky commented on code in PR #16227: URL: https://github.com/apache/kafka/pull/16227#discussion_r1632040486
########## clients/src/test/java/org/apache/kafka/clients/consumer/ConsumerRecordsTest.java: ########## @@ -35,28 +35,83 @@ public class ConsumerRecordsTest { @Test public void iterator() throws Exception { + String topic = "topic"; + int recordSize = 10; + int partitionSize = 10; + int emptyPartitionInterval = 3; + ConsumerRecords<Integer, String> records = buildTopicTestRecords(recordSize, partitionSize, emptyPartitionInterval, topic); + Iterator<ConsumerRecord<Integer, String>> iterator = records.iterator(); + + for (int count = 0; iterator.hasNext(); count++) { + if (count % emptyPartitionInterval != 0) { + int offset = 0; + for (; offset < recordSize; offset++) { + ConsumerRecord<Integer, String> record = iterator.next(); + assertEquals(count, record.partition()); + assertEquals(topic, record.topic()); + assertEquals(offset, record.offset()); + } + assertEquals(recordSize, offset); + } + } + } + @Test + public void testRecordsWithNullTopic() { + String nullTopic = null; Map<TopicPartition, List<ConsumerRecord<Integer, String>>> records = new LinkedHashMap<>(); + ConsumerRecords<Integer, String> consumerRecords = new ConsumerRecords<>(records); Review Comment: Cool, I don't know we have this utility function, I will replace with it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org