Search in sources :

Example 1 with ActionParameterRequestBuilder

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;
}
Also used : TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ActionParameterRequest(org.motechproject.tasks.contract.ActionParameterRequest) ActionEventRequest(org.motechproject.tasks.contract.ActionEventRequest) ActionParameterRequestBuilder(org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder) TestActionEventRequestBuilder(org.motechproject.tasks.contract.builder.TestActionEventRequestBuilder)

Example 2 with ActionParameterRequestBuilder

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);
}
Also used : TreeSet(java.util.TreeSet) ActionParameterRequest(org.motechproject.tasks.contract.ActionParameterRequest) ActionEventRequest(org.motechproject.tasks.contract.ActionEventRequest) ActionParameterRequestBuilder(org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder) TestActionEventRequestBuilder(org.motechproject.tasks.contract.builder.TestActionEventRequestBuilder)

Example 3 with ActionParameterRequestBuilder

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);
}
Also used : JsonObject(com.google.gson.JsonObject) ActionParameterRequest(org.motechproject.tasks.contract.ActionParameterRequest) ActionEventRequest(org.motechproject.tasks.contract.ActionEventRequest) ActionParameterRequestBuilder(org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder) TestActionEventRequestBuilder(org.motechproject.tasks.contract.builder.TestActionEventRequestBuilder) Test(org.junit.Test)

Example 4 with ActionParameterRequestBuilder

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;
}
Also used : TreeSet(java.util.TreeSet) ActionParameterRequest(org.motechproject.tasks.contract.ActionParameterRequest) ActionParameterRequestBuilder(org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder)

Aggregations

ActionParameterRequest (org.motechproject.tasks.contract.ActionParameterRequest)4 ActionParameterRequestBuilder (org.motechproject.tasks.contract.builder.ActionParameterRequestBuilder)4 TreeSet (java.util.TreeSet)3 ActionEventRequest (org.motechproject.tasks.contract.ActionEventRequest)3 TestActionEventRequestBuilder (org.motechproject.tasks.contract.builder.TestActionEventRequestBuilder)3 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1