public AbstractEntityBuilder setBody(SingleBodyBuilder body) throws IOException { return this.setBody(body.build()); }
public SingleBody build() throws IOException { if (this.charset != null) { return buildText(); } else { return buildBinary(); } }
public static SingleBodyBuilder createCopy(final SingleBody other) throws IOException { return new SingleBodyBuilder().copy(other); }
@Test public void getMessageListFileNameFilterShouldNotReturnMessagesWithOnlyAttachmentContentMatching() throws Exception { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, ALICE, "mailbox"); mailboxProbe.appendMessage(ALICE, MailboxPath.forUser(ALICE, "mailbox"), MessageManager.AppendCommand.builder() .build(Message.Builder.of() .setBody( MultipartBuilder.create("alternative") .addBodyPart(BodyPartBuilder.create() .setContentDisposition("attachment", "nomatch.md") .setBody(SingleBodyBuilder.create() .setText("matchme.txt ...") .setCharset(StandardCharsets.UTF_8) .build()) .build()) .build()))); await(); given() .header("Authorization", aliceAccessToken.serialize()) .body("[[\"getMessageList\", {\"filter\":{\"attachmentFileName\":\"matchme.txt\"}}, \"#0\"]]") .when() .post("/jmap") .then() .statusCode(200) .body(NAME, equalTo("messageList")) .body(ARGUMENTS + ".messageIds", hasSize(0)); }
@Test public void extractReportShouldExtractMDNWhenValidMDN() throws IOException { ExtractMDNOriginalJMAPMessageId testee = new ExtractMDNOriginalJMAPMessageId(mock(MailboxManager.class)); BodyPart mdn = BodyPartBuilder .create() .setBody(SingleBodyBuilder.create() .setText( "Reporting-UA: linagora.com; Evolution 3.26.5-1+b1 \n" + "Final-Recipient: rfc822; homer@linagora.com\n" + "Original-Message-ID: <1521557867.2614.0.camel@apache.org>\n" + "Disposition: manual-action/MDN-sent-manually;displayed\n") .buildText()) .setContentType("message/disposition-notification") .build(); Message message = Message.Builder.of() .setBody(MultipartBuilder.create("report") .addTextPart("first", StandardCharsets.UTF_8) .addBodyPart(mdn) .build()) .build(); assertThat(testee.extractReport(message)) .isNotEmpty() .contains(mdn); } }
public static SingleBodyBuilder create() { return new SingleBodyBuilder(); }
.addBodyPart(BodyPartBuilder.create() .setContentDisposition("attachment", "matchme.txt") .setBody(SingleBodyBuilder.create() .setText("this is the file content...") .setCharset(StandardCharsets.UTF_8) .build()) .build()) .build())));
.addBodyPart(BodyPartBuilder.create() .setContentDisposition("attachment", "matchme.txt") .setBody(SingleBodyBuilder.create() .setText("this is the file content...") .setCharset(StandardCharsets.UTF_8) .build()) .build()) .build())));