use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskServiceImplTest method shouldNotSaveTaskWithoutName.
@Test(expected = ValidationException.class)
public void shouldNotSaveTaskWithoutName() {
Task t = new Task(null, trigger, asList(action));
taskService.save(t);
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskFilterExecutorTest method shouldThrowExceptionIfDataSourceObjectIsNotFound.
@Test(expected = TaskHandlerException.class)
public void shouldThrowExceptionIfDataSourceObjectIsNotFound() throws TaskHandlerException {
List<Filter> filters = new ArrayList<>();
List<String> filtersManipulations = new ArrayList<>();
filters.add(new Filter("MRS.Person#2.Age", "ad.2.Person#2.age", INTEGER, false, EXIST.getValue(), "", filtersManipulations));
Task task = new TaskBuilder().addAction(new TaskActionInformation()).build();
TaskContext taskContext = new TaskContext(task, new HashMap<>(), new HashMap<>(), activityService);
new TaskFilterExecutor().checkFilters(filters, LogicalOperator.AND, taskContext);
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class ActivityControllerTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
controller = new ActivityController(activityService, taskTriggerHandler, taskWebService);
params = new HashMap<String, Object>();
params.put("errorKey", "errorValue");
expected = new ArrayList<>();
expected.add(new TaskActivityDto(SUCCESS.getValue(), TASK_ID, SUCCESS));
expected.add(new TaskActivityDto(WARNING.getValue(), TASK_ID, WARNING));
expected.add(new TaskActivityDto(ERROR.getValue(), TASK_ID, ERROR));
expected.add(new TaskActivityDto(ACTIVITY_ID, ERROR.getValue(), TASK_ID, new ArrayList<>(), null, ERROR, null, params));
activityTypes = new HashSet<>();
activityTypes.addAll(Arrays.asList(TaskActivityType.values()));
queryParams = new QueryParams(page, pageSize);
task = new Task();
task.setId(TASK_ID);
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskDataServiceBundleIT method shouldFindTasksThatDependOnAModule.
@Test
public void shouldFindTasksThatDependOnAModule() {
TaskTriggerInformation trigger1 = new TaskTriggerInformation("trigger1", "best", "test", "0.14", "RECEIVE-1", null);
TaskTriggerInformation trigger2 = new TaskTriggerInformation("trigger2", "lest", "jest", "0.14", "RECEIVE-2", null);
TaskActionInformation action1 = new TaskActionInformation("action1", "test", "test", "0.15", "SEND");
TaskActionInformation action2 = new TaskActionInformation("action2", "fest", "test", "0.12", "actionSubject");
TaskActionInformation action3 = new TaskActionInformation("action2", "fest", "jest", "0.12", "actionSubject");
Task[] tasks = new Task[] { new Task("task1", trigger1, asList(action1)), new Task("task2", trigger2, asList(action3)), new Task("task3", new TaskTriggerInformation(trigger1), asList(action2)), new Task("task4", new TaskTriggerInformation(trigger2), asList(action1)) };
for (Task task : tasks) {
tasksDataService.create(task);
}
List<String> tasksUsingTestModule = extract(taskService.findTasksDependentOnModule("test"), on(Task.class).getName());
assertTrue(tasksUsingTestModule.contains("task1"));
assertTrue(tasksUsingTestModule.contains("task3"));
assertTrue(tasksUsingTestModule.contains("task4"));
assertFalse(tasksUsingTestModule.contains("task2"));
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskDataServiceBundleIT method shouldAddAndUpdateTask.
@Test
public void shouldAddAndUpdateTask() {
TaskActionInformation action = new TaskActionInformation("send", "test", "test", "0.15", "SEND", new HashMap<String, String>());
TaskTriggerInformation trigger = new TaskTriggerInformation("receive", "test", "test", "0.14", "RECEIVE", null);
Task expected = new Task("name", trigger, asList(action));
tasksDataService.create(expected);
List<Task> tasks = tasksDataService.retrieveAll();
assertEquals(asList(expected), tasks);
Task actual = tasks.get(0);
actual.setName("newName");
tasksDataService.update(actual);
tasks = tasksDataService.retrieveAll();
assertEquals(asList(actual), tasks);
}
Aggregations