Search in sources :

Example 36 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class GetClustersByStoragePoolIdQueryTest method testExecuteQueryCommand.

/**
 * Tests the flow of {@link GetClustersByStoragePoolIdQuery#executeQueryCommand()} using mock objects
 */
@Test
public void testExecuteQueryCommand() {
    // Set up the result
    Guid storagePoolId = Guid.newGuid();
    Cluster group = new Cluster();
    group.setStoragePoolId(storagePoolId);
    List<Cluster> result = Collections.singletonList(group);
    // Set up the query parameters
    when(getQueryParameters().getId()).thenReturn(storagePoolId);
    // Mock the Dao
    when(clusterDaoMock.getAllForStoragePool(storagePoolId, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(result);
    // Execute the query
    getQuery().executeQueryCommand();
    // Check the result
    assertEquals("Wrong query result", result, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 37 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class GetClustersWithPermittedActionQueryTest method testQueryExecution.

@Test
public void testQueryExecution() {
    // Set up the expected data
    Cluster expected = new Cluster();
    // Mock the Dao
    when(clusterDaoMock.getClustersWithPermittedAction(getUser().getId(), getActionGroup())).thenReturn(Collections.singletonList(expected));
    getQuery().executeQueryCommand();
    @SuppressWarnings("unchecked") List<Cluster> actual = getQuery().getQueryReturnValue().getReturnValue();
    assertEquals("Wrong number of VDS Groups", 1, actual.size());
    assertEquals("Wrong VDS Groups", expected, actual.get(0));
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Test(org.junit.Test)

Example 38 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class HasStoragePoolValidatorTest method setUp.

@Before
public void setUp() {
    hsp = new Cluster();
    validator = spy(new HasStoragePoolValidator(hsp));
    doReturn(storagePoolDao).when(validator).getStoragePoolDao();
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Before(org.junit.Before)

Example 39 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class UpdateStoragePoolCommandTest method hasMultipleClustersForLocalDC.

@Test
public void hasMultipleClustersForLocalDC() {
    List<Cluster> clusters = Arrays.asList(new Cluster(), new Cluster());
    when(clusterDao.getAllForStoragePool(any())).thenReturn(clusters);
    cmd.getStoragePool().setIsLocal(true);
    ValidateTestUtils.runAndAssertValidateFailure(cmd, EngineMessage.CLUSTER_CANNOT_ADD_MORE_THEN_ONE_HOST_TO_LOCAL_STORAGE);
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 40 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class UpdateStoragePoolCommandTest method addDefaultClusterToPool.

private void addDefaultClusterToPool() {
    Cluster defaultCluster = new Cluster();
    defaultCluster.setCompatibilityVersion(VERSION_1_1);
    defaultCluster.setId(DEFAULT_CLUSTER_ID);
    List<Cluster> clusters = new ArrayList<>();
    clusters.add(defaultCluster);
    when(clusterDao.getAllForStoragePool(any())).thenReturn(clusters);
}
Also used : ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Aggregations

Cluster (org.ovirt.engine.core.common.businessentities.Cluster)346 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)80 Guid (org.ovirt.engine.core.compat.Guid)77 VDS (org.ovirt.engine.core.common.businessentities.VDS)54 List (java.util.List)50 VM (org.ovirt.engine.core.common.businessentities.VM)36 HashMap (java.util.HashMap)35 Map (java.util.Map)33 HashSet (java.util.HashSet)30 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)30 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)28 Version (org.ovirt.engine.core.compat.Version)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)26 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)26 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)25 Set (java.util.Set)24 QueryType (org.ovirt.engine.core.common.queries.QueryType)23 Collections (java.util.Collections)22 Frontend (org.ovirt.engine.ui.frontend.Frontend)22