@Test
    public void testTopicPartitionGroupingSizeReduction() {
        Set<TopicPartition> tps = TestUtils.generateRandomTopicPartitions(10, 10);
        List<LeaderAndIsrPartitionState> partitionStates = new ArrayList<>();
        Map<String, Uuid> topicIds = new HashMap<>();
        for (TopicPartition tp : tps) {
            partitionStates.add(new LeaderAndIsrPartitionState()
                .setTopicName(tp.topic())
                .setPartitionIndex(tp.partition()));
            topicIds.put(tp.topic(), Uuid.randomUuid());
        }
        LeaderAndIsrRequest.Builder builder = new LeaderAndIsrRequest.Builder((short) 2, 0, 0, 0,
            partitionStates, topicIds, Collections.emptySet());

        LeaderAndIsrRequest v2 = builder.build((short) 2);
        LeaderAndIsrRequest v1 = builder.build((short) 1);
        assertTrue(v2.sizeInBytes() < v1.sizeInBytes(), "Expected v2 < v1: v2=" + v2.sizeInBytes() + ", v1=" + v1.sizeInBytes());
    }
Verifies the logic we have in LeaderAndIsrRequest to present a unified interface across the various versions
works correctly. For example, `LeaderAndIsrPartitionState.topicName` is not serialized/deserialized in
recent versions, but we set it manually so that we can always present the ungrouped partition states
independently of the version.
clients/src/test/java/org/apache/kafka/common/requests/LeaderAndIsrRequestTest.java