/** * Returns initialized entity with quota Storage result set. */ private RowMapper<QuotaStorage> getQuotaStorageResultSet() { return (rs, rowNum) -> { QuotaStorage entity = new QuotaStorage(); entity.setQuotaId(getGuidDefaultEmpty(rs, "quota_id")); entity.setQuotaStorageId(getGuidDefaultEmpty(rs, "quota_storage_id")); entity.setStorageId(getGuidDefaultEmpty(rs, "storage_id")); entity.setStorageName(rs.getString("storage_name")); entity.setStorageSizeGB((Long) rs.getObject("storage_size_gb")); entity.setStorageSizeGBUsage((Double) rs.getObject("storage_size_gb_usage")); return entity; }; }
private QuotaStorage getStorageGlobalCpuLimit() { QuotaStorage storageGlobalLimit = new QuotaStorage(); storageGlobalLimit.setQuotaId(GUIDS[0]); storageGlobalLimit.setStorageId(STORAGE_ID_1); storageGlobalLimit.setStorageSizeGB(STORAGE_SIZE_GB); return storageGlobalLimit; }
@Mapping(from = QuotaStorageLimit.class, to = org.ovirt.engine.core.common.businessentities.Quota.class) public static org.ovirt.engine.core.common.businessentities.Quota map(QuotaStorageLimit model, org.ovirt.engine.core.common.businessentities.Quota template) { org.ovirt.engine.core.common.businessentities.Quota entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.Quota(); QuotaStorage quotaStorage = new QuotaStorage(); if (model.isSetLimit()) { quotaStorage.setStorageSizeGB(model.getLimit()); } // specific SD if(model.isSetStorageDomain() && model.getStorageDomain().isSetId()) { quotaStorage.setStorageId(GuidUtils.asGuid(model.getStorageDomain().getId())); entity.getQuotaStorages().add(quotaStorage); } else { // global entity.setGlobalQuotaStorage(quotaStorage); } return entity; }
private static QuotaStorage getSpecificQuotaStorage(Guid quotaId) { QuotaStorage quotaStorage = new QuotaStorage(); quotaStorage.setQuotaId(quotaId); quotaStorage.setQuotaStorageId(Guid.newGuid()); quotaStorage.setStorageId(FixturesTool.STORAGE_DOMAIN_NFS_MASTER); quotaStorage.setStorageSizeGB(10000L); quotaStorage.setStorageSizeGBUsage(0d); return quotaStorage; }
quotaStorage.setStorageId(storage.getId()); quotaStorage.setStorageName(storage.getStorageName()); quotaStorage.setStorageSizeGB(null);
@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); } } }
quotaStorage.setStorageId(storage.getId()); quotaStorage.setStorageName(storage.getStorageName()); quotaStorage.setQuotaId(quota.getId());