@Test
  public void testQuotaRefresh() throws QuotaException, InterruptedException {
    // 1. Charge quota for an account.
    Account account = inMemAccountService.getAccountById((short) 102);
    Container container = new ArrayList<>(account.getAllContainers()).get(0);
    ambryCUQuotaSource.chargeUsage(QuotaResource.fromContainer(container), QuotaName.READ_CAPACITY_UNIT, 102400000);
    ambryCUQuotaSource.chargeUsage(QuotaResource.fromContainer(container), QuotaName.WRITE_CAPACITY_UNIT, 102400000);

    // 2. Verify that usage reflects the charge.
    Assert.assertEquals(10.0,
        ambryCUQuotaSource.getUsage(QuotaResource.fromContainer(container), QuotaName.READ_CAPACITY_UNIT), 0.01);
    Assert.assertEquals(10.0,
        ambryCUQuotaSource.getUsage(QuotaResource.fromContainer(container), QuotaName.WRITE_CAPACITY_UNIT), 0.01);

    // 3. Wait for (slightly longer than) aggregation window time period.
    Thread.sleep((quotaConfig.cuQuotaAggregationWindowInSecs + 1) * 1000);

    // 4. Verify that the usage is reset automatically.
    Assert.assertEquals(0.0,
        ambryCUQuotaSource.getUsage(QuotaResource.fromContainer(container), QuotaName.READ_CAPACITY_UNIT), 0.01);
    Assert.assertEquals(0.0,
        ambryCUQuotaSource.getUsage(QuotaResource.fromContainer(container), QuotaName.WRITE_CAPACITY_UNIT), 0.01);
    Assert.assertEquals(4, ambryCUQuotaSource.getAllQuotaUsage().size());
  }
Create test setup by creating the {@link AmbryCUQuotaSource} object and updating account service.
@throws IOException
@throws AccountServiceException
ambry-quota/src/test/java/com/github/ambry/quota/capacityunit/AmbryCUQuotaSourceTest.java