use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.
the class AsyncTaskDaoTest method testUpdate.
/**
* Ensures that updating a ad_group works as expected.
*/
@Test
public void testUpdate() {
existingAsyncTask.setstatus(AsyncTaskStatusEnum.aborting);
existingAsyncTask.setresult(AsyncTaskResultEnum.failure);
existingAsyncTask.setActionType(ActionType.AddDisk);
dao.update(existingAsyncTask);
AsyncTask result = dao.get(existingAsyncTask.getTaskId());
assertEquals(existingAsyncTask, result);
}
use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.
the class AsyncTaskDaoTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
dao = dbFacade.getAsyncTaskDao();
ActionParametersBase params = new ActionParametersBase();
params.setSessionId("ASESSIONID");
params.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
ActionParametersBase taskParams = new ActionParametersBase();
taskParams.setSessionId("ASESSIONID");
taskParams.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
taskParams.setParentParameters(params);
// create some test data
newAsyncTask = new AsyncTask();
newAsyncTask.setTaskId(Guid.newGuid());
newAsyncTask.setVdsmTaskId(Guid.newGuid());
newAsyncTask.setStartTime(new Date());
newAsyncTask.setActionType(ActionType.AddDisk);
newAsyncTask.setstatus(AsyncTaskStatusEnum.running);
newAsyncTask.setresult(AsyncTaskResultEnum.success);
newAsyncTask.setActionParameters(params);
newAsyncTask.setTaskParameters(taskParams);
newAsyncTask.setCommandId(Guid.newGuid());
newAsyncTask.setRootCommandId(Guid.newGuid());
newAsyncTask.setTaskType(AsyncTaskType.copyImage);
newAsyncTask.setStoragePoolId(Guid.newGuid());
existingAsyncTask = dao.get(FixturesTool.EXISTING_TASK_ID);
}
use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.
the class AsyncTaskDaoTest method testGetWithInvalidId.
/**
* Ensures that if the id is invalid then no AsyncTask is returned.
*/
@Test
public void testGetWithInvalidId() {
AsyncTask result = dao.get(Guid.newGuid());
assertNull(result);
}
use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.
the class AsyncTaskDaoTest method testGetTaskByVdsmTaskId.
@Test
public void testGetTaskByVdsmTaskId() {
AsyncTask result = dao.getByVdsmTaskId(FixturesTool.EXISTING_VDSM_TASK_ID);
assertNotNull(result);
assertEquals(existingAsyncTask, result);
}
use of org.ovirt.engine.core.common.businessentities.AsyncTask in project ovirt-engine by oVirt.
the class AsyncTaskDaoTest method testRemoveByVdsmTaskId.
@Test
public void testRemoveByVdsmTaskId() {
AsyncTask result = dao.getByVdsmTaskId(FixturesTool.EXISTING_VDSM_TASK_ID);
assertNotNull(result);
assertEquals(1, dao.removeByVdsmTaskId(existingAsyncTask.getVdsmTaskId()));
result = dao.getByVdsmTaskId(existingAsyncTask.getVdsmTaskId());
assertNull(result);
assertEquals(0, dao.removeByVdsmTaskId(existingAsyncTask.getVdsmTaskId()));
// The removed task is associated with an entity, try to fetch
// tasks for the entity, and see no task is returned
List<Guid> taskIds = dao.getAsyncTaskIdsByEntity(FixturesTool.ENTITY_WITH_TASKS_ID);
assertNotNull(taskIds);
assertTrue(taskIds.isEmpty());
}
Aggregations