JAMES-2213 Allow createMessage and updateMessage with isForwarded and later can retrieve message with isForwarded value
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/35b1d121 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/35b1d121 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/35b1d121 Branch: refs/heads/master Commit: 35b1d1219927a4c8df8c8c872704184edc4df945 Parents: a345a32 Author: quynhn <qngu...@linagora.com> Authored: Mon Nov 13 15:12:15 2017 +0700 Committer: quynhn <qngu...@linagora.com> Committed: Tue Nov 14 10:27:40 2017 +0700 ---------------------------------------------------------------------- .../integration/SetMessagesMethodTest.java | 47 ++++++++++++++++++++ .../org/apache/james/jmap/model/Message.java | 4 ++ .../james/jmap/model/MessageProperties.java | 1 + .../james/jmap/json/ParsingWritingObjects.java | 2 +- .../james/jmap/model/MessageFactoryTest.java | 6 +-- .../jmap/src/test/resources/json/message.json | 3 +- 6 files changed, 58 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/35b1d121/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java index d72a60e..6e74189 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java @@ -994,6 +994,53 @@ public abstract class SetMessagesMethodTest { .body(ARGUMENTS + ".list[0].isAnswered", equalTo(true)); } + + @Test + public void setMessagesShouldMarkMessageAsForwardWhenIsForwardedPassed() throws MailboxException { + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "mailbox"); + + ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, USER_MAILBOX, + new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), new Date(), false, new Flags()); + await(); + + String serializedMessageId = message.getMessageId().serialize(); + + given() + .header("Authorization", accessToken.serialize()) + .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isForwarded\" : true } } }, \"#0\"]]", serializedMessageId)) + .when() + .post("/jmap") + .then() + .log().ifValidationFails() + .spec(getSetMessagesUpdateOKResponseAssertions(serializedMessageId)); + } + + @Test + public void setMessagesShouldMarkAsForwardedWhenIsForwardedPassed() throws MailboxException { + mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "mailbox"); + + ComposedMessageId message = mailboxProbe.appendMessage(USERNAME, USER_MAILBOX, + new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), new Date(), false, new Flags()); + await(); + + String serializedMessageId = message.getMessageId().serialize(); + given() + .header("Authorization", accessToken.serialize()) + .body(String.format("[[\"setMessages\", {\"update\": {\"%s\" : { \"isForwarded\" : true } } }, \"#0\"]]", serializedMessageId)) + .when() + .post("/jmap"); + + with() + .header("Authorization", accessToken.serialize()) + .body("[[\"getMessages\", {\"ids\": [\"" + serializedMessageId + "\"]}, \"#0\"]]") + .post("/jmap") + .then() + .log().ifValidationFails() + .body(NAME, equalTo("messages")) + .body(ARGUMENTS + ".list", hasSize(1)) + .body(ARGUMENTS + ".list[0].isForwarded", equalTo(true)); + } + @Test public void setMessagesShouldReturnNotFoundWhenUpdateUnknownMessage() { mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "mailbox"); http://git-wip-us.apache.org/repos/asf/james-project/blob/35b1d121/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java index 797d191..557e99f 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Message.java @@ -332,6 +332,10 @@ public class Message { return keywords.contains(Keyword.DRAFT); } + public boolean isIsForwarded() { + return keywords.contains(Keyword.FORWARDED); + } + public boolean isHasAttachment() { return hasAttachment; } http://git-wip-us.apache.org/repos/asf/james-project/blob/35b1d121/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java index bf1bff5..ca71165 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageProperties.java @@ -128,6 +128,7 @@ public class MessageProperties { isFlagged("isFlagged"), isAnswered("isAnswered"), isDraft("isDraft"), + isForwarded("isForwarded"), hasAttachment("hasAttachment"), headers("headers"), from("from"), http://git-wip-us.apache.org/repos/asf/james-project/blob/35b1d121/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjects.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjects.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjects.java index 7a7a04e..b81731a 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjects.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjects.java @@ -51,7 +51,7 @@ public interface ParsingWritingObjects { Flags FLAGS = FlagsBuilder.builder() .add(Flags.Flag.FLAGGED, Flags.Flag.ANSWERED, Flags.Flag.DRAFT, Flags.Flag.SEEN) .build(); - ImmutableSet<Keyword> KEYWORDS = ImmutableSet.of(Keyword.DRAFT, Keyword.FLAGGED, Keyword.ANSWERED, Keyword.SEEN); + ImmutableSet<Keyword> KEYWORDS = ImmutableSet.of(Keyword.DRAFT, Keyword.FLAGGED, Keyword.ANSWERED, Keyword.SEEN, Keyword.FORWARDED); boolean HAS_ATTACHMENT = true; ImmutableMap<String, String> HEADERS = ImmutableMap.of("h1", "h1Value", "h2", "h2Value"); Emailer FROM = Emailer.builder().name("myName").email("myem...@james.org").build(); http://git-wip-us.apache.org/repos/asf/james-project/blob/35b1d121/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java index 5637620..434ca06 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java @@ -90,7 +90,7 @@ public class MessageFactoryTest { public void flagsShouldBeSetIntoMessage() throws Exception { MetaDataWithContent testMail = MetaDataWithContent.builder() .uid(MessageUid.of(2)) - .keywords(Keywords.factory().from(Keyword.ANSWERED, Keyword.FLAGGED, Keyword.DRAFT)) + .keywords(Keywords.factory().from(Keyword.ANSWERED, Keyword.FLAGGED, Keyword.DRAFT, Keyword.FORWARDED)) .size(0) .internalDate(INTERNAL_DATE) .content(new ByteArrayInputStream("".getBytes(Charsets.UTF_8))) @@ -100,8 +100,8 @@ public class MessageFactoryTest { .build(); Message testee = messageFactory.fromMetaDataWithContent(testMail); assertThat(testee) - .extracting(Message::isIsUnread, Message::isIsFlagged, Message::isIsAnswered, Message::isIsDraft) - .containsExactly(true, true, true, true); + .extracting(Message::isIsUnread, Message::isIsFlagged, Message::isIsAnswered, Message::isIsDraft, Message::isIsForwarded) + .containsExactly(true, true, true, true, true); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/35b1d121/server/protocols/jmap/src/test/resources/json/message.json ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/resources/json/message.json b/server/protocols/jmap/src/test/resources/json/message.json index ba0c82f..264c6fb 100644 --- a/server/protocols/jmap/src/test/resources/json/message.json +++ b/server/protocols/jmap/src/test/resources/json/message.json @@ -8,6 +8,7 @@ "isFlagged": true, "isAnswered": true, "isDraft": true, + "isForwarded": true, "hasAttachment": false, "headers": { "h1": "h1Value", "h2": "h2Value" }, "from": { "name": "myName", "email": "myem...@james.org"}, @@ -23,5 +24,5 @@ "htmlBody": "<h1>myHtmlBody</h1>", "attachments": [ ], "attachedMessages": { }, - "keywords": {"$Draft" : true, "$Flagged" : true, "$Answered" : true, "$Seen" : true} + "keywords": {"$Draft" : true, "$Flagged" : true, "$Answered" : true, "$Seen" : true, "$Forwarded" : true} } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org