public static TopicMetadata fromRecord(
        ConsumerGroupPartitionMetadataValue.TopicMetadata record
    ) {
        // Converting the data type from a list stored in the record to a map for the topic metadata.
        Map<Integer, Set<String>> partitionRacks = new HashMap<>();
        for (ConsumerGroupPartitionMetadataValue.PartitionMetadata partitionMetadata : record.partitionMetadata()) {
            partitionRacks.put(
                partitionMetadata.partition(),
                Collections.unmodifiableSet(new HashSet<>(partitionMetadata.racks()))
            );
        }

        return new TopicMetadata(
            record.topicId(),
            record.topicName(),
            record.numPartitions(),
            partitionRacks);
    }
@Test
    public void testFromRecord() {
        Uuid topicId = Uuid.randomUuid();
        String topicName = "foo";

        ConsumerGroupPartitionMetadataValue.TopicMetadata record = new ConsumerGroupPartitionMetadataValue.TopicMetadata()
            .setTopicId(topicId)
            .setTopicName(topicName)
            .setNumPartitions(15)
            .setPartitionMetadata(mkListOfPartitionRacks(15));

        assertEquals(
            new TopicMetadata(topicId, topicName, 15, mkMapOfPartitionRacks(15)),
            TopicMetadata.fromRecord(record)
        );
    }