use of org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder in project motech by motech.
the class TaskAnnotationBeanPostProcessorTest method getExpectedPostActionParameters.
private SortedSet<ActionParameter> getExpectedPostActionParameters() {
SortedSet<ActionParameter> set = new TreeSet<>();
set.add(new ActionParameterBuilder().setDisplayName(EXTERNAL_DISPLAY_NAME_2).setKey(EXTERNAL_KEY_2).setOrder(0).build());
return set;
}
use of org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder in project motech by motech.
the class MethodHandlerTest method getActionEvent.
private ActionEvent getActionEvent(MethodCallManner callManner) {
ActionEvent action = new ActionEventBuilder().setServiceMethodCallManner(callManner).build();
action.addParameter(new ActionParameterBuilder().setDisplayName("String").setKey("string").build(), true);
action.addParameter(new ActionParameterBuilder().setDisplayName("Integer").setKey("integer").setType(ParameterType.INTEGER).build(), true);
action.addParameter(new ActionParameterBuilder().setDisplayName("Long").setKey("long").setType(ParameterType.LONG).build(), true);
action.addParameter(new ActionParameterBuilder().setDisplayName("Double").setKey("double").setType(ParameterType.DOUBLE).build(), true);
action.addParameter(new ActionParameterBuilder().setDisplayName("Boolean").setKey("boolean").setType(ParameterType.BOOLEAN).build(), true);
action.addParameter(new ActionParameterBuilder().setDisplayName("Date").setKey("date").setType(ParameterType.DATE).build(), true);
action.addParameter(new ActionParameterBuilder().setDisplayName("Map").setKey("map").setType(ParameterType.MAP).build(), true);
action.addParameter(new ActionParameterBuilder().setDisplayName("List").setKey("list").setType(ParameterType.LIST).build(), true);
return action;
}
use of org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder in project motech by motech.
the class TaskTriggerHandlerTest method shouldSendEventAndConvertDateWithAndWithoutManipulation.
@Test
public void shouldSendEventAndConvertDateWithAndWithoutManipulation() throws Exception {
setTriggerEvent();
setActionEvent();
when(taskService.findActiveTasksForTriggerSubject(TRIGGER_SUBJECT)).thenReturn(tasks);
when(taskService.getActionEventFor(task.getActions().get(0))).thenReturn(actionEvent);
task.getActions().get(0).getValues().put("date1", "2012-12-21 21:21 +0100");
actionEvent.addParameter(new ActionParameterBuilder().setDisplayName("Date1").setKey("date1").setType(DATE).build(), true);
task.getActions().get(0).getValues().put("date2", "{{trigger.startDate?datetime(yyyyy.MMMMM.dd GGG hh:mm aaa)}}");
actionEvent.addParameter(new ActionParameterBuilder().setDisplayName("Date2").setKey("date2").setType(UNICODE).build(), true);
handler.handle(createEvent());
verify(taskService).findActiveTasksForTriggerSubject(TRIGGER_SUBJECT);
verify(taskService).getActionEventFor(task.getActions().get(0));
ArgumentCaptor<MotechEvent> captorEvent = ArgumentCaptor.forClass(MotechEvent.class);
verify(eventRelay).sendEventMessage(captorEvent.capture());
MotechEvent motechEvent = captorEvent.getValue();
assertEquals(ACTION_SUBJECT, motechEvent.getSubject());
Map<String, Object> motechEventParameters = motechEvent.getParameters();
assertNotNull(motechEventParameters);
assertEquals(task.getActions().get(0).getValues().get("phone"), motechEventParameters.get("phone").toString());
assertEquals(4, motechEventParameters.size());
assertNotNull(motechEventParameters.get("date1"));
assertNotNull(motechEventParameters.get("date2"));
}
use of org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder in project motech by motech.
the class TaskTriggerHandlerTest method setManipulation.
private void setManipulation() {
task.getActions().get(0).getValues().put("manipulations", "String manipulation: {{trigger.eventName?toUpper?toLower?capitalize?join(-)}}, Date manipulation: {{trigger.startDate?dateTime(yyyyMMdd)}}");
actionEvent.addParameter(new ActionParameterBuilder().setDisplayName("Manipulations").setKey("manipulations").setType(TEXTAREA).build(), true);
}
use of org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder in project motech by motech.
the class TaskTriggerHandlerTest method setDateField.
private void setDateField() {
task.getActions().get(0).getValues().put("date", "2012-12-21 21:21 +0100");
actionEvent.addParameter(new ActionParameterBuilder().setDisplayName("Date").setKey("date").setType(DATE).build(), true);
}
Aggregations