Search in sources :

Example 56 with Quota

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;
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster)

Example 57 with Quota

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());
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 58 with Quota

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());
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 59 with Quota

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);
}
Also used : QuotaStorage(org.ovirt.engine.core.common.businessentities.QuotaStorage) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) Before(org.junit.Before)

Example 60 with Quota

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);
        }
    }
}
Also used : QuotaClusterLimits(org.ovirt.engine.api.model.QuotaClusterLimits) Quota(org.ovirt.engine.core.common.businessentities.Quota) QuotaCluster(org.ovirt.engine.core.common.businessentities.QuotaCluster) QuotaClusterLimit(org.ovirt.engine.api.model.QuotaClusterLimit) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

Quota (org.ovirt.engine.core.common.businessentities.Quota)101 ArrayList (java.util.ArrayList)23 Guid (org.ovirt.engine.core.compat.Guid)22 Test (org.junit.Test)17 QuotaCluster (org.ovirt.engine.core.common.businessentities.QuotaCluster)17 QuotaStorage (org.ovirt.engine.core.common.businessentities.QuotaStorage)16 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)12 HashMap (java.util.HashMap)9 List (java.util.List)9 QueryType (org.ovirt.engine.core.common.queries.QueryType)9 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)8 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 QuotaCRUDParameters (org.ovirt.engine.core.common.action.QuotaCRUDParameters)6 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)6 Map (java.util.Map)5 RepoImage (org.ovirt.engine.core.common.businessentities.storage.RepoImage)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5