use of org.motechproject.tasks.domain.mds.task.TaskActionInformation in project motech by motech.
the class TaskTriggerHandlerTest method setSecondAction.
private void setSecondAction() {
Map<String, String> actionValues = new HashMap<>();
actionValues.put("phone", "123456");
actionValues.put("message", "Hello, world! I'm second action");
task.addAction(new TaskActionInformation("sms", "SMS", "sms-bundle", "0.15", ACTION_SUBJECT, actionValues));
}
use of org.motechproject.tasks.domain.mds.task.TaskActionInformation in project motech by motech.
the class TaskContextTest method shouldThrowExceptionWhenDataSourceIsNull.
@Test
public void shouldThrowExceptionWhenDataSourceIsNull() throws Exception {
Task task = new TaskBuilder().addAction(new TaskActionInformation()).build();
TaskContext taskContext = new TaskContext(task, null, null, activityService);
taskContext.addDataSourceObject("1", null, true);
KeyInformation key = parse("ad.1.Integer#1.id");
expectedException.expect(TaskHandlerException.class);
expectedException.expect(new TaskHandlerExceptionMatcher(TaskFailureCause.DATA_SOURCE, "task.error.objectOfTypeNotFound", key.getObjectType()));
taskContext.getDataSourceObjectValue(key.getObjectId().toString(), key.getKey(), key.getObjectType());
}
use of org.motechproject.tasks.domain.mds.task.TaskActionInformation in project motech by motech.
the class TaskContextTest method testGetDataSourceValue.
@Test
public void testGetDataSourceValue() throws Exception {
Task task = new TaskBuilder().addAction(new TaskActionInformation()).build();
TaskContext taskContext = new TaskContext(task, null, null, activityService);
taskContext.addDataSourceObject("1", new TestDataSourceObject(), true);
KeyInformation key = parse("ad.1.Integer#1.id");
assertEquals(OBJECT_ID.intValue(), taskContext.getDataSourceObjectValue(key.getObjectId().toString(), key.getKey(), key.getObjectType()));
}
use of org.motechproject.tasks.domain.mds.task.TaskActionInformation in project motech by motech.
the class TaskContextTest method testGetTriggerKeyShouldThrowException.
@Test(expected = IllegalStateException.class)
public void testGetTriggerKeyShouldThrowException() throws Exception {
MotechEvent event = mock(MotechEvent.class);
when(event.getParameters()).thenReturn(new HashMap<>());
KeyInformation key = parse(String.format("%s.%s", TRIGGER_PREFIX, EVENT_KEY));
Task task = new TaskBuilder().addAction(new TaskActionInformation()).build();
new TaskContext(task, event.getParameters(), null, activityService).getTriggerValue(key.getKey());
}
Aggregations