use of com.github.ambry.quota.capacityunit.CapacityUnit in project ambry by linkedin.
the class JsonCUQuotaDataProviderUtilTest method testGetFeCUCapacityFromJson.
@Test
public void testGetFeCUCapacityFromJson() throws IOException {
CapacityUnit feCapacityUnit = JsonCUQuotaDataProviderUtil.getFeCUCapacityFromJson(DEFAULT_FRONTEND_CAPACITY_JSON);
Assert.assertEquals(1024, (long) feCapacityUnit.getRcu());
Assert.assertEquals(1024, (long) feCapacityUnit.getWcu());
}
use of com.github.ambry.quota.capacityunit.CapacityUnit in project ambry by linkedin.
the class JsonCUQuotaDataProviderUtilTest method testGetCUQuotasFromJson.
@Test
public void testGetCUQuotasFromJson() throws IOException, AccountServiceException {
InMemAccountService accountService = new InMemAccountService(false, false);
ObjectMapper objectMapper = new ObjectMapper();
Map<String, JsonCUQuotaDataProviderUtil.MapOrQuota> testQuotas = objectMapper.readValue(DEFAULT_CU_QUOTA_IN_JSON, new TypeReference<Map<String, JsonCUQuotaDataProviderUtil.MapOrQuota>>() {
});
for (String s : testQuotas.keySet()) {
accountService.updateAccounts(Collections.singletonList(createAccountForQuota(testQuotas.get(s), s)));
}
Map<String, CapacityUnit> quotas = JsonCUQuotaDataProviderUtil.getCUQuotasFromJson(DEFAULT_CU_QUOTA_IN_JSON, accountService);
Assert.assertEquals(4, quotas.size());
Assert.assertEquals(1024000000, (long) quotas.get("101_1").getRcu());
Assert.assertEquals(1024000000, (long) quotas.get("101_1").getWcu());
Assert.assertEquals(258438456, (long) quotas.get("101_2").getRcu());
Assert.assertEquals(258438456, (long) quotas.get("101_2").getWcu());
Assert.assertEquals(1024000000, (long) quotas.get("102_1").getRcu());
Assert.assertEquals(1024000000, (long) quotas.get("102_1").getWcu());
Assert.assertEquals(10737418240L, (long) quotas.get("103").getRcu());
Assert.assertEquals(10737418240L, (long) quotas.get("103").getWcu());
}
use of com.github.ambry.quota.capacityunit.CapacityUnit in project ambry by linkedin.
the class JsonCUQuotaDataProviderUtilTest method testGetFeCUCapacityFromJsonForEmptyJson.
@Test
public void testGetFeCUCapacityFromJsonForEmptyJson() throws IOException {
CapacityUnit feCapacityUnit = JsonCUQuotaDataProviderUtil.getFeCUCapacityFromJson(EMPTY_JSON);
Assert.assertEquals(0, (long) feCapacityUnit.getRcu());
Assert.assertEquals(0, (long) feCapacityUnit.getWcu());
}
use of com.github.ambry.quota.capacityunit.CapacityUnit in project ambry by linkedin.
the class JsonCUQuotaDataProviderUtilTest method testGetCUQuotasFromJsonForEmptyJsonString.
@Test
public void testGetCUQuotasFromJsonForEmptyJsonString() throws IOException, AccountServiceException {
InMemAccountService accountService = new InMemAccountService(false, false);
ObjectMapper objectMapper = new ObjectMapper();
Map<String, JsonCUQuotaDataProviderUtil.MapOrQuota> testQuotas = objectMapper.readValue(EMPTY_JSON, new TypeReference<Map<String, JsonCUQuotaDataProviderUtil.MapOrQuota>>() {
});
for (String s : testQuotas.keySet()) {
accountService.updateAccounts(Collections.singletonList(createAccountForQuota(testQuotas.get(s), s)));
}
Map<String, CapacityUnit> quotas = JsonCUQuotaDataProviderUtil.getCUQuotasFromJson(EMPTY_JSON, accountService);
Assert.assertEquals(0, quotas.size());
}
Aggregations