@Test public void testExecuteDiscard() throws MessagingException, IOException { mockery.checking(new Expectations() { { allowing(message).getFrom(); will(returnValue(new Address[] { new InternetAddress(SENDER_ADDRESS) })); allowing(message).getRecipients(RecipientType.TO); will(returnValue(new Address[] { new InternetAddress(SYSTEM_ADDRESS) })); } }); assertFalse(sut.execute(message, responseMessages)); mockery.assertIsSatisfied(); }
public boolean execute(final Message message, final List<Message> inResponseMessages) throws MessagingException, IOException { String token = getToken(message); if (token == null) { return false; } String fromAddress = getFromAddress(message); DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName("TokenAddressMessageAuthenticator"); transDef.setReadOnly(false); TransactionStatus transStatus = transactionMgr.getTransaction(transDef); byte[] key; Long personId; PersonModelView person; try { personId = personIdByEmailDao.execute(fromAddress); key = userKeyByIdDao.execute(personId); person = personDao.execute(personId); } finally { transactionMgr.commit(transStatus); } Map<String, Long> tokenData = getTokenData(token, key); String content = messageContentExtractor.extract(message); UserActionRequest actionSelection = actionSelector.select(tokenData, content, person); executeAction(message, actionSelection, person, inResponseMessages); return true; }
MessageProcessor { public boolean execute(final Message message, final List<Message> inResponseMessages) throws MessagingException, IOException { String token = getToken(message); if (token == null) { return false; } String fromAddress = getFromAddress(message); DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName("TokenAddressMessageAuthenticator"); transDef.setReadOnly(false); TransactionStatus transStatus = transactionMgr.getTransaction(transDef); byte[] key; Long personId; PersonModelView person; try { personId = personIdByEmailDao.execute(fromAddress); key = userKeyByIdDao.execute(personId); person = personDao.execute(personId); } finally { transactionMgr.commit(transStatus); } Map<String, Long> tokenData = getTokenData(token, key); String content = messageContentExtractor.extract(message); UserActionRequest actionSelection = actionSelector.select(tokenData, content, person); executeAction(message, actionSelection, person, inResponseMessages); return true; } }
MessageProcessor { public boolean execute(final Message message, final List<Message> inResponseMessages) throws MessagingException, IOException { String token = getToken(message); if (token == null) { return false; } String fromAddress = getFromAddress(message); DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName("TokenAddressMessageAuthenticator"); transDef.setReadOnly(false); TransactionStatus transStatus = transactionMgr.getTransaction(transDef); byte[] key; Long personId; PersonModelView person; try { personId = personIdByEmailDao.execute(fromAddress); key = userKeyByIdDao.execute(personId); person = personDao.execute(personId); } finally { transactionMgr.commit(transStatus); } Map<String, Long> tokenData = getTokenData(token, key); String content = messageContentExtractor.extract(message); UserActionRequest actionSelection = actionSelector.select(tokenData, content, person); executeAction(message, actionSelection, person, inResponseMessages); return true; } 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 { public boolean execute(final Message message, final List<Message> inResponseMessages) throws MessagingException, IOException { String token = getToken(message); if (token == null) { return false; } String fromAddress = getFromAddress(message); DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName("TokenAddressMessageAuthenticator"); transDef.setReadOnly(false); TransactionStatus transStatus = transactionMgr.getTransaction(transDef); byte[] key; Long personId; PersonModelView person; try { personId = personIdByEmailDao.execute(fromAddress); key = userKeyByIdDao.execute(personId); person = personDao.execute(personId); } finally { transactionMgr.commit(transStatus); } Map<String, Long> tokenData = getTokenData(token, key); String content = messageContentExtractor.extract(message); UserActionRequest actionSelection = actionSelector.select(tokenData, content, person); executeAction(message, actionSelection, person, inResponseMessages); return true; } 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 { public boolean execute(final Message message, final List<Message> inResponseMessages) throws MessagingException, IOException { String token = getToken(message); if (token == null) { return false; } String fromAddress = getFromAddress(message); DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName("TokenAddressMessageAuthenticator"); transDef.setReadOnly(false); TransactionStatus transStatus = transactionMgr.getTransaction(transDef); byte[] key; Long personId; PersonModelView person; try { personId = personIdByEmailDao.execute(fromAddress); key = userKeyByIdDao.execute(personId); person = personDao.execute(personId); } finally { transactionMgr.commit(transStatus); } Map<String, Long> tokenData = getTokenData(token, key); String content = messageContentExtractor.extract(message); UserActionRequest actionSelection = actionSelector.select(tokenData, content, person); executeAction(message, actionSelection, person, inResponseMessages); return true; } 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);  }