/** Ensures that saving a ad_group works as expected. */ @Test public void testSave() { dao.save(newAsyncTask); async_tasks result = dao.get(newAsyncTask.gettask_id()); assertEquals(newAsyncTask, result); }
/** Ensures that removing a ad_group works as expected. */ @Test public void testRemove() { async_tasks result = dao.get(existingAsyncTask.gettask_id()); assertNotNull(result); assertEquals(dao.remove(existingAsyncTask.gettask_id()), 1); result = dao.get(existingAsyncTask.gettask_id()); assertNull(result); assertEquals(dao.remove(existingAsyncTask.gettask_id()), 0); // 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()); }
/** Ensures that, if the id is valid, then retrieving a AsyncTask works as expected. */ @Test public void testGet() { async_tasks result = dao.get(existingAsyncTask.gettask_id()); // NOTE: There is no equals() method in async_tasks class. assertNotNull(result); assertEquals(existingAsyncTask, result); }
/** Ensures that saving a ad_group works as expected. */ @Test public void testSaveWithEntities() { Guid storageId = Guid.NewGuid(); dao.save(newAsyncTask, VdcObjectType.Storage, storageId); List<Guid> asyncTasks = dao.getAsyncTaskIdsByEntity(storageId); assertNotNull(asyncTasks); assertEquals(asyncTasks.size(), 1); assertEquals(asyncTasks.get(0), newAsyncTask.gettask_id()); }
/** Ensures that updating a ad_group works as expected. */ @Test public void testUpdate() { existingAsyncTask.setstatus(AsyncTaskStatusEnum.aborting); existingAsyncTask.setresult(AsyncTaskResultEnum.failure); existingAsyncTask.setaction_type(VdcActionType.AddDisk); AddDiskParameters addDiskToVmParams = new AddDiskParameters(); addDiskToVmParams.setSessionId("SESSION_ID"); existingAsyncTask.setaction_parameters(addDiskToVmParams); dao.update(existingAsyncTask); async_tasks result = dao.get(existingAsyncTask.gettask_id()); assertEquals(existingAsyncTask, result); }