private void verifyLeaderReplicasInDc(HelixClusterManager helixClusterManager, String dcName) {
    // Following are maps of partitionId to the instance that holds its leader replica.
    Map<String, String> leaderReplicasInSnapshot = new HashMap<>();
    Map<String, String> leaderReplicasInCluster = helixCluster.getPartitionToLeaderReplica(dcName);
    for (PartitionId partitionId : helixClusterManager.getAllPartitionIds(null)) {
      List<? extends ReplicaId> leadReplicas = partitionId.getReplicaIdsByState(ReplicaState.LEADER, dcName);
      assertEquals("There should be exactly one lead replica for partition: " + partitionId.toPathString(), 1,
          leadReplicas.size());
      DataNodeId dataNodeId = leadReplicas.get(0).getDataNodeId();
      leaderReplicasInSnapshot.put(partitionId.toPathString(),
          getInstanceName(dataNodeId.getHostname(), dataNodeId.getPort()));
    }
    assertEquals("Mismatch in leader replicas", leaderReplicasInCluster, leaderReplicasInSnapshot);
  }
Helper method to verify leader replicas in cluster match those in routing table snapshot.
@param helixClusterManager the {@link HelixClusterManager} from which routing table snapshot is retrieved to check.
@param dcName name of the data center in which this verification is performed.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/HelixClusterManagerTest.java