@Test
    public void testTopicPartitionGroupingSizeReduction() {
        Set<TopicPartition> tps = TestUtils.generateRandomTopicPartitions(10, 10);
        List<UpdateMetadataPartitionState> partitionStates = new ArrayList<>();
        for (TopicPartition tp : tps) {
            partitionStates.add(new UpdateMetadataPartitionState()
                .setTopicName(tp.topic())
                .setPartitionIndex(tp.partition()));
        }
        UpdateMetadataRequest.Builder builder = new UpdateMetadataRequest.Builder((short) 5, 0, 0, 0,
                partitionStates, Collections.emptyList(), Collections.emptyMap());

        assertTrue(builder.build((short) 5).sizeInBytes() <  builder.build((short) 4).sizeInBytes());
    }
Verifies the logic we have in UpdateMetadataRequest to present a unified interface across the various versions
works correctly. For example, `UpdateMetadataPartitionState.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/UpdateMetadataRequestTest.java