@Test public void testExecute() throws Exception { context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue(new SendWelcomeEmailRequest("somebody@example.com", "somebody1"))); oneOf(emailerFactory).createMessage(); will(returnValue(message)); oneOf(emailerFactory).setTo(message, "somebody@example.com"); oneOf(emailerFactory).setSubject(message, "welcome subject"); oneOf(emailerFactory).setHtmlBody(message, "welcome body with http: oneOf(emailerFactory).sendMail(message); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
@Override public Boolean execute(final ActionContext inActionContext) { SendWelcomeEmailRequest request = (SendWelcomeEmailRequest) inActionContext.getParams(); String emailAddress = request.getEmailAddress(); String accountId = request.getAccountId(); if (emailAddress != null && emailAddress != "") { try { MimeMessage msg = emailerFactory.createMessage(); emailerFactory.setTo(msg, emailAddress); emailerFactory.setSubject(msg, subject); emailerFactory.setHtmlBody(msg, body.replace("$(url)", baseUrl + "#people/" + accountId)); emailerFactory.sendMail(msg); if (log.isInfoEnabled()) { log.info("New user email sent to: " + emailAddress); } } catch (MessagingException ex) { log.error("Failed to send new user email to: " + emailAddress); } } return Boolean.TRUE; }
SendWelcomeEmailExecution implements ExecutionStrategy<ActionContext> { @Override public Boolean execute(final ActionContext inActionContext) { SendWelcomeEmailRequest request = (SendWelcomeEmailRequest) inActionContext.getParams(); String emailAddress = request.getEmailAddress(); String accountId = request.getAccountId(); if (emailAddress != null && emailAddress != "") { try { MimeMessage msg = emailerFactory.createMessage(); emailerFactory.setTo(msg, emailAddress); emailerFactory.setSubject(msg, subject); emailerFactory.setHtmlBody(msg, body.replace("$(url)", baseUrl + "#people/" + accountId)); emailerFactory.sendMail(msg); if (log.isInfoEnabled()) { log.info("New user email sent to: " + emailAddress); } } catch (MessagingException ex) { log.error("Failed to send new user email to: " + emailAddress); } } return Boolean.TRUE; } }
SendWelcomeEmailExecution implements ExecutionStrategy<ActionContext> { @Override public Boolean execute(final ActionContext inActionContext) { SendWelcomeEmailRequest request = (SendWelcomeEmailRequest) inActionContext.getParams(); String emailAddress = request.getEmailAddress(); String accountId = request.getAccountId(); if (emailAddress != null && emailAddress != "") { try { MimeMessage msg = emailerFactory.createMessage(); emailerFactory.setTo(msg, emailAddress); emailerFactory.setSubject(msg, subject); emailerFactory.setHtmlBody(msg, body.replace("$(url)", baseUrl + "#people/" + accountId)); emailerFactory.sendMail(msg); if (log.isInfoEnabled()) { log.info("New user email sent to: " + emailAddress); } } catch (MessagingException ex) { log.error("Failed to send new user email to: " + emailAddress); } } return Boolean.TRUE; } SendWelcomeEmailExecution(final EmailerFactory inEmailerFactory, final String inBaseUrl,
            final String inSubject, final String inBody); }
SendWelcomeEmailExecution implements ExecutionStrategy<ActionContext> { @Override public Boolean execute(final ActionContext inActionContext) { SendWelcomeEmailRequest request = (SendWelcomeEmailRequest) inActionContext.getParams(); String emailAddress = request.getEmailAddress(); String accountId = request.getAccountId(); if (emailAddress != null && emailAddress != "") { try { MimeMessage msg = emailerFactory.createMessage(); emailerFactory.setTo(msg, emailAddress); emailerFactory.setSubject(msg, subject); emailerFactory.setHtmlBody(msg, body.replace("$(url)", baseUrl + "#people/" + accountId)); emailerFactory.sendMail(msg); if (log.isInfoEnabled()) { log.info("New user email sent to: " + emailAddress); } } catch (MessagingException ex) { log.error("Failed to send new user email to: " + emailAddress); } } return Boolean.TRUE; } SendWelcomeEmailExecution(final EmailerFactory inEmailerFactory, final String inBaseUrl,
            final String inSubject, final String inBody); @Override Boolean execute(final ActionContext inActionContext); }
SendWelcomeEmailExecution implements ExecutionStrategy<ActionContext> { @Override public Boolean execute(final ActionContext inActionContext) { SendWelcomeEmailRequest request = (SendWelcomeEmailRequest) inActionContext.getParams(); String emailAddress = request.getEmailAddress(); String accountId = request.getAccountId(); if (emailAddress != null && emailAddress != "") { try { MimeMessage msg = emailerFactory.createMessage(); emailerFactory.setTo(msg, emailAddress); emailerFactory.setSubject(msg, subject); emailerFactory.setHtmlBody(msg, body.replace("$(url)", baseUrl + "#people/" + accountId)); emailerFactory.sendMail(msg); if (log.isInfoEnabled()) { log.info("New user email sent to: " + emailAddress); } } catch (MessagingException ex) { log.error("Failed to send new user email to: " + emailAddress); } } return Boolean.TRUE; } SendWelcomeEmailExecution(final EmailerFactory inEmailerFactory, final String inBaseUrl,
            final String inSubject, final String inBody); @Override Boolean execute(final ActionContext inActionContext);  }