/** * Default constructor of Quota, which initialize empty lists for specific limitations, and no user assigned. */ public Quota() { setQuotaStorages(new ArrayList<QuotaStorage>()); setQuotaClusters(new ArrayList<QuotaCluster>()); id = Guid.Empty; description = ""; }
/** * Get full {@code Quota} entity. */ @Override public Quota getById(Guid quotaId) { MapSqlParameterSource parameterSource = createQuotaIdParameterMapper(quotaId); Quota quotaEntity = getCallsHandler().executeRead("GetQuotaByQuotaGuid", getQuotaFromResultSet(), parameterSource); if (quotaEntity != null) { quotaEntity.setQuotaClusters(getQuotaClusterByQuotaGuid(quotaId)); quotaEntity.setQuotaStorages(getQuotaStorageByQuotaGuid(quotaId)); } return quotaEntity; }
} else { if (quota.getQuotaStorages() == null) { quota.setQuotaStorages(new ArrayList<>());
@Test public void testListNonGlobalLimit() { Quota quota = getQuota(); List<QuotaStorage> storageLimits = new LinkedList<>(); QuotaStorage storageLimit1 = new QuotaStorage(); storageLimit1.setStorageSizeGB(STORAGE_SIZE_GB); storageLimit1.setStorageId(STORAGE_ID_1); QuotaStorage storageLimit2 = new QuotaStorage(); storageLimit2.setStorageSizeGBUsage(STORAGE_SIZE_GB_USAGE); storageLimit2.setStorageId(STORAGE_ID_2); storageLimits.add(storageLimit1); storageLimits.add(storageLimit2); quota.setQuotaStorages(storageLimits); setUpGetEntityExpectations(quota); QuotaStorageLimits list = collection.list(); assertStorageLimitsFound(list, 2); for (QuotaStorageLimit storageLimit : list.getQuotaStorageLimits()) { if (storageLimit.getStorageDomain().getId().equals(STORAGE_ID_1.toString())) { assertEquals(STORAGE_SIZE_GB, storageLimit.getLimit()); } if (storageLimit.getStorageDomain().getId().equals(STORAGE_ID_2.toString())) { assertEquals(STORAGE_SIZE_GB_USAGE, storageLimit.getUsage(), 0.0001); } } }
@Test public void testSpecificQuotaLimitations() { // Set new Quota definition. Quota quota = createGeneralQuota(); quota.setQuotaClusters(getQuotaCluster(getSpecificQuotaCluster(quota.getId()))); quota.setQuotaStorages(getQuotaStorage(getSpecificQuotaStorage(quota.getId()))); dao.save(quota); Quota quotaEntity = dao.getById(quota.getId()); assertNotNull(quotaEntity); assertEquals(quota, quotaEntity); }
@Test public void testSpecificAndGeneralQuotaLimitations() { // Set new Quota definition. Quota quota = createGeneralQuota(); quota.setQuotaClusters(getQuotaCluster(getSpecificQuotaCluster(quota.getId()))); quota.setQuotaStorages(getQuotaStorage(null)); quota.setGlobalQuotaStorage(new QuotaStorage(null, null, null, 10000L, 0d)); dao.save(quota); Quota quotaEntity = dao.getById(quota.getId()); assertNotNull(quotaEntity); assertEquals(quota, quotaEntity); }
quota.setQuotaStorages(quotaStorageList);
@Test public void testGeneralQuotaLimitations() { // Set new Quota definition. Quota quota = createGeneralQuota(); setQuotaGlobalLimitations(quota); quota.setQuotaClusters(getQuotaCluster(null)); quota.setQuotaStorages(getQuotaStorage(null)); dao.save(quota); Quota quotaEntity = dao.getById(quota.getId()); assertNotNull(quotaEntity); assertEquals(quota, quotaEntity); assertEquals("rhel6.NFS", quotaEntity.getStoragePoolName()); assertEquals(QuotaEnforcementTypeEnum.DISABLED, quotaEntity.getQuotaEnforcementType()); }