private void addExpectedPartitionAndInstanceToResource(TestPartitionLayout testPartitionLayout, int resourceId,
      Map<String, Map<String, Set<String>>> instancesUnderResourcesInDc,
      Map<String, Map<String, Set<Integer>>> partitionsUnderResourcesInDc) {
    for (Datacenter dc : testPartitionLayout.testHardwareLayout.getHardwareLayout().getDatacenters()) {
      String resourceName = String.valueOf(resourceId);
      Set<String> instances = testPartitionLayout.testHardwareLayout.getAllDataNodesFromDc(dc.getName())
          .stream()
          .map(dn -> ClusterMapUtils.getInstanceName(dn.getHostname(), dn.getPort()))
          .collect(Collectors.toSet());
      instancesUnderResourcesInDc.get(dc.getName())
          .computeIfAbsent(resourceName, k -> new HashSet<>())
          .addAll(instances);

      Set<Integer> partitions = testPartitionLayout.getPartitionLayout()
          .getAllPartitionNames()
          .stream()
          .map(Integer::parseInt)
          .collect(Collectors.toSet());
      partitionsUnderResourcesInDc.get(dc.getName())
          .computeIfAbsent(resourceName, k -> new HashSet<>())
          .addAll(partitions);
    }
  }
Verify that the number of resources in Helix is as expected.
@param hardwareLayout the {@link HardwareLayout} of the static clustermap.
@param expectedResourceCount the expected number of resources in Helix.
ambry-tools/src/integration-test/java/com/github/ambry/clustermap/HelixBootstrapUpgradeToolTest.java