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());
}
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));
}
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();
}
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);
}
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);
}
Aggregations