@Test public void shouldNotSendEventIfDateFormatInManipulationIsNotValid() throws Exception { setTriggerEvent(); setActionEvent(); setManipulation(); when(taskService.findActiveTasksForTriggerSubject(TRIGGER_SUBJECT)).thenReturn(tasks); when(taskService.getActionEventFor(task.getActions().get(0))).thenReturn(actionEvent); task.getActions().get(0).getValues().put("manipulations", "{{trigger.startDate?dateTime(BadFormat)}}"); handler.handle(createEvent()); verifyErrorHandling("error.date.format"); }
@Override @Transactional public void handle(MotechEvent event) { LOGGER.info("Handling the motech event with subject: {}", event.getSubject()); Map<String, Object> eventParams = event.getParameters(); eventParams.putAll(event.getMetadata()); TasksEventParser parser = null; if (eventParams != null) { parser = taskService.findCustomParser((String) eventParams.get(TasksEventParser.CUSTOM_PARSER_EVENT_KEY)); } String triggerSubject = parser == null ? event.getSubject() : parser.parseEventSubject(event.getSubject(), eventParams); Map<String, Object> parameters = parser == null ? eventParams : parser.parseEventParameters(event.getSubject(), eventParams); List<Task> tasks = taskService.findActiveTasksForTriggerSubject(triggerSubject); for (Task task : tasks) { checkAndHandleTask(task, parameters); } }
TaskTriggerHandler implements TriggerHandler { @Override @Transactional public void handle(MotechEvent event) { LOGGER.info("Handling the motech event with subject: {}", event.getSubject()); Map<String, Object> eventParams = event.getParameters(); eventParams.putAll(event.getMetadata()); TasksEventParser parser = null; if (eventParams != null) { parser = taskService.findCustomParser((String) eventParams.get(TasksEventParser.CUSTOM_PARSER_EVENT_KEY)); } String triggerSubject = parser == null ? event.getSubject() : parser.parseEventSubject(event.getSubject(), eventParams); Map<String, Object> parameters = parser == null ? eventParams : parser.parseEventParameters(event.getSubject(), eventParams); List<Task> tasks = taskService.findActiveTasksForTriggerSubject(triggerSubject); for (Task task : tasks) { checkAndHandleTask(task, parameters); } } }
TaskTriggerHandler implements TriggerHandler { @Override @Transactional public void handle(MotechEvent event) { LOGGER.info("Handling the motech event with subject: {}", event.getSubject()); Map<String, Object> eventParams = event.getParameters(); eventParams.putAll(event.getMetadata()); TasksEventParser parser = null; if (eventParams != null) { parser = taskService.findCustomParser((String) eventParams.get(TasksEventParser.CUSTOM_PARSER_EVENT_KEY)); } String triggerSubject = parser == null ? event.getSubject() : parser.parseEventSubject(event.getSubject(), eventParams); Map<String, Object> parameters = parser == null ? eventParams : parser.parseEventParameters(event.getSubject(), eventParams); List<Task> tasks = taskService.findActiveTasksForTriggerSubject(triggerSubject); for (Task task : tasks) { checkAndHandleTask(task, parameters); } }  }
TaskTriggerHandler implements TriggerHandler { @Override @Transactional public void handle(MotechEvent event) { LOGGER.info("Handling the motech event with subject: {}", event.getSubject()); Map<String, Object> eventParams = event.getParameters(); eventParams.putAll(event.getMetadata()); TasksEventParser parser = null; if (eventParams != null) { parser = taskService.findCustomParser((String) eventParams.get(TasksEventParser.CUSTOM_PARSER_EVENT_KEY)); } String triggerSubject = parser == null ? event.getSubject() : parser.parseEventSubject(event.getSubject(), eventParams); Map<String, Object> parameters = parser == null ? eventParams : parser.parseEventParameters(event.getSubject(), eventParams); List<Task> tasks = taskService.findActiveTasksForTriggerSubject(triggerSubject); for (Task task : tasks) { checkAndHandleTask(task, parameters); } }  @PostConstruct void init(); @PreDestroy void preDestroy(); @Override void registerHandlerFor(String subject); @Override void registerHandlerFor(String subject, boolean isRetryHandler); @Override @Transactional void handle(MotechEvent event); @Override @Transactional void handleRetry(MotechEvent event); @Override @Transactional void retryTask(Long activityId); @Override void addDataProvider(DataProvider provider); @Override void removeDataProvider(String taskDataProviderId); @Autowired void setBundleContext(BundleContext bundleContext); }
TaskTriggerHandler implements TriggerHandler { @Override @Transactional public void handle(MotechEvent event) { LOGGER.info("Handling the motech event with subject: {}", event.getSubject()); Map<String, Object> eventParams = event.getParameters(); eventParams.putAll(event.getMetadata()); TasksEventParser parser = null; if (eventParams != null) { parser = taskService.findCustomParser((String) eventParams.get(TasksEventParser.CUSTOM_PARSER_EVENT_KEY)); } String triggerSubject = parser == null ? event.getSubject() : parser.parseEventSubject(event.getSubject(), eventParams); Map<String, Object> parameters = parser == null ? eventParams : parser.parseEventParameters(event.getSubject(), eventParams); List<Task> tasks = taskService.findActiveTasksForTriggerSubject(triggerSubject); for (Task task : tasks) { checkAndHandleTask(task, parameters); } }  @PostConstruct void init(); @PreDestroy void preDestroy(); @Override void registerHandlerFor(String subject); @Override void registerHandlerFor(String subject, boolean isRetryHandler); @Override @Transactional void handle(MotechEvent event); @Override @Transactional void handleRetry(MotechEvent event); @Override @Transactional void retryTask(Long activityId); @Override void addDataProvider(DataProvider provider); @Override void removeDataProvider(String taskDataProviderId); @Autowired void setBundleContext(BundleContext bundleContext);  }