Search in sources :

Example 46 with Task

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);
}
Also used : Task(org.motechproject.tasks.domain.mds.task.Task) Test(org.junit.Test)

Example 47 with Task

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);
}
Also used : TaskBuilder(org.motechproject.tasks.domain.mds.task.builder.TaskBuilder) Task(org.motechproject.tasks.domain.mds.task.Task) Filter(org.motechproject.tasks.domain.mds.task.Filter) ArrayList(java.util.ArrayList) TaskActionInformation(org.motechproject.tasks.domain.mds.task.TaskActionInformation) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 48 with Task

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);
}
Also used : Task(org.motechproject.tasks.domain.mds.task.Task) ArrayList(java.util.ArrayList) TaskActivityDto(org.motechproject.tasks.dto.TaskActivityDto) QueryParams(org.motechproject.mds.query.QueryParams) Before(org.junit.Before)

Example 49 with Task

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"));
}
Also used : TaskTriggerInformation(org.motechproject.tasks.domain.mds.task.TaskTriggerInformation) Task(org.motechproject.tasks.domain.mds.task.Task) TaskActionInformation(org.motechproject.tasks.domain.mds.task.TaskActionInformation) Test(org.junit.Test)

Example 50 with Task

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);
}
Also used : TaskTriggerInformation(org.motechproject.tasks.domain.mds.task.TaskTriggerInformation) Task(org.motechproject.tasks.domain.mds.task.Task) TaskActionInformation(org.motechproject.tasks.domain.mds.task.TaskActionInformation) Test(org.junit.Test)

Aggregations

Task (org.motechproject.tasks.domain.mds.task.Task)86 Test (org.junit.Test)65 TaskActionInformation (org.motechproject.tasks.domain.mds.task.TaskActionInformation)35 TaskBuilder (org.motechproject.tasks.domain.mds.task.builder.TaskBuilder)26 HashMap (java.util.HashMap)21 ActionEventBuilder (org.motechproject.tasks.domain.mds.channel.builder.ActionEventBuilder)19 TaskConfig (org.motechproject.tasks.domain.mds.task.TaskConfig)19 ArrayList (java.util.ArrayList)18 TaskTriggerInformation (org.motechproject.tasks.domain.mds.task.TaskTriggerInformation)17 TriggerEvent (org.motechproject.tasks.domain.mds.channel.TriggerEvent)16 DataSource (org.motechproject.tasks.domain.mds.task.DataSource)15 EventParameter (org.motechproject.tasks.domain.mds.channel.EventParameter)14 ActionEvent (org.motechproject.tasks.domain.mds.channel.ActionEvent)13 Channel (org.motechproject.tasks.domain.mds.channel.Channel)12 Lookup (org.motechproject.tasks.domain.mds.task.Lookup)11 KeyInformation (org.motechproject.tasks.domain.KeyInformation)10 TreeSet (java.util.TreeSet)9 MotechEvent (org.motechproject.event.MotechEvent)9 ObjectTest (org.motechproject.tasks.domain.ObjectTest)9 TaskDataProviderObject (org.motechproject.tasks.domain.mds.task.TaskDataProviderObject)9