EmailMessageCreator { public EmailMessage createMessage() { final EmailMessage message = new EmailMessage( this.mailHost, this.mailPort, this.mailUser, this.mailPassword, this); message.setFromAddress(this.mailSender); message.setTLS(this.tls); message.setAuth(this.usesAuth); return message; } @Inject  EmailMessageCreator(final Props props); EmailMessage createMessage(); JavaxMailSender createSender(final Properties props); static final int DEFAULT_SMTP_PORT; }
@Test public void createMessage() { final Props props = new Props(); props.put("mail.user", USER); props.put("mail.password", PASSWORD); props.put("mail.sender", SENDER); props.put("mail.host", HOST); props.put("mail.port", MAIL_PORT); final EmailMessageCreator creator = new EmailMessageCreator(props); final EmailMessage message = creator.createMessage(); assertThat(message.getMailPort()).isEqualTo(MAIL_PORT); assertThat(message.getBody()).isEmpty(); assertThat(message.getSubject()).isNull(); }