Search in sources :

Example 6 with TriggerEvent

use of org.motechproject.tasks.domain.mds.channel.TriggerEvent in project motech by motech.

the class TasksTestBase method setTriggerEvent.

protected void setTriggerEvent() {
    List<EventParameter> triggerEventParameters = new ArrayList<>();
    triggerEventParameters.add(new EventParameter("ExternalID", "externalId"));
    triggerEventParameters.add(new EventParameter("StartDate", "startDate", DATE));
    triggerEventParameters.add(new EventParameter("EndDate", "endDate", DATE));
    triggerEventParameters.add(new EventParameter("FacilityId", "facilityId"));
    triggerEventParameters.add(new EventParameter("EventName", "eventName"));
    triggerEventParameters.add(new EventParameter("List", "list", LIST));
    triggerEventParameters.add(new EventParameter("Map", "map", MAP));
    triggerEvent = new TriggerEvent();
    triggerEvent.setSubject(TRIGGER_SUBJECT);
    triggerEvent.setEventParameters(triggerEventParameters);
}
Also used : EventParameter(org.motechproject.tasks.domain.mds.channel.EventParameter) TriggerEvent(org.motechproject.tasks.domain.mds.channel.TriggerEvent) ArrayList(java.util.ArrayList)

Example 7 with TriggerEvent

use of org.motechproject.tasks.domain.mds.channel.TriggerEvent in project motech by motech.

the class TaskServiceImpl method validateAction.

private Set<TaskError> validateAction(Task task, Channel channel, TaskActionInformation action) {
    LOGGER.debug("Validating task action: {} from task: {} with ID: {}", action.getName(), task.getName(), task.getId());
    Set<TaskError> errors = new HashSet<>();
    if (channel == null) {
        errors.add(new TaskError("task.validation.error.actionChannelNotRegistered"));
        return errors;
    }
    if (channel.getModuleName().equalsIgnoreCase(action.getModuleName())) {
        errors.addAll(taskValidator.validateAction(action, channel));
        TriggerEvent trigger = triggerEventService.getTrigger(task.getTrigger());
        Map<Long, TaskDataProvider> providers = getProviders(task);
        ActionEvent actionEvent = channel.getAction(action);
        if (actionEvent != null) {
            errors.addAll(taskValidator.validateActionFields(action, actionEvent, trigger, providers));
        }
    }
    logResultOfValidation("task action", task.getName(), errors);
    return errors;
}
Also used : TaskDataProvider(org.motechproject.tasks.domain.mds.task.TaskDataProvider) TriggerEvent(org.motechproject.tasks.domain.mds.channel.TriggerEvent) ActionEvent(org.motechproject.tasks.domain.mds.channel.ActionEvent) TaskError(org.motechproject.tasks.domain.mds.task.TaskError) HashSet(java.util.HashSet)

Example 8 with TriggerEvent

use of org.motechproject.tasks.domain.mds.channel.TriggerEvent in project motech by motech.

the class SchedulerChannelProviderBundleIT method getExpectedTrigger.

private TriggerEvent getExpectedTrigger() {
    List<EventParameter> parameters = new ArrayList<>();
    parameters.add(new EventParameter("scheduler.jobId", "JobID"));
    return new TriggerEvent("Job: test-event-job_id", "test-event-job_id", null, parameters, TEST_EVENT);
}
Also used : EventParameter(org.motechproject.tasks.domain.mds.channel.EventParameter) TriggerEvent(org.motechproject.tasks.domain.mds.channel.TriggerEvent) ArrayList(java.util.ArrayList)

Example 9 with TriggerEvent

use of org.motechproject.tasks.domain.mds.channel.TriggerEvent in project motech by motech.

the class AbstractTaskBundleIT method findTriggerEventBySubject.

protected TriggerEvent findTriggerEventBySubject(List<TriggerEvent> triggerEvents, String subject) {
    TaskEvent taskEvent = findTaskEventBySubject(triggerEvents, subject);
    assertTrue(taskEvent instanceof TriggerEvent);
    return (TriggerEvent) taskEvent;
}
Also used : TriggerEvent(org.motechproject.tasks.domain.mds.channel.TriggerEvent) TaskEvent(org.motechproject.tasks.domain.mds.channel.TaskEvent)

Example 10 with TriggerEvent

use of org.motechproject.tasks.domain.mds.channel.TriggerEvent in project motech by motech.

the class DynamicChannelLoaderImplTest method prepareTriggerEvents.

private List<TriggerEvent> prepareTriggerEvents() {
    List<TriggerEvent> triggers = new ArrayList<>();
    triggers.add(prepareTriggerEvent());
    triggers.add(new TriggerEvent("subjectTwo", "subject.two", DESCRIPTION, null, null));
    return triggers;
}
Also used : TriggerEvent(org.motechproject.tasks.domain.mds.channel.TriggerEvent) ArrayList(java.util.ArrayList)

Aggregations

TriggerEvent (org.motechproject.tasks.domain.mds.channel.TriggerEvent)34 Test (org.junit.Test)24 EventParameter (org.motechproject.tasks.domain.mds.channel.EventParameter)22 ArrayList (java.util.ArrayList)17 Task (org.motechproject.tasks.domain.mds.task.Task)16 Channel (org.motechproject.tasks.domain.mds.channel.Channel)13 ActionEventBuilder (org.motechproject.tasks.domain.mds.channel.builder.ActionEventBuilder)12 TaskConfig (org.motechproject.tasks.domain.mds.task.TaskConfig)12 DataSource (org.motechproject.tasks.domain.mds.task.DataSource)9 Lookup (org.motechproject.tasks.domain.mds.task.Lookup)9 TaskDataProviderObject (org.motechproject.tasks.domain.mds.task.TaskDataProviderObject)9 TaskTriggerInformation (org.motechproject.tasks.domain.mds.task.TaskTriggerInformation)8 ActionEvent (org.motechproject.tasks.domain.mds.channel.ActionEvent)7 TaskDataProvider (org.motechproject.tasks.domain.mds.task.TaskDataProvider)7 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 TaskError (org.motechproject.tasks.domain.mds.task.TaskError)6 MotechEvent (org.motechproject.event.MotechEvent)5 LookupFieldsParameter (org.motechproject.tasks.domain.mds.task.LookupFieldsParameter)5 Matchers.anyString (org.mockito.Matchers.anyString)4