use of com.github.ambry.quota.capacityunit.AmbryCUQuotaSource in project ambry by linkedin.
the class AmbryQuotaManagerUpdateNotificationTest method ambryQuotaManagerUpdateNotificationTest.
@Test
public void ambryQuotaManagerUpdateNotificationTest() throws Exception {
VerifiableProperties verifiableProperties = new VerifiableProperties(new Properties());
MetricRegistry metricRegistry = new MetricRegistry();
QuotaConfig quotaConfig = new QuotaConfig(verifiableProperties);
QuotaRecommendationMergePolicy quotaRecommendationMergePolicy = new SimpleQuotaRecommendationMergePolicy(quotaConfig);
AccountServiceForConsumerTest accountService = new AccountServiceForConsumerTest(new AccountServiceConfig(verifiableProperties), new AccountServiceMetrics(metricRegistry), null);
AmbryQuotaManager ambryQuotaManager = new AmbryQuotaManager(quotaConfig, quotaRecommendationMergePolicy, accountService, null, new QuotaMetrics(metricRegistry));
AmbryCUQuotaSource quotaSource = (AmbryCUQuotaSource) getQuotaSourceMember(ambryQuotaManager);
assertTrue("updated accounts should be empty", quotaSource.getAllQuota().isEmpty());
Set<Short> accountIdSet = new HashSet<>();
accountIdSet.add((short) 1);
accountIdSet.add((short) 2);
Map<Short, Account> idToRefAccountMap = new HashMap<>();
AccountTestUtils.generateRefAccounts(idToRefAccountMap, new HashMap<>(), accountIdSet, 2, 3);
accountService.notifyAccountUpdateConsumers(idToRefAccountMap.values());
assertEquals("Invalid size of updated accounts", quotaSource.getAllQuota().size(), 2);
}
Aggregations