@Test
  public void testAggregateHostPartitionClassStorageStats() throws Exception {
    int nodeCount = 3;
    int numberOfPartitions = 4;
    Map<String, Map<Long, Map<Short, Map<Short, ContainerStorageStats>>>> storageStatsMap = new HashMap<>();
    String[] partitionClassNames = {"default", "newClass"};
    for (int i = 0; i < numberOfPartitions; i++) {
      String partitionClassName = partitionClassNames[i % partitionClassNames.length];
      storageStatsMap.computeIfAbsent(partitionClassName, k -> new HashMap<>())
          .put((long) i,
              StorageStatsUtilTest.generateRandomAggregatedAccountStorageStats((short) 0, i + 3, 3, 10000L, 2, 10));
    }
    StatsHeader header =
        new StatsHeader(StatsHeader.StatsDescription.STORED_DATA_SIZE, DEFAULT_TIMESTAMP, numberOfPartitions,
            numberOfPartitions, Collections.emptyList());
    HostPartitionClassStorageStatsWrapper nodeStats =
        new HostPartitionClassStorageStatsWrapper(header, new HostPartitionClassStorageStats(storageStatsMap));

    header = new StatsHeader(StatsHeader.StatsDescription.STORED_DATA_SIZE, DEFAULT_TIMESTAMP, 0, 0,
        Collections.emptyList());
    HostPartitionClassStorageStatsWrapper emptyStats =
        new HostPartitionClassStorageStatsWrapper(header, new HostPartitionClassStorageStats());

    Map<String, HostPartitionClassStorageStatsWrapper> instanceToStatsMap = new HashMap<>();

    for (int i = 0; i < nodeCount; i++) {
      instanceToStatsMap.put("Instance_" + i,
          new HostPartitionClassStorageStatsWrapper(new StatsHeader(nodeStats.getHeader()),
              new HostPartitionClassStorageStats(nodeStats.getStats())));
    }
    instanceToStatsMap.put("Instance_" + nodeCount, emptyStats);

    Map<String, Map<Short, Map<Short, ContainerStorageStats>>> expectedAggregatedStorageStatsMap =
        clusterAggregator.aggregateHostPartitionClassStorageStats(storageStatsMap);
    ClusterMapConfig clusterMapConfig = getClusterMapConfig();
    InmemoryAccountStatsStore accountStatsStore = new InmemoryAccountStatsStore(
        "unused_clustername", "unused_hostname", null, instanceToStatsMap);
    Pair<AggregatedPartitionClassStorageStats, AggregatedPartitionClassStorageStats> aggregatedRawAndValidStats =
        clusterAggregator.aggregateHostPartitionClassStorageStatsWrappers(new PartitionClassStorageStatsIterator(
            instanceToStatsMap.keySet().stream().collect(Collectors.toList()), accountStatsStore, clusterMapConfig));
    Assert.assertEquals(expectedAggregatedStorageStatsMap, aggregatedRawAndValidStats.getSecond().getStorageStats());
    assertAggregatedRawStatsForPartitionClassStorageStats(aggregatedRawAndValidStats.getFirst().getStorageStats(),
        expectedAggregatedStorageStatsMap, nodeCount);
  }
Test basic functionality of {@link MySqlClusterAggregator#aggregateHostPartitionClassStorageStats}.
@throws Exception
ambry-clustermap/src/test/java/com/github/ambry/clustermap/MySqlClusterAggregatorTest.java