@Test
  public void testChargeAndGetSystemResource() throws Exception {
    Assert.assertEquals(0, ambryCUQuotaSource.getSystemResourceUsage(QuotaName.WRITE_CAPACITY_UNIT), 0.01);
    Assert.assertEquals(0, ambryCUQuotaSource.getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.01);

    ambryCUQuotaSource.chargeSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT, 819);
    Assert.assertEquals(79.98 * routerConfig.routerGetRequestParallelism,
        ambryCUQuotaSource.getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.01);
    Assert.assertEquals(0, ambryCUQuotaSource.getSystemResourceUsage(QuotaName.WRITE_CAPACITY_UNIT), 0.01);

    ambryCUQuotaSource.chargeSystemResourceUsage(QuotaName.WRITE_CAPACITY_UNIT, 819);
    Assert.assertEquals(79.98 * routerConfig.routerGetRequestParallelism,
        ambryCUQuotaSource.getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.01);
    Assert.assertEquals(79.98 * routerConfig.routerPutRequestParallelism,
        ambryCUQuotaSource.getSystemResourceUsage(QuotaName.WRITE_CAPACITY_UNIT), 0.01);

    ambryCUQuotaSource.chargeSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT, 1);
    Assert.assertEquals(80.07 * routerConfig.routerGetRequestParallelism,
        ambryCUQuotaSource.getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.1);
    Assert.assertEquals(79.98 * routerConfig.routerPutRequestParallelism,
        ambryCUQuotaSource.getSystemResourceUsage(QuotaName.WRITE_CAPACITY_UNIT), 0.01);

    ambryCUQuotaSource.chargeSystemResourceUsage(QuotaName.WRITE_CAPACITY_UNIT, 1);
    Assert.assertEquals(80.07 * routerConfig.routerGetRequestParallelism,
        ambryCUQuotaSource.getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.1);
    Assert.assertEquals(80.07 * routerConfig.routerPutRequestParallelism,
        ambryCUQuotaSource.getSystemResourceUsage(QuotaName.WRITE_CAPACITY_UNIT), 0.1);
  }
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