Search in sources :

Example 16 with TaskTriggerInformation

use of org.motechproject.tasks.domain.mds.task.TaskTriggerInformation in project motech by motech.

the class SchedulerChannelProviderBundleIT method shouldGetTrigger.

@Test
public void shouldGetTrigger() {
    TaskTriggerInformation information = new TaskTriggerInformation("Job: test-event-job_id", "Channel name", "Module name", "Module version", "test-event-job_id", TEST_EVENT);
    TriggerEvent trigger = channelProvider.getTrigger(information);
    assertEquals(getExpectedTrigger(), trigger);
}
Also used : TaskTriggerInformation(org.motechproject.tasks.domain.mds.task.TaskTriggerInformation) TriggerEvent(org.motechproject.tasks.domain.mds.channel.TriggerEvent) Test(org.junit.Test)

Example 17 with TaskTriggerInformation

use of org.motechproject.tasks.domain.mds.task.TaskTriggerInformation 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 18 with TaskTriggerInformation

use of org.motechproject.tasks.domain.mds.task.TaskTriggerInformation 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)

Example 19 with TaskTriggerInformation

use of org.motechproject.tasks.domain.mds.task.TaskTriggerInformation in project motech by motech.

the class TaskDataServiceBundleIT method shouldAddTaskAsNewIfItHasIDAndTaskNotExistInDB.

@Test
public void shouldAddTaskAsNewIfItHasIDAndTaskNotExistInDB() {
    Task expected = new TaskBuilder().withId(1L).withName("name").withTrigger(new TaskTriggerInformation("receive", "test", "test", "0.14", "RECEIVE", "RECEIVE")).addAction(new TaskActionInformation("send", "test", "test", "0.15", "SEND", new HashMap<String, String>())).build();
    tasksDataService.create(expected);
    List<Task> tasks = tasksDataService.retrieveAll();
    assertEquals(asList(expected), tasks);
}
Also used : TaskBuilder(org.motechproject.tasks.domain.mds.task.builder.TaskBuilder) 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 20 with TaskTriggerInformation

use of org.motechproject.tasks.domain.mds.task.TaskTriggerInformation in project motech by motech.

the class TaskDataServiceBundleIT method shouldSaveMoreThan255CharactersInTaskActionInformation.

@Test
public void shouldSaveMoreThan255CharactersInTaskActionInformation() {
    String value1 = RandomStringUtils.randomAlphanumeric(500);
    String value2 = RandomStringUtils.randomAlphanumeric(450);
    Map<String, String> values = new HashMap<>();
    values.put("value1", value1);
    values.put("value2", value2);
    TaskActionInformation action = new TaskActionInformation("action", "test", "test", "0.15", "SEND", values);
    TaskTriggerInformation trigger = new TaskTriggerInformation("trigger", "best", "test", "0.14", "RECEIVE-1", null);
    Task task = new Task("task1", trigger, asList(action));
    task = tasksDataService.create(task);
    Task taskFromDatabase = tasksDataService.findById(task.getId());
    assertEquals(value1, taskFromDatabase.getActions().get(0).getValues().get("value1"));
    assertEquals(value2, taskFromDatabase.getActions().get(0).getValues().get("value2"));
}
Also used : TaskTriggerInformation(org.motechproject.tasks.domain.mds.task.TaskTriggerInformation) Task(org.motechproject.tasks.domain.mds.task.Task) HashMap(java.util.HashMap) TaskActionInformation(org.motechproject.tasks.domain.mds.task.TaskActionInformation) Test(org.junit.Test)

Aggregations

TaskTriggerInformation (org.motechproject.tasks.domain.mds.task.TaskTriggerInformation)28 Test (org.junit.Test)23 Task (org.motechproject.tasks.domain.mds.task.Task)16 TaskActionInformation (org.motechproject.tasks.domain.mds.task.TaskActionInformation)14 TriggerEvent (org.motechproject.tasks.domain.mds.channel.TriggerEvent)8 TaskConfig (org.motechproject.tasks.domain.mds.task.TaskConfig)7 TaskError (org.motechproject.tasks.domain.mds.task.TaskError)7 HashMap (java.util.HashMap)6 DataSource (org.motechproject.tasks.domain.mds.task.DataSource)6 ArrayList (java.util.ArrayList)5 FilterSet (org.motechproject.tasks.domain.mds.task.FilterSet)5 Matchers.anyString (org.mockito.Matchers.anyString)4 DataProvider (org.motechproject.commons.api.DataProvider)4 MotechEvent (org.motechproject.event.MotechEvent)4 EventParameter (org.motechproject.tasks.domain.mds.channel.EventParameter)4 Lookup (org.motechproject.tasks.domain.mds.task.Lookup)4 TaskBuilder (org.motechproject.tasks.domain.mds.task.builder.TaskBuilder)4 TaskHandlerException (org.motechproject.tasks.exception.TaskHandlerException)4 HashSet (java.util.HashSet)3 TreeSet (java.util.TreeSet)2