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);
}
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"));
}
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);
}
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);
}
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"));
}
Aggregations