@Test void extractShouldReturnHtmlAndTextWhenMultipartMixedAndFirstPartIsMultipartAlternative() throws IOException { BodyPart multipartAlternative = BodyPartBuilder.create() .setBody(MultipartBuilder.create("alternative") .addBodyPart(htmlPart) .addBodyPart(textPart) .build()) .build(); Multipart multipartMixed = MultipartBuilder.create("mixed") .addBodyPart(multipartAlternative) .build(); Message message = Message.Builder.of() .setBody(multipartMixed) .build(); MessageContent actual = testee.extract(message); assertThat(actual.getTextBody()).contains(TEXT_CONTENT); assertThat(actual.getHtmlBody()).contains(HTML_CONTENT); }
public MessageContent extract(org.apache.james.mime4j.dom.Message message) throws IOException { Body body = message.getBody(); if (body instanceof TextBody) { return parseTextBody(message, (TextBody)body); } if (body instanceof Multipart) { return parseMultipart(message, (Multipart)body); } return MessageContent.empty(); }
MessageContentExtractor { public MessageContent extract(org.apache.james.mime4j.dom.Message message) throws IOException { Body body = message.getBody(); if (body instanceof TextBody) { return parseTextBody(message, (TextBody)body); } if (body instanceof Multipart) { return parseMultipart(message, (Multipart)body); } return MessageContent.empty(); } }
MessageContentExtractor { public MessageContent extract(org.apache.james.mime4j.dom.Message message) throws IOException { Body body = message.getBody(); if (body instanceof TextBody) { return parseTextBody(message, (TextBody)body); } if (body instanceof Multipart) { return parseMultipart(message, (Multipart)body); } return MessageContent.empty(); }  }
MessageContentExtractor { public MessageContent extract(org.apache.james.mime4j.dom.Message message) throws IOException { Body body = message.getBody(); if (body instanceof TextBody) { return parseTextBody(message, (TextBody)body); } if (body instanceof Multipart) { return parseMultipart(message, (Multipart)body); } return MessageContent.empty(); }  MessageContent extract(org.apache.james.mime4j.dom.Message message); }
MessageContentExtractor { public MessageContent extract(org.apache.james.mime4j.dom.Message message) throws IOException { Body body = message.getBody(); if (body instanceof TextBody) { return parseTextBody(message, (TextBody)body); } if (body instanceof Multipart) { return parseMultipart(message, (Multipart)body); } return MessageContent.empty(); }  MessageContent extract(org.apache.james.mime4j.dom.Message message); static final String CONTENT_ID; static final String MULTIPART_ALTERNATIVE; static final String TEXT_HTML; static final String TEXT_PLAIN; }