@Test
  public void testInitStorageUsage() throws Exception {
    Map<String, Map<String, Long>> containerUsage = TestUtils.makeStorageMap(10, 10, 1000, 100);
    InMemAccountService accountService = new InMemAccountService(false, false);
    Map<QuotaResource, Long> expectedStorageUsages = new HashMap<>();
    // Account and container id's base is 1, not 0
    for (int i = 1; i <= 10; i++) {
      QuotaResourceType resourceType =
          i <= containerUsage.size() / 2 ? QuotaResourceType.CONTAINER : QuotaResourceType.ACCOUNT;
      AccountBuilder accountBuilder =
          new AccountBuilder((short) i, String.valueOf(i), Account.AccountStatus.ACTIVE, resourceType);
      for (int j = 1; j <= 10; j++) {
        accountBuilder.addOrUpdateContainer(
            new ContainerBuilder((short) j, String.valueOf(j), Container.ContainerStatus.ACTIVE, "",
                (short) i).build());
      }
      accountService.updateAccounts(Collections.singleton(accountBuilder.build()));
      if (resourceType == QuotaResourceType.ACCOUNT) {
        expectedStorageUsages.put(QuotaResource.fromAccountId((short) i),
            containerUsage.get(String.valueOf(i)).values().stream().mapToLong(Long::longValue).sum());
      } else {
        for (Map.Entry<String, Long> containerEntry : containerUsage.get(String.valueOf(i)).entrySet()) {
          expectedStorageUsages.put(QuotaResource.fromContainerId((short) i, Short.valueOf(containerEntry.getKey())),
              containerEntry.getValue());
        }
      }
    }

    StorageQuotaEnforcer enforcer =
        new StorageQuotaEnforcer(config, new JSONStringStorageQuotaSource(new HashMap<>(), accountService),
            (StorageUsageRefresher) null);
    enforcer.initStorageUsage(containerUsage);
    assertEquals(expectedStorageUsages, enforcer.getStorageUsages());
  }
Test to initialize the storage usage with non-empty map.
ambry-quota/src/test/java/com/github/ambry/quota/storage/StorageQuotaEnforcerTest.java