MimeMessageUtils { public List<Header> toHeaderList() throws MessagingException { ImmutableList.Builder<Header> headers = ImmutableList.builder(); Enumeration<Header> allHeaders = message.getAllHeaders(); while (allHeaders.hasMoreElements()) { headers.add(allHeaders.nextElement()); } return headers.build(); } MimeMessageUtils(MimeMessage message); Optional<String> subjectWithPrefix(String subjectPrefix); Optional<String> subjectWithPrefix(String subjectPrefix, Mail originalMail, String subject); String getMessageHeaders(); List<Header> toHeaderList();  }
@Test public void toHeaderListShouldReturnMessageIdAndMimeVersionByDefault() throws Exception { assertThat( new MimeMessageUtils(MimeMessageBuilder.mimeMessageBuilder() .build()) .toHeaderList()) .extracting("name") .contains("Message-Id", "MIME-Version"); }
@Test public void toHeaderListShouldReturnAllMessageHeaders() throws Exception { String headerName = "X-OPENPAAS-FEATURE-1"; assertThat( new MimeMessageUtils(MimeMessageBuilder.mimeMessageBuilder() .addHeader(headerName, "value") .build()) .toHeaderList()) .extracting("name") .containsOnly("Message-Id", "MIME-Version", headerName, "Date", "Content-Type", "Content-Transfer-Encoding"); }