@Test public void shouldEmail() { MailSenderFactory mailSenderFactory = createMock(MailSenderFactory.class); JavaMailSender sender = createMock(JavaMailSender.class); expect(mailSenderFactory.mailSender()).andReturn(sender); sender.send(equalsMessage(expectedMessage())); expectLastCall(); Email mail = new Email("abc@abc.com", "xyz@xyz.com", "Hi", "Hello World"); replay(mailSenderFactory,sender); new MailingServiceImpl(mailSenderFactory).send(mail); verify(mailSenderFactory,sender); }
public void send(Email mail) { SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setTo(mail.to()); mailMessage.setFrom(mail.from()); mailMessage.setSubject(mail.subject()); mailMessage.setText(mail.text()); mailSenderFactory.mailSender().send(mailMessage); }
MailingServiceImpl implements MailingService { public void send(Email mail) { SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setTo(mail.to()); mailMessage.setFrom(mail.from()); mailMessage.setSubject(mail.subject()); mailMessage.setText(mail.text()); mailSenderFactory.mailSender().send(mailMessage); } }
MailingServiceImpl implements MailingService { public void send(Email mail) { SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setTo(mail.to()); mailMessage.setFrom(mail.from()); mailMessage.setSubject(mail.subject()); mailMessage.setText(mail.text()); mailSenderFactory.mailSender().send(mailMessage); } MailingServiceImpl(MailSenderFactory mailSenderFactory); }
MailingServiceImpl implements MailingService { public void send(Email mail) { SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setTo(mail.to()); mailMessage.setFrom(mail.from()); mailMessage.setSubject(mail.subject()); mailMessage.setText(mail.text()); mailSenderFactory.mailSender().send(mailMessage); } MailingServiceImpl(MailSenderFactory mailSenderFactory); void send(Email mail); }
MailingServiceImpl implements MailingService { public void send(Email mail) { SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setTo(mail.to()); mailMessage.setFrom(mail.from()); mailMessage.setSubject(mail.subject()); mailMessage.setText(mail.text()); mailSenderFactory.mailSender().send(mailMessage); } MailingServiceImpl(MailSenderFactory mailSenderFactory); void send(Email mail);  }