private long verifyContainerStorageStatsAndGetTotalValidSize(BlobStoreStats blobStoreStats, long referenceTimeInMs)
      throws StoreException {
    DeleteTombstoneStats.Builder builder = new DeleteTombstoneStats.Builder(state.time);
    Map<Short, Map<Short, ContainerStorageStats>> actualContainerStorageStatsMap =
        blobStoreStats.getContainerStorageStats(referenceTimeInMs);
    Map<Short, Map<Short, ContainerStorageStats>> expectedContainerStorageStatsMap =
        getContainerStorageStats(referenceTimeInMs, state.time.milliseconds(), builder);
    long totalValidSize = 0L;

    for (Map.Entry<Short, Map<Short, ContainerStorageStats>> expectedContainerStorageStatsEntry : expectedContainerStorageStatsMap.entrySet()) {
      short accountId = expectedContainerStorageStatsEntry.getKey();
      assertTrue("Expected accountId: " + accountId + " not found",
          actualContainerStorageStatsMap.containsKey(accountId));
      Map<Short, ContainerStorageStats> innerMap = expectedContainerStorageStatsEntry.getValue();
      for (Map.Entry<Short, ContainerStorageStats> innerEntry : innerMap.entrySet()) {
        short containerId = innerEntry.getKey();
        assertTrue("Expected containerId: " + containerId + " not found in accountId: " + accountId,
            actualContainerStorageStatsMap.get(accountId).containsKey(containerId));
        ContainerStorageStats expectedContainerStorageStats = innerEntry.getValue();
        ContainerStorageStats actualContainerStorageStats =
            actualContainerStorageStatsMap.get(accountId).get(containerId);
        assertEquals("Storage stats mismatch for accountId: " + accountId + " containerId: " + containerId,
            expectedContainerStorageStats, actualContainerStorageStats);
        totalValidSize += expectedContainerStorageStats.getLogicalStorageUsage();
      }
      if (innerMap.size() != actualContainerStorageStatsMap.get(accountId).size()) {
        // make sure all the new items have value 0
        for (Map.Entry<Short, ContainerStorageStats> actualContainerEntry : actualContainerStorageStatsMap.get(
            accountId).entrySet()) {
          if (!innerMap.containsKey(actualContainerEntry.getKey())) {
            assertEquals(
                "Expecting 0 value for account id " + accountId + " and container " + actualContainerEntry.getKey(), 0,
                actualContainerEntry.getValue().getLogicalStorageUsage());
          }
        }
      }
      actualContainerStorageStatsMap.remove(accountId);
    }
    for (Map.Entry<Short, Map<Short, ContainerStorageStats>> actualContainerValidSizeEntry : actualContainerStorageStatsMap.entrySet()) {
      if (actualContainerValidSizeEntry.getValue().size() != 0) {
        for (Map.Entry<Short, ContainerStorageStats> mapEntry : actualContainerValidSizeEntry.getValue().entrySet()) {
          assertEquals("Additional values found in actual container valid size map for service "
              + actualContainerValidSizeEntry.getKey(), 0, mapEntry.getValue().getLogicalStorageUsage());
        }
      }
    }
    // verify delete tombstone stats
    verifyDeleteTombstoneStats(blobStoreStats, builder.build());
    return totalValidSize;
  }
Verify the correctness of valid data size information per container returned by BlobStoreStats and return the
total valid data size of all containers.
@param blobStoreStats the {@link BlobStoreStats} to be verified
@param referenceTimeInMs the reference time in ms until which deletes and expiration are relevant
@return the total valid data size of all containers (from all serviceIds)
ambry-store/src/test/java/com/github/ambry/store/BlobStoreStatsTest.java