### Question:
MailMessageFactory { public SimpleMailMessage createMessage(String subject) { String emailReplyTo = configuration.getEmailReplyTo(); SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(configuration.getEmailFrom()); if (isEmpty(emailReplyTo)) { message.setReplyTo(emailReplyTo); } message.setSubject(subject); message.setSentDate(new Date()); return message; }  SimpleMailMessage createMessage(String subject);  }### Answer:
@Test public void subject_contained_and_date() { SimpleMailMessage message = factoryToTest.createMessage("subject1"); assertEquals("subject1",message.getSubject()); assertNotNull(message.getSentDate()); }
@Test public void noreply_set_is_also_in_message() { when(mockedConfiguration.getEmailReplyTo()).thenReturn("reply1"); SimpleMailMessage message = factoryToTest.createMessage("subject1"); assertEquals("reply1", message.getReplyTo()); }
@Test public void no_noreply_set_is_also_not_in_message() { when(mockedConfiguration.getEmailReplyTo()).thenReturn(null); SimpleMailMessage message = factoryToTest.createMessage("subject1"); assertEquals(null, message.getReplyTo()); }