use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskContextTest method testGetNullTriggerKey.
@Test
public void testGetNullTriggerKey() throws Exception {
Map<String, Object> parameters = new HashMap<>();
MotechEvent event = mock(MotechEvent.class);
KeyInformation key = parse(String.format("%s.%s", TRIGGER_PREFIX, EVENT_KEY));
Map<String, String> child = new HashMap<>();
child.put("key", null);
parameters.put("event", child);
Task task = new TaskBuilder().addAction(new TaskActionInformation()).build();
assertEquals(null, new TaskContext(task, parameters, null, activityService).getTriggerValue(key.getKey()));
// should not throw any exceptions
assertNull(new TaskContext(task, parameters, null, activityService).getTriggerValue(key.getKey()));
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskContextTest method shouldNotThrowExceptionWhenDataSourceFieldValueEvaluationThrowsException_IfFailNotFoundIsFalse.
@Test
public void shouldNotThrowExceptionWhenDataSourceFieldValueEvaluationThrowsException_IfFailNotFoundIsFalse() throws Exception {
Task task = new TaskBuilder().addAction(new TaskActionInformation()).build();
TaskContext taskContext = new TaskContext(task, null, null, activityService);
taskContext.addDataSourceObject("1", new TestDataSourceObject(), false);
KeyInformation key = parse("ad.1.Integer#1.providerId");
assertNull(taskContext.getDataSourceObjectValue(key.getObjectId().toString(), key.getKey(), key.getObjectType()));
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskBuilderTest method shouldReturnEmptyTaskObject.
@Test
public void shouldReturnEmptyTaskObject() throws Exception {
TaskBuilder builder = new TaskBuilder();
Task task = builder.withName(TASK_NAME).withDescription(TASK_DESCRIPTION).isEnabled(isEnabled).withTrigger(new TaskTriggerInformation()).addAction(new TaskActionInformation()).withTaskConfig(new TaskConfig()).addFilterSet(new FilterSet()).addDataSource(new DataSource()).clear().build();
assertNotNull(task);
assertTrue(task.getName().isEmpty());
assertTrue(task.getDescription().isEmpty());
assertEquals(false, task.isEnabled());
assertNull(task.getTrigger());
assertNotNull(task.getActions());
assertTrue(task.getActions().isEmpty());
assertNotNull(task.getTaskConfig());
assertTrue(task.getTaskConfig().getSteps().isEmpty());
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskControllerTest method shouldSaveExistingTask.
@Test
public void shouldSaveExistingTask() {
Task expected = new Task("name", null, null);
expected.setId(TASK_ID);
expected.setTrigger(new TaskTriggerInformation());
controller.saveTask(expected);
verify(taskWebService).save(expected);
}
use of org.motechproject.tasks.domain.mds.task.Task in project motech by motech.
the class TaskControllerTest method shouldNotSaveNewTask.
@Test
public void shouldNotSaveNewTask() {
Task expected = new Task("name", null, null);
controller.saveTask(expected);
verify(taskWebService, never()).save(expected);
}
Aggregations