use of org.motechproject.tasks.exception.ActionNotFoundException in project motech by motech.
the class TaskTriggerHandlerTest method shouldHandleErrorWhenActionIsNotFound.
@Test
public void shouldHandleErrorWhenActionIsNotFound() throws Exception {
setTriggerEvent();
when(taskService.findActiveTasksForTriggerSubject(TRIGGER_SUBJECT)).thenReturn(tasks);
when(taskService.getActionEventFor(task.getActions().get(0))).thenThrow(new ActionNotFoundException(""));
handler.handle(createEvent());
verifyErrorHandling("task.error.actionNotFound");
}
use of org.motechproject.tasks.exception.ActionNotFoundException in project motech by motech.
the class TaskServiceImpl method getActionEventFor.
@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;
}
Aggregations