@Test(expected = ActionNotFoundException.class) public void shouldThrowActionNotFoundException() throws ActionNotFoundException { List<ActionEvent> actionEvents = new ArrayList<>(); actionEvents.add(new ActionEventBuilder().build()); Channel c = new Channel(); c.setActionTaskEvents(actionEvents); when(channelService.getChannel("test-action")).thenReturn(c); taskService.getActionEventFor(action); }
@Override @Transactional public ActionEvent getActionEventFor(TaskActionInformation taskActionInformation) throws ActionNotFoundException { Channel channel = channelService.getChannel(taskActionInformation.getModuleName()); ActionEvent event = null; for (ActionEvent action : channel.getActionTaskEvents()) { if (action.accept(taskActionInformation)) { event = action; break; } } if (event == null) { throw new ActionNotFoundException(format( "Cant find action on the basic of information: %s", taskActionInformation )); } return event; }
TaskServiceImpl implements TaskService { @Override @Transactional public ActionEvent getActionEventFor(TaskActionInformation taskActionInformation) throws ActionNotFoundException { Channel channel = channelService.getChannel(taskActionInformation.getModuleName()); ActionEvent event = null; for (ActionEvent action : channel.getActionTaskEvents()) { if (action.accept(taskActionInformation)) { event = action; break; } } if (event == null) { throw new ActionNotFoundException(format( "Cant find action on the basic of information: %s", taskActionInformation )); } return event; } }
TaskServiceImpl implements TaskService { @Override @Transactional public ActionEvent getActionEventFor(TaskActionInformation taskActionInformation) throws ActionNotFoundException { Channel channel = channelService.getChannel(taskActionInformation.getModuleName()); ActionEvent event = null; for (ActionEvent action : channel.getActionTaskEvents()) { if (action.accept(taskActionInformation)) { event = action; break; } } if (event == null) { throw new ActionNotFoundException(format( "Cant find action on the basic of information: %s", taskActionInformation )); } return event; }  }
TaskServiceImpl implements TaskService { @Override @Transactional public ActionEvent getActionEventFor(TaskActionInformation taskActionInformation) throws ActionNotFoundException { Channel channel = channelService.getChannel(taskActionInformation.getModuleName()); ActionEvent event = null; for (ActionEvent action : channel.getActionTaskEvents()) { if (action.accept(taskActionInformation)) { event = action; break; } } if (event == null) { throw new ActionNotFoundException(format( "Cant find action on the basic of information: %s", taskActionInformation )); } return event; }  @Override @Transactional Set<TaskError> save(final Task task); @Override @Transactional void setEnabledOrDisabled(final Task task); @Override @Transactional ActionEvent getActionEventFor(TaskActionInformation taskActionInformation); @Override @Transactional List<Task> getAllTasks(); @Override @Transactional List<Task> findTasksByName(String name); @Override @Transactional List<Task> findActiveTasksForTrigger(final TriggerEvent trigger); @Override @Transactional List<Task> findActiveTasksForTriggerSubject(final String subject); @Override TasksEventParser findCustomParser(String name); @Override @Transactional Task getTask(Long taskId); @Override @Transactional void deleteTask(Long taskId); @MotechListener(subjects = CHANNEL_UPDATE_SUBJECT) @Transactional void validateTasksAfterChannelUpdate(MotechEvent event); @MotechListener(subjects = DATA_PROVIDER_UPDATE_SUBJECT) @Transactional void validateTasksAfterTaskDataProviderUpdate(MotechEvent event); @Override @Transactional String exportTask(Long taskId); @Override @Transactional Task importTask(String json); @Override @Transactional List<Task> findTasksDependentOnModule(final String moduleName); @Autowired void setTasksDataService(TasksDataService tasksDataService); @Autowired void setChannelService(ChannelService channelService); @Autowired void setProviderService(TaskDataProviderService providerService); @Autowired void setEventRelay(EventRelay eventRelay); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setTaskValidator(TaskValidator taskValidator); @Autowired void setTriggerEventService(TriggerEventService triggerEventService); @Autowired void setTaskMigrationManager(TaskMigrationManager taskMigrationManager); }
TaskServiceImpl implements TaskService { @Override @Transactional public ActionEvent getActionEventFor(TaskActionInformation taskActionInformation) throws ActionNotFoundException { Channel channel = channelService.getChannel(taskActionInformation.getModuleName()); ActionEvent event = null; for (ActionEvent action : channel.getActionTaskEvents()) { if (action.accept(taskActionInformation)) { event = action; break; } } if (event == null) { throw new ActionNotFoundException(format( "Cant find action on the basic of information: %s", taskActionInformation )); } return event; }  @Override @Transactional Set<TaskError> save(final Task task); @Override @Transactional void setEnabledOrDisabled(final Task task); @Override @Transactional ActionEvent getActionEventFor(TaskActionInformation taskActionInformation); @Override @Transactional List<Task> getAllTasks(); @Override @Transactional List<Task> findTasksByName(String name); @Override @Transactional List<Task> findActiveTasksForTrigger(final TriggerEvent trigger); @Override @Transactional List<Task> findActiveTasksForTriggerSubject(final String subject); @Override TasksEventParser findCustomParser(String name); @Override @Transactional Task getTask(Long taskId); @Override @Transactional void deleteTask(Long taskId); @MotechListener(subjects = CHANNEL_UPDATE_SUBJECT) @Transactional void validateTasksAfterChannelUpdate(MotechEvent event); @MotechListener(subjects = DATA_PROVIDER_UPDATE_SUBJECT) @Transactional void validateTasksAfterTaskDataProviderUpdate(MotechEvent event); @Override @Transactional String exportTask(Long taskId); @Override @Transactional Task importTask(String json); @Override @Transactional List<Task> findTasksDependentOnModule(final String moduleName); @Autowired void setTasksDataService(TasksDataService tasksDataService); @Autowired void setChannelService(ChannelService channelService); @Autowired void setProviderService(TaskDataProviderService providerService); @Autowired void setEventRelay(EventRelay eventRelay); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setTaskValidator(TaskValidator taskValidator); @Autowired void setTriggerEventService(TriggerEventService triggerEventService); @Autowired void setTaskMigrationManager(TaskMigrationManager taskMigrationManager); static final List<String> IGNORED_FIELDS; }