use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaDaoTest method testQuotaClusterByQuotaGuidWithGeneralDefaultNoDefault.
/**
* Asserts that when {@link QuotaDao#getQuotaClusterByQuotaGuidWithGeneralDefault(Guid)} is called
* with a specific quota, all the relevant VDSs are returned
*/
@Test
public void testQuotaClusterByQuotaGuidWithGeneralDefaultNoDefault() {
List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByQuotaGuidWithGeneralDefault(FixturesTool.QUOTA_SPECIFIC);
assertNotNull(quotaClusterList);
assertEquals("wrong number of quotas returned", 2, quotaClusterList.size());
for (QuotaCluster group : quotaClusterList) {
assertNotNull("VDS ID should not be null in specific mode", group.getClusterId());
assertNotNull("VDS name should not be null in specific mode", group.getClusterName());
}
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaDaoTest method testUpdateQuota.
/**
* Make Quota specific to be the same as Quota general and specific.
*/
@Test
public void testUpdateQuota() throws Exception {
Quota quotaGeneralToSpecific = dao.getById(FixturesTool.QUOTA_GENERAL);
// Save quotaName and cluster list for future check.
String quotaName = "New Temporary name";
List<QuotaCluster> quotaClusterList = getQuotaCluster(getSpecificQuotaCluster(quotaGeneralToSpecific.getId()));
Long newStorageLimit = 2345L;
// Check before the update, that the fields are not equal.
assertFalse(quotaName.equals(quotaGeneralToSpecific.getQuotaName()));
assertNotEquals(quotaClusterList.size(), quotaGeneralToSpecific.getQuotaClusters().size());
assertFalse(quotaGeneralToSpecific.getGlobalQuotaStorage().getStorageSizeGB().equals(newStorageLimit));
// Update
quotaGeneralToSpecific.setQuotaName(quotaName);
quotaGeneralToSpecific.getGlobalQuotaStorage().setStorageSizeGB(newStorageLimit);
quotaGeneralToSpecific.setQuotaClusters(quotaClusterList);
dao.update(quotaGeneralToSpecific);
quotaGeneralToSpecific = dao.getById(FixturesTool.QUOTA_GENERAL);
// Check after the update, that the fields are equal now.
assertEquals(quotaName, quotaGeneralToSpecific.getQuotaName());
assertEquals(quotaClusterList.size(), quotaGeneralToSpecific.getQuotaClusters().size());
assertEquals(newStorageLimit, quotaGeneralToSpecific.getGlobalQuotaStorage().getStorageSizeGB());
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class UpdateQuotaCommandTest method setUpQuota.
private Quota setUpQuota(Guid guid) {
Quota quota = new Quota();
quota.setId(guid);
int numQutoaClusters = RandomUtils.instance().nextInt(10);
List<QuotaCluster> quotaClusters = new ArrayList<>(numQutoaClusters);
for (int i = 0; i < numQutoaClusters; ++i) {
quotaClusters.add(new QuotaCluster());
}
quota.setQuotaClusters(quotaClusters);
int numQutoaStorages = RandomUtils.instance().nextInt(10);
List<QuotaStorage> quotaStorages = new ArrayList<>(numQutoaStorages);
for (int i = 0; i < numQutoaClusters; ++i) {
quotaStorages.add(new QuotaStorage());
}
quota.setQuotaStorages(quotaStorages);
return quota;
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class GetQuotaClusterByQuotaIdQueryTest method testExecuteQueryCommand.
@Test
public void testExecuteQueryCommand() {
// Mock the parameters
Guid quotaId = Guid.newGuid();
when(params.getId()).thenReturn(quotaId);
// Create the return value
QuotaCluster group = new QuotaCluster();
group.setQuotaId(quotaId);
// Mock the Dao
when(quotaDao.getQuotaClusterByQuotaGuidWithGeneralDefault(quotaId)).thenReturn(Collections.singletonList(group));
// Execute the query
getQuery().executeQueryCommand();
// Assert the result
@SuppressWarnings("unchecked") List<QuotaCluster> results = getQuery().getQueryReturnValue().getReturnValue();
assertEquals("Wrong number of results returned", 1, results.size());
assertEquals("Wrong results returned", group, results.get(0));
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaCRUDCommand method setQuotaCluster.
private void setQuotaCluster(Quota quota) {
// Create unlimited global cluster quota if no other is specified
if (quota.isEmptyClusterQuota()) {
quota.setGlobalQuotaCluster(new QuotaCluster(Guid.newGuid(), quota.getId(), null, -1, 0, -1L, 0L));
return;
}
if (quota.isGlobalClusterQuota()) {
quota.getGlobalQuotaCluster().setQuotaId(quota.getId());
quota.getGlobalQuotaCluster().setQuotaClusterId(Guid.newGuid());
return;
}
for (QuotaCluster quotaCluster : quota.getQuotaClusters()) {
quotaCluster.setQuotaId(quota.getId());
quotaCluster.setQuotaClusterId(Guid.newGuid());
}
}
Aggregations