@Test public void replaceSubjectShouldReplaceTheSubjectWhenSubjectIsPresent() throws Exception { MimeMessage message = MimeMessageBuilder.mimeMessageBuilder() .setSubject("subject") .build(); String expectedSubject = "new subject"; new MimeMessageModifier(message).replaceSubject(Optional.of(expectedSubject)); 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);  }