@Test(expected = ExecutionException.class) public void testExecuteActionBadBean() { final UserActionRequest sel = new UserActionRequest(ACTION_NAME, null, ""); mockery.checking(new Expectations() { { allowing(beanFactory).getBean(ACTION_NAME); will(returnValue("")); oneOf(messageReplier).reply(with(equal(message)), with(equal(person)), with(equal(sel)), with(any(ExecutionException.class)), with(same(responseMessages))); } }); sut.executeAction(message, sel, person, responseMessages); mockery.assertIsSatisfied(); }
void executeAction(final Message message, final UserActionRequest actionSelection, final PersonModelView person, final List<Message> inResponseMessages) { try { Object springBean = beanFactory.getBean(actionSelection.getActionKey()); PrincipalActionContext actionContext = new ServiceActionContext(actionSelection.getParams(), new DefaultPrincipal(person.getAccountId(), person.getOpenSocialId(), person.getId())); actionContext.setActionId(actionSelection.getActionKey()); if (springBean instanceof ServiceAction) { ServiceAction action = (ServiceAction) springBean; serviceActionController.execute(actionContext, action); } else if (springBean instanceof TaskHandlerServiceAction) { TaskHandlerServiceAction action = (TaskHandlerServiceAction) springBean; serviceActionController.execute(actionContext, action); } else { throw new ExecutionException("Bean '" + actionSelection.getActionKey() + "' is not an executable action"); } } catch (RuntimeException ex) { messageReplier.reply(message, person, actionSelection, ex, inResponseMessages); throw ex; } }
MessageProcessor { void executeAction(final Message message, final UserActionRequest actionSelection, final PersonModelView person, final List<Message> inResponseMessages) { try { Object springBean = beanFactory.getBean(actionSelection.getActionKey()); PrincipalActionContext actionContext = new ServiceActionContext(actionSelection.getParams(), new DefaultPrincipal(person.getAccountId(), person.getOpenSocialId(), person.getId())); actionContext.setActionId(actionSelection.getActionKey()); if (springBean instanceof ServiceAction) { ServiceAction action = (ServiceAction) springBean; serviceActionController.execute(actionContext, action); } else if (springBean instanceof TaskHandlerServiceAction) { TaskHandlerServiceAction action = (TaskHandlerServiceAction) springBean; serviceActionController.execute(actionContext, action); } else { throw new ExecutionException("Bean '" + actionSelection.getActionKey() + "' is not an executable action"); } } catch (RuntimeException ex) { messageReplier.reply(message, person, actionSelection, ex, inResponseMessages); throw ex; } } }
MessageProcessor { void executeAction(final Message message, final UserActionRequest actionSelection, final PersonModelView person, final List<Message> inResponseMessages) { try { Object springBean = beanFactory.getBean(actionSelection.getActionKey()); PrincipalActionContext actionContext = new ServiceActionContext(actionSelection.getParams(), new DefaultPrincipal(person.getAccountId(), person.getOpenSocialId(), person.getId())); actionContext.setActionId(actionSelection.getActionKey()); if (springBean instanceof ServiceAction) { ServiceAction action = (ServiceAction) springBean; serviceActionController.execute(actionContext, action); } else if (springBean instanceof TaskHandlerServiceAction) { TaskHandlerServiceAction action = (TaskHandlerServiceAction) springBean; serviceActionController.execute(actionContext, action); } else { throw new ExecutionException("Bean '" + actionSelection.getActionKey() + "' is not an executable action"); } } catch (RuntimeException ex) { messageReplier.reply(message, person, actionSelection, ex, inResponseMessages); throw ex; } } MessageProcessor(final MessageContentExtractor inMessageContentExtractor,
            final ActionSelectorFactory inActionSelector, final ActionController inServiceActionController,
            final BeanFactory inBeanFactory, final TokenEncoder inTokenEncoder,
            final TokenContentFormatter inTokenContentFormatter, final PlatformTransactionManager inTransactionMgr,
            final DomainMapper<String, Long> inPersonIdByEmailDao, final DomainMapper<Long, byte[]> inUserKeyByIdDao,
            final DomainMapper<Long, PersonModelView> inPersonDao, final MessageReplier inMessageReplier,
            final String inRequiredToAddress); }
MessageProcessor { void executeAction(final Message message, final UserActionRequest actionSelection, final PersonModelView person, final List<Message> inResponseMessages) { try { Object springBean = beanFactory.getBean(actionSelection.getActionKey()); PrincipalActionContext actionContext = new ServiceActionContext(actionSelection.getParams(), new DefaultPrincipal(person.getAccountId(), person.getOpenSocialId(), person.getId())); actionContext.setActionId(actionSelection.getActionKey()); if (springBean instanceof ServiceAction) { ServiceAction action = (ServiceAction) springBean; serviceActionController.execute(actionContext, action); } else if (springBean instanceof TaskHandlerServiceAction) { TaskHandlerServiceAction action = (TaskHandlerServiceAction) springBean; serviceActionController.execute(actionContext, action); } else { throw new ExecutionException("Bean '" + actionSelection.getActionKey() + "' is not an executable action"); } } catch (RuntimeException ex) { messageReplier.reply(message, person, actionSelection, ex, inResponseMessages); throw ex; } } MessageProcessor(final MessageContentExtractor inMessageContentExtractor,
            final ActionSelectorFactory inActionSelector, final ActionController inServiceActionController,
            final BeanFactory inBeanFactory, final TokenEncoder inTokenEncoder,
            final TokenContentFormatter inTokenContentFormatter, final PlatformTransactionManager inTransactionMgr,
            final DomainMapper<String, Long> inPersonIdByEmailDao, final DomainMapper<Long, byte[]> inUserKeyByIdDao,
            final DomainMapper<Long, PersonModelView> inPersonDao, final MessageReplier inMessageReplier,
            final String inRequiredToAddress); boolean execute(final Message message, final List<Message> inResponseMessages); }
MessageProcessor { void executeAction(final Message message, final UserActionRequest actionSelection, final PersonModelView person, final List<Message> inResponseMessages) { try { Object springBean = beanFactory.getBean(actionSelection.getActionKey()); PrincipalActionContext actionContext = new ServiceActionContext(actionSelection.getParams(), new DefaultPrincipal(person.getAccountId(), person.getOpenSocialId(), person.getId())); actionContext.setActionId(actionSelection.getActionKey()); if (springBean instanceof ServiceAction) { ServiceAction action = (ServiceAction) springBean; serviceActionController.execute(actionContext, action); } else if (springBean instanceof TaskHandlerServiceAction) { TaskHandlerServiceAction action = (TaskHandlerServiceAction) springBean; serviceActionController.execute(actionContext, action); } else { throw new ExecutionException("Bean '" + actionSelection.getActionKey() + "' is not an executable action"); } } catch (RuntimeException ex) { messageReplier.reply(message, person, actionSelection, ex, inResponseMessages); throw ex; } } MessageProcessor(final MessageContentExtractor inMessageContentExtractor,
            final ActionSelectorFactory inActionSelector, final ActionController inServiceActionController,
            final BeanFactory inBeanFactory, final TokenEncoder inTokenEncoder,
            final TokenContentFormatter inTokenContentFormatter, final PlatformTransactionManager inTransactionMgr,
            final DomainMapper<String, Long> inPersonIdByEmailDao, final DomainMapper<Long, byte[]> inUserKeyByIdDao,
            final DomainMapper<Long, PersonModelView> inPersonDao, final MessageReplier inMessageReplier,
            final String inRequiredToAddress); boolean execute(final Message message, final List<Message> inResponseMessages);  }