private void testChargeAndRecommendForForcedCharge() throws Exception {
    RestRequest restRequest =
        QuotaTestUtils.createRestRequest(ACCOUNT, ACCOUNT.getAllContainers().iterator().next(), RestMethod.GET);
    AmbryQuotaManager ambryQuotaManager = buildAmbryQuotaManagerWithNoEnforcers();
    ambryQuotaManager.init();

    // 1. test that chargeAndRecommend returns ALLOW if there are no enforcers.
    QuotaAction quotaAction = ambryQuotaManager.chargeAndRecommend(restRequest, null, true, true);
    Assert.assertEquals(QuotaAction.ALLOW, quotaAction);

    // 2. test that enforcers are called and usage is charged.
    ambryQuotaManager = buildAmbryQuotaManagerWithAmbryCUEnforcer();
    testAmbryCUQuotaEnforcer.resetDefaults();
    ambryQuotaManager.init();
    Map<QuotaName, Double> costMap = Collections.singletonMap(QuotaName.READ_CAPACITY_UNIT, 11.0);
    quotaAction = ambryQuotaManager.chargeAndRecommend(restRequest, costMap, true, true);
    Assert.assertEquals(QuotaAction.ALLOW, quotaAction);
    Assert.assertEquals(1, testAmbryCUQuotaEnforcer.initCallCount);
    Assert.assertEquals(0, testAmbryCUQuotaEnforcer.recommendCallCount);
    Assert.assertEquals(1, testAmbryCUQuotaEnforcer.chargeCallCount);
    Assert.assertEquals(110, testAmbryCUQuotaEnforcer.getQuotaSource()
        .getUsage(QuotaResource.fromRestRequest(restRequest), QuotaName.READ_CAPACITY_UNIT), 0.0001);
    Assert.assertEquals(11 * routerConfig.routerGetRequestParallelism,
        testAmbryCUQuotaEnforcer.getQuotaSource().getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.0001);

    // 3. test that enforcers are called and usage is charged even if usage is outside quota limits.
    testAmbryCUQuotaEnforcer.resetDefaults();
    costMap = Collections.singletonMap(QuotaName.READ_CAPACITY_UNIT, 100.0);
    quotaAction = ambryQuotaManager.chargeAndRecommend(restRequest, costMap, true, true);
    Assert.assertEquals(QuotaAction.ALLOW, quotaAction);
    Assert.assertEquals(0, testAmbryCUQuotaEnforcer.initCallCount);
    Assert.assertEquals(0, testAmbryCUQuotaEnforcer.recommendCallCount);
    Assert.assertEquals(1, testAmbryCUQuotaEnforcer.chargeCallCount);
    Assert.assertEquals(1110, testAmbryCUQuotaEnforcer.getQuotaSource()
        .getUsage(QuotaResource.fromRestRequest(restRequest), QuotaName.READ_CAPACITY_UNIT), 0.0001);
    Assert.assertEquals(111 * routerConfig.routerGetRequestParallelism,
        testAmbryCUQuotaEnforcer.getQuotaSource().getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.0001);

    // 3. test that enforcers are called and usage is charged even if usage is outside quota limits and exceed is not allowed.
    testAmbryCUQuotaEnforcer.resetDefaults();
    costMap = Collections.singletonMap(QuotaName.READ_CAPACITY_UNIT, 100.0);
    quotaAction = ambryQuotaManager.chargeAndRecommend(restRequest, costMap, true, true);
    Assert.assertEquals(QuotaAction.ALLOW, quotaAction);
    Assert.assertEquals(0, testAmbryCUQuotaEnforcer.initCallCount);
    Assert.assertEquals(0, testAmbryCUQuotaEnforcer.recommendCallCount);
    Assert.assertEquals(1, testAmbryCUQuotaEnforcer.chargeCallCount);
    Assert.assertEquals(2110, testAmbryCUQuotaEnforcer.getQuotaSource()
        .getUsage(QuotaResource.fromRestRequest(restRequest), QuotaName.READ_CAPACITY_UNIT), 0.0001);
    Assert.assertEquals(211 * routerConfig.routerGetRequestParallelism,
        testAmbryCUQuotaEnforcer.getQuotaSource().getSystemResourceUsage(QuotaName.READ_CAPACITY_UNIT), 0.0001);
  }
Test {@link QuotaManager#chargeAndRecommend} when quota exceed check is set to true and force charge is set to true.
@throws Exception in case of any exception.
ambry-quota/src/test/java/com/github/ambry/quota/AmbryQuotaManagerTest.java