@Test
  public void testChargeForNonExistentResource() throws Exception {
    Account account =
        createAccountForQuota(new JsonCUQuotaDataProviderUtil.MapOrQuota(new CapacityUnit(10, 10)), "106");
    Container container = createContainer("1");
    verifyFailsWithQuotaException(
        () -> ambryCUQuotaSource.getUsage(QuotaResource.fromAccount(account), QuotaName.READ_CAPACITY_UNIT),
        "Get usage for non existent resource");
    verifyFailsWithQuotaException(
        () -> ambryCUQuotaSource.getUsage(QuotaResource.fromAccount(account), QuotaName.WRITE_CAPACITY_UNIT),
        "Get usage for non existent resource");

    verifyFailsWithQuotaException(() -> {
      ambryCUQuotaSource.chargeUsage(QuotaResource.fromAccount(account), QuotaName.READ_CAPACITY_UNIT, 10.0);
      return null;
    }, "Charge usage for non existent resource");
    verifyFailsWithQuotaException(
        () -> ambryCUQuotaSource.getUsage(QuotaResource.fromAccount(account), QuotaName.READ_CAPACITY_UNIT),
        "Get usage for non existent resource");
    verifyFailsWithQuotaException(
        () -> ambryCUQuotaSource.getUsage(QuotaResource.fromAccount(account), QuotaName.WRITE_CAPACITY_UNIT),
        "Get usage for non existent resource");

    verifyFailsWithQuotaException(() -> {
      ambryCUQuotaSource.chargeUsage(QuotaResource.fromContainer(container), QuotaName.READ_CAPACITY_UNIT, 10.0);
      return null;
    }, "Charge usage for non existent resource");
    verifyFailsWithQuotaException(
        () -> ambryCUQuotaSource.getUsage(QuotaResource.fromContainer(container), QuotaName.READ_CAPACITY_UNIT),
        "Get usage for non existent resource");
    verifyFailsWithQuotaException(
        () -> ambryCUQuotaSource.getUsage(QuotaResource.fromContainer(container), QuotaName.WRITE_CAPACITY_UNIT),
        "Get usage for non existent resource");
  }
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