Source:
<code>public static MetadataResponse metadataUpdateWith(final String clusterId, final int numNodes, final Map<String, Errors> topicErrors, final Map<String, Integer> topicPartitionCounts, final Function<TopicPartition, Integer> epochSupplier, final PartitionMetadataSupplier partitionSupplier) { final List<Node> nodes = new ArrayList<>(numNodes); for (int i = 0; i < numNodes; i++) nodes.add(new Node(i, "localhost", 1969 + i)); List<MetadataResponse.TopicMetadata> topicMetadata = new ArrayList<>(); for (Map.Entry<String, Integer> topicPartitionCountEntry : topicPartitionCounts.entrySet()) { String topic = topicPartitionCountEntry.getKey(); int numPartitions = topicPartitionCountEntry.getValue(); List<MetadataResponse.PartitionMetadata> partitionMetadata = new ArrayList<>(numPartitions); for (int i = 0; i < numPartitions; i++) { TopicPartition tp = new TopicPartition(topic, i); Node leader = nodes.get(i % nodes.size()); <START> List<Integer> replicas = Collections.singletonList(leader.id()); <END> partitionMetadata.add(partitionSupplier.supply( Errors.NONE, tp, leader.id(), Optional.ofNullable(epochSupplier.apply(tp)), replicas, replicas, replicas)); } topicMetadata.add(new MetadataResponse.TopicMetadata(Errors.NONE, topic, Topic.isInternal(topic), partitionMetadata)); } for (Map.Entry<String, Errors> topicErrorEntry : topicErrors.entrySet()) { String topic = topicErrorEntry.getKey(); topicMetadata.add(new MetadataResponse.TopicMetadata(topicErrorEntry.getValue(), topic, Topic.isInternal(topic), Collections.emptyList())); } return MetadataResponse.prepareResponse(nodes, clusterId, 0, topicMetadata); }</code><technical_language>Nit: call replicaIds maybe</technical_language>

Target:
public static MetadataResponse metadataUpdateWith(final String clusterId, final int numNodes, final Map<String, Errors> topicErrors, final Map<String, Integer> topicPartitionCounts, final Function<TopicPartition, Integer> epochSupplier, final PartitionMetadataSupplier partitionSupplier) { final List<Node> nodes = new ArrayList<>(numNodes); for (int i = 0; i < numNodes; i++) nodes.add(new Node(i, "localhost", 1969 + i)); List<MetadataResponse.TopicMetadata> topicMetadata = new ArrayList<>(); for (Map.Entry<String, Integer> topicPartitionCountEntry : topicPartitionCounts.entrySet()) { String topic = topicPartitionCountEntry.getKey(); int numPartitions = topicPartitionCountEntry.getValue(); List<MetadataResponse.PartitionMetadata> partitionMetadata = new ArrayList<>(numPartitions); for (int i = 0; i < numPartitions; i++) { TopicPartition tp = new TopicPartition(topic, i); Node leader = nodes.get(i % nodes.size()); List<Integer> replicaIds = Collections.singletonList(leader.id()); partitionMetadata.add(partitionSupplier.supply( Errors.NONE, tp, Optional.of(leader.id()), Optional.ofNullable(epochSupplier.apply(tp)), replicaIds, replicaIds, replicaIds)); } topicMetadata.add(new MetadataResponse.TopicMetadata(Errors.NONE, topic, Topic.isInternal(topic), partitionMetadata)); } for (Map.Entry<String, Errors> topicErrorEntry : topicErrors.entrySet()) { String topic = topicErrorEntry.getKey(); topicMetadata.add(new MetadataResponse.TopicMetadata(topicErrorEntry.getValue(), topic, Topic.isInternal(topic), Collections.emptyList())); } return MetadataResponse.prepareResponse(nodes, clusterId, 0, topicMetadata); }