Search in sources :

Example 11 with ActionParameterBuilder

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;
}
Also used : ActionParameterBuilder(org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder) TreeSet(java.util.TreeSet) ActionParameter(org.motechproject.tasks.domain.mds.channel.ActionParameter)

Example 12 with ActionParameterBuilder

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;
}
Also used : ActionParameterBuilder(org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder) ActionEvent(org.motechproject.tasks.domain.mds.channel.ActionEvent) ActionEventBuilder(org.motechproject.tasks.domain.mds.channel.builder.ActionEventBuilder)

Example 13 with ActionParameterBuilder

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"));
}
Also used : ActionParameterBuilder(org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder) Matchers.anyString(org.mockito.Matchers.anyString) MotechEvent(org.motechproject.event.MotechEvent) Test(org.junit.Test)

Example 14 with ActionParameterBuilder

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);
}
Also used : ActionParameterBuilder(org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder)

Example 15 with ActionParameterBuilder

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);
}
Also used : ActionParameterBuilder(org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder)

Aggregations

ActionParameterBuilder (org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder)19 TreeSet (java.util.TreeSet)6 ActionParameter (org.motechproject.tasks.domain.mds.channel.ActionParameter)6 Test (org.junit.Test)5 ActionEvent (org.motechproject.tasks.domain.mds.channel.ActionEvent)5 ActionEventBuilder (org.motechproject.tasks.domain.mds.channel.builder.ActionEventBuilder)5 DataSource (org.motechproject.tasks.domain.mds.task.DataSource)5 Lookup (org.motechproject.tasks.domain.mds.task.Lookup)5 EventParameter (org.motechproject.tasks.domain.mds.channel.EventParameter)4 TriggerEvent (org.motechproject.tasks.domain.mds.channel.TriggerEvent)4 Task (org.motechproject.tasks.domain.mds.task.Task)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Matchers.anyString (org.mockito.Matchers.anyString)3 MotechEvent (org.motechproject.event.MotechEvent)3 TaskConfig (org.motechproject.tasks.domain.mds.task.TaskConfig)3 Annotation (java.lang.annotation.Annotation)2 DataProvider (org.motechproject.commons.api.DataProvider)2 Channel (org.motechproject.tasks.domain.mds.channel.Channel)2 LookupFieldsParameter (org.motechproject.tasks.domain.mds.task.LookupFieldsParameter)2