List of usage examples for javax.mail Flags Flags
public Flags()
From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java
@Test public void getMessageListShouldReturnLimitMessagesWhenLimitGiven() throws Exception { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); LocalDate date = LocalDate.now(); ComposedMessageId message = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new Flags()); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags()); await();/*from w ww.j a v a 2 s .c o m*/ given().header("Authorization", accessToken.serialize()) .body("[[\"getMessageList\", {\"limit\":1}, \"#0\"]]").when().post("/jmap").then().statusCode(200) .body(NAME, equalTo("messageList")) .body(ARGUMENTS + ".messageIds", contains(message.getMessageId().serialize())); }
From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java
@Test public void getMessageListShouldReturnLimitMessagesWithDefaultValueWhenLimitIsNotGiven() throws Exception { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); LocalDate date = LocalDate.now(); ComposedMessageId message1 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new Flags()); ComposedMessageId message2 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags()); ComposedMessageId message3 = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test3\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags()); mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test4\r\n\r\ntestmail".getBytes()), convertToDate(date), false, new Flags()); await();/*from w w w . j ava 2 s. c o m*/ given().header("Authorization", accessToken.serialize()).body("[[\"getMessageList\", {}, \"#0\"]]").when() .post("/jmap").then().statusCode(200).body(NAME, equalTo("messageList")) .body(ARGUMENTS + ".messageIds", containsInAnyOrder(message1.getMessageId().serialize(), message2.getMessageId().serialize(), message3.getMessageId().serialize())); }
From source file:org.apache.james.jmap.methods.integration.GetMessageListMethodTest.java
@Test public void getMessageListShouldChainFetchingMessagesWhenAskedFor() throws Exception { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox"); LocalDate date = LocalDate.now(); ComposedMessageId message = mailboxProbe.appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), convertToDate(date.plusDays(1)), false, new Flags()); await();//from w w w . ja v a2 s .c o m given().header("Authorization", accessToken.serialize()) .body("[[\"getMessageList\", {\"fetchMessages\":true}, \"#0\"]]").when().post("/jmap").then() .statusCode(200).body("[0][0]", equalTo("messageList")).body("[1][0]", equalTo("messages")) .body("[0][1].messageIds", hasSize(1)) .body("[0][1].messageIds[0]", equalTo(message.getMessageId().serialize())) .body("[1][1].list", hasSize(1)) .body("[1][1].list[0].id", equalTo(message.getMessageId().serialize())); }
From source file:org.apache.james.jmap.methods.integration.SetMessagesMethodTest.java
@Test public void movingAMessageIsNotSupported() throws Exception { String newMailboxName = "heartFolder"; jmapServer.serverProbe().createMailbox("#private", username, newMailboxName); Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", username, newMailboxName); String heartFolderId = heartFolder.getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); jmapServer.serverProbe().appendMessage(username, new MailboxPath("#private", username, "inbox"), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = "user|inbox|1"; String requestBody = "[" + " [" + " \"setMessages\"," + " {" + " \"update\": { \"" + messageToMoveId + "\" : {" + " \"mailboxIds\": [\"" + heartFolderId + "\"]" + " }}" + " }," + " \"#0\"" + " ]" + "]"; given().header("Authorization", this.accessToken.serialize()).body(requestBody).when().post("/jmap").then() .statusCode(200).body(NAME, equalTo("messagesSet")).body(NOT_UPDATED, hasKey(messageToMoveId)) .body(NOT_UPDATED + "[\"" + messageToMoveId + "\"].type", equalTo("invalidProperties")) .body(NOT_UPDATED + "[\"" + messageToMoveId + "\"].properties[0]", equalTo("mailboxIds")) .body(NOT_UPDATED + "[\"" + messageToMoveId + "\"].description", equalTo("mailboxIds: moving a message is not supported " + "(through reference chain: org.apache.james.jmap.model.Builder[\"mailboxIds\"])")) .body(ARGUMENTS + ".updated", hasSize(0)); }