use of org.motechproject.tasks.domain.mds.task.TaskActionInformation in project motech by motech.
the class TaskServiceImplTest method shouldFailValidationIfTriggerChannelIsNotRegistered.
@Test
public void shouldFailValidationIfTriggerChannelIsNotRegistered() {
TaskTriggerInformation trigger = new TaskTriggerInformation("triggerDisplay", "triggerChannel", "triggerModule", "1.0", "subject", "triggerListenerSubject");
TaskActionInformation action = new TaskActionInformation("actionDisplay", "actionChannel", "actionModule", "1.0", "subject");
Task fooTask = new TaskBuilder().withName("foo").withTrigger(trigger).withTaskConfig(new TaskConfig()).addAction(action).build();
fooTask.setEnabled(true);
when(channelService.getChannel("foo-module")).thenReturn(null);
when(channelService.getChannel("actionModule")).thenReturn(null);
Set<TaskError> errors = new HashSet<>();
errors.add(new TaskError("task.validation.error.triggerChannelNotRegistered"));
when(triggerEventService.validateTrigger(trigger)).thenReturn(errors);
expectedException.expect(ValidationException.class);
expectedException.expect(new TypeSafeMatcher<ValidationException>() {
@Override
public void describeTo(Description description) {
}
@Override
public boolean matchesSafely(ValidationException actualException) {
final TaskErrorDto triggerChannelError = new TaskErrorDto("task.validation.error.triggerChannelNotRegistered");
final TaskErrorDto actionChannelError = new TaskErrorDto("task.validation.error.actionChannelNotRegistered");
Set<TaskErrorDto> taskErrors = actualException.getTaskErrors();
return taskErrors.contains(triggerChannelError) && taskErrors.contains(actionChannelError);
}
});
taskService.save(fooTask);
}
use of org.motechproject.tasks.domain.mds.task.TaskActionInformation 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.TaskActionInformation in project motech by motech.
the class ProviderNameTaskMigrator method migrateActions.
private void migrateActions(Task task) {
// replace data source references in actions
for (TaskActionInformation action : task.getActions()) {
for (Map.Entry<String, String> entry : action.getValues().entrySet()) {
String oldVal = entry.getValue();
String newVal = replaceTaskValue(oldVal, EXPR_PATTERN, task);
entry.setValue(newVal);
}
}
}
use of org.motechproject.tasks.domain.mds.task.TaskActionInformation in project motech by motech.
the class TaskAnnotationBeanPostProcessor method getAction.
private ActionEvent getAction(Channel channel, String serviceInterface, Method method, String actionName) {
TaskActionInformation info = new TaskActionInformation(method.getName(), actionName, channel.getDisplayName(), channel.getModuleName(), channel.getModuleVersion(), serviceInterface, method.getName());
ActionEvent actionEvent = null;
for (ActionEvent action : channel.getActionTaskEvents()) {
if (action.accept(info)) {
actionEvent = action;
break;
}
}
return actionEvent;
}
use of org.motechproject.tasks.domain.mds.task.TaskActionInformation 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"));
}
Aggregations