use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class AddQuotaCommandTest method mockGeneralStorageQuota.
private Quota mockGeneralStorageQuota() {
Quota generalQuota = new Quota();
generalQuota.setDescription("New Quota to create");
generalQuota.setQuotaName("New Quota Name");
QuotaStorage storageQuota = new QuotaStorage();
storageQuota.setStorageSizeGB(100L);
storageQuota.setStorageSizeGBUsage(0d);
generalQuota.setGlobalQuotaStorage(storageQuota);
QuotaCluster clusterQuota = new QuotaCluster();
clusterQuota.setVirtualCpu(0);
clusterQuota.setVirtualCpuUsage(0);
clusterQuota.setMemSizeMB(0L);
clusterQuota.setMemSizeMBUsage(0L);
generalQuota.setGlobalQuotaCluster(clusterQuota);
generalQuota.setId(Guid.newGuid());
generalQuota.setStoragePoolId(Guid.newGuid());
return generalQuota;
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class GetAllRelevantQuotasForClusterQueryTest method testExecuteQueryCommand.
@Test
public void testExecuteQueryCommand() {
// Set up the query parameters
Guid quotaID = Guid.newGuid();
when(params.getId()).thenReturn(quotaID);
// Set up the Daos
List<Quota> expected = Collections.singletonList(new Quota());
when(quotaDaoMock.getAllRelevantQuotasForCluster(quotaID, getQuery().getEngineSessionSeqId(), false)).thenReturn(expected);
// Run the query
GetAllRelevantQuotasForClusterQuery<IdQueryParameters> query = getQuery();
query.executeQueryCommand();
// Assert the result
assertEquals("Wrong result returned", expected, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class GetAllRelevantQuotasForStorageQueryTest method testExecuteQueryCommand.
@Test
public void testExecuteQueryCommand() {
// Set up the query parameters
Guid quotaID = Guid.newGuid();
when(params.getId()).thenReturn(quotaID);
// Set up the Daos
List<Quota> expected = Collections.singletonList(new Quota());
when(quotaDaoMock.getAllRelevantQuotasForStorage(quotaID, getQuery().getEngineSessionSeqId(), false)).thenReturn(expected);
// Run the query
GetAllRelevantQuotasForStorageQuery<IdQueryParameters> query = getQuery();
query.executeQueryCommand();
// Assert the result
assertEquals("Wrong result returned", expected, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class QuotaValidatorTest method setup.
@Before
public void setup() {
quota = new Quota();
quota.setId(QUOTA_ID);
quotaStorage = new QuotaStorage(Guid.newGuid(), QUOTA_ID, Guid.newGuid(), 100L, 0.0);
quotaCluster = new QuotaCluster(Guid.newGuid(), QUOTA_ID, Guid.newGuid(), 10, 0, 100L, 0L);
doReturn(quota).when(quotaDao).getById(QUOTA_ID);
}
use of org.ovirt.engine.core.common.businessentities.Quota in project ovirt-engine by oVirt.
the class BackendQuotaClusterLimitsResourceTest method testListNonGlobalLimit.
@Test
public void testListNonGlobalLimit() throws Exception {
Quota quota = getQuota();
List<QuotaCluster> clusterLimits = new LinkedList<>();
QuotaCluster clusterLimit1 = new QuotaCluster();
clusterLimit1.setVirtualCpu(CPU_NUMBER);
clusterLimit1.setClusterId(CLUSTER_ID_1);
QuotaCluster clusterLimit2 = new QuotaCluster();
clusterLimit2.setVirtualCpuUsage(VIRTUAL_CPU_USAGE);
clusterLimit2.setClusterId(CLUSTER_ID_2);
clusterLimits.add(clusterLimit1);
clusterLimits.add(clusterLimit2);
quota.setQuotaClusters(clusterLimits);
setUpGetEntityExpectations(quota);
QuotaClusterLimits list = collection.list();
assertClusterLimitsFound(list, 2);
for (QuotaClusterLimit clusterLimit : list.getQuotaClusterLimits()) {
if (clusterLimit.getCluster().getId().equals(CLUSTER_ID_1.toString())) {
assertEquals(CPU_NUMBER, clusterLimit.getVcpuLimit().longValue());
}
if (clusterLimit.getCluster().getId().equals(CLUSTER_ID_2.toString())) {
assertTrue(clusterLimit.getVcpuUsage() == VIRTUAL_CPU_USAGE);
}
}
}
Aggregations