@Test public void replaceSubjectShouldNotAlterTheSubjectWhenSubjectIsAbsent() throws Exception { String expectedSubject = "subject"; MimeMessage message = MimeMessageBuilder.mimeMessageBuilder() .setSubject(expectedSubject) .build(); new MimeMessageModifier(message).replaceSubject(Optional.empty()); assertThat(message.getSubject()).isEqualTo(expectedSubject); }
public void replaceSubject(Optional<String> newSubject) throws MessagingException { if (newSubject.isPresent()) { message.setSubject(null); message.setSubject(newSubject.get(), StandardCharsets.UTF_8.displayName()); } }
MimeMessageModifier { public void replaceSubject(Optional<String> newSubject) throws MessagingException { if (newSubject.isPresent()) { message.setSubject(null); message.setSubject(newSubject.get(), StandardCharsets.UTF_8.displayName()); } } }
MimeMessageModifier { public void replaceSubject(Optional<String> newSubject) throws MessagingException { if (newSubject.isPresent()) { message.setSubject(null); message.setSubject(newSubject.get(), StandardCharsets.UTF_8.displayName()); } } MimeMessageModifier(MimeMessage message); }
MimeMessageModifier { public void replaceSubject(Optional<String> newSubject) throws MessagingException { if (newSubject.isPresent()) { message.setSubject(null); message.setSubject(newSubject.get(), StandardCharsets.UTF_8.displayName()); } } MimeMessageModifier(MimeMessage message); void replaceSubject(Optional<String> newSubject); }
MimeMessageModifier { public void replaceSubject(Optional<String> newSubject) throws MessagingException { if (newSubject.isPresent()) { message.setSubject(null); message.setSubject(newSubject.get(), StandardCharsets.UTF_8.displayName()); } } MimeMessageModifier(MimeMessage message); void replaceSubject(Optional<String> newSubject);  }