use of org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder in project motech by motech.
the class ActionEventDeserializerParametrizedTest method getPillReminderEvents.
private static List<ActionEventRequest> getPillReminderEvents() {
SortedSet<ActionParameterRequest> parameters = new TreeSet<>();
parameters.add(new ActionParameterRequestBuilder().setKey("DosageID").setDisplayName("pillreminder.dossageID").setOrder(0).createActionParameterRequest());
parameters.add(new ActionParameterRequestBuilder().setKey("ExternalID").setDisplayName("pillreminder.externalID").setOrder(1).createActionParameterRequest());
parameters.add(new ActionParameterRequestBuilder().setKey("times-reminders-sent").setDisplayName("pillreminder.times.sent").setOrder(2).setType("INTEGER").createActionParameterRequest());
parameters.add(new ActionParameterRequestBuilder().setKey("times-reminders-to-be-sent").setDisplayName("pillreminder.total.times.sent").setOrder(3).setType("INTEGER").createActionParameterRequest());
parameters.add(new ActionParameterRequestBuilder().setKey("retry-interval").setDisplayName("pillreminder.retry.interval").setOrder(4).setType("INTEGER").createActionParameterRequest());
ActionEventRequest event = new TestActionEventRequestBuilder().setDisplayName("pillreminder.event.subject.scheduler").setSubject("org.motechproject.server.pillreminder.scheduler-reminder").setDescription("description").setServiceInterface(null).setServiceMethod(null).setActionParameters(parameters).createActionEventRequest();
List<ActionEventRequest> events = new ArrayList<>();
events.add(event);
return events;
}
use of org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder in project motech by motech.
the class ActionEventDeserializerParametrizedTest method getMessageCampaignEvents.
private static List<ActionEventRequest> getMessageCampaignEvents() {
SortedSet<ActionParameterRequest> parameters1 = new TreeSet<>();
parameters1.add(new ActionParameterRequestBuilder().setKey("CampaignName").setDisplayName("msgCampaign.campaign.name").setOrder(0).createActionParameterRequest());
parameters1.add(new ActionParameterRequestBuilder().setKey("ExternalID").setDisplayName("msgCampaign.externalID").setOrder(1).createActionParameterRequest());
parameters1.add(new ActionParameterRequestBuilder().setKey("MessageKey").setDisplayName("msgCampaign.message.key").setOrder(2).createActionParameterRequest());
ActionEventRequest event1 = new TestActionEventRequestBuilder().setDisplayName("msgCampaign.send.message").setSubject("org.motechproject.messagecampaign.fired-campaign-message").setDescription("description").setServiceInterface(null).setServiceMethod(null).setActionParameters(parameters1).createActionEventRequest();
SortedSet<ActionParameterRequest> parameters2 = new TreeSet<>();
parameters2.add(new ActionParameterRequestBuilder().setKey("ExternalID").setDisplayName("msgCampaign.externalID").setOrder(0).createActionParameterRequest());
parameters2.add(new ActionParameterRequestBuilder().setKey("CampaignName").setDisplayName("msgCampaign.campaign.name").setOrder(1).createActionParameterRequest());
ActionEventRequest event2 = new TestActionEventRequestBuilder().setDisplayName("msgCampaign.campaign.completed").setSubject("org.motechproject.messagecampaign.campaign-completed").setDescription("description").setServiceInterface("org.motechproject.messagecampaign.service.MessageCampaignService").setServiceMethod("campaignCompleted").setActionParameters(parameters2).createActionEventRequest();
return asList(event1, event2);
}
use of org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder in project motech by motech.
the class ActionEventDeserializerTest method shouldDeserializeJsonWithActionParameters.
@Test
public void shouldDeserializeJsonWithActionParameters() {
ActionEventRequest expected = new TestActionEventRequestBuilder().setDisplayName(DISPLAY_NAME_FIELD).setSubject(SUBJECT_FIELD).setDescription(DESCRIPTION_FIELD).setServiceInterface(SERVICE_INTERFACE_FIELD).setServiceMethod(SERVICE_METHOD_FIELD).setActionParameters(getActionParameters()).createActionEventRequest();
JsonObject object = createJsonObject(expected);
ActionParameterRequest actionParameterRequestWithoutOrder = new ActionParameterRequestBuilder().setKey("Witout order").setDisplayName("withoutOrder").createActionParameterRequest();
expected.addParameter(actionParameterRequestWithoutOrder, true);
object.getAsJsonArray(ACTION_PARAMETERS_FIELD).add(createParameter(actionParameterRequestWithoutOrder));
ActionEventRequest actual = deserializer.deserialize(object, null, context);
assertEquals(expected, actual);
}
use of org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder in project motech by motech.
the class ActionEventDeserializerTest method getActionParameters.
private SortedSet<ActionParameterRequest> getActionParameters() {
SortedSet<ActionParameterRequest> parameters = new TreeSet<>();
parameters.add(new ActionParameterRequestBuilder().setKey(EXTERNAL_DISPLAY_NAME).setDisplayName(EXTERNAL_KEY).setOrder(0).createActionParameterRequest());
parameters.add(new ActionParameterRequestBuilder().setKey(MOTECH_DISPLAY_NAME).setDisplayName(MOTECH_KEY).setOrder(1).setType(ParameterType.INTEGER.getValue()).createActionParameterRequest());
return parameters;
}
Aggregations