You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/08/25 08:32:41 UTC

[03/13] james-project git commit: JAMES-2110 Parser message should not care json message deserilization such as we had CreationMessage and UpdateMessagePath

JAMES-2110 Parser message should not care json message deserilization such as we had CreationMessage and UpdateMessagePath


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/53fdcbdd
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/53fdcbdd
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/53fdcbdd

Branch: refs/heads/master
Commit: 53fdcbdd86d35e55d075fa0ad79ebd69b11ec735
Parents: 20beee7
Author: quynhn <qn...@linagora.com>
Authored: Tue Aug 15 16:35:50 2017 +0700
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Thu Aug 24 15:47:27 2017 +0200

----------------------------------------------------------------------
 .../james/jmap/json/ParsingWritingObjects.java    | 18 ++++++++++--------
 .../jmap/json/ParsingWritingObjectsTest.java      | 10 ----------
 .../jmap/src/test/resources/json/message.json     |  5 +++--
 3 files changed, 13 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/53fdcbdd/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 144e144..f84b91e 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
@@ -22,10 +22,14 @@ package org.apache.james.jmap.json;
 import java.time.Instant;
 import java.util.Optional;
 
+import javax.mail.Flags;
+
 import org.apache.james.jmap.model.BlobId;
 import org.apache.james.jmap.model.Emailer;
+import org.apache.james.jmap.model.Keyword;
 import org.apache.james.jmap.model.Message;
 import org.apache.james.jmap.model.SubMessage;
+import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
@@ -33,6 +37,7 @@ import org.apache.james.mailbox.model.TestMessageId;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 
 public interface ParsingWritingObjects {
 
@@ -42,10 +47,10 @@ public interface ParsingWritingObjects {
         String THREAD_ID = "myThreadId";
         ImmutableList<MailboxId> MAILBOX_IDS = ImmutableList.of(InMemoryId.of(1), InMemoryId.of(2));
         String IN_REPLY_TO_MESSAGE_ID = "myInReplyToMessageId";
-        boolean IS_UNREAD = true;
-        boolean IS_FLAGGED = true;
-        boolean IS_ANSWERED = true;
-        boolean IS_DRAFT = true;
+        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);
         boolean HAS_ATTACHMENT = true;
         ImmutableMap<String, String> HEADERS = ImmutableMap.of("h1", "h1Value", "h2", "h2Value");
         Emailer FROM = Emailer.builder().name("myName").email("myEmail@james.org").build();
@@ -71,10 +76,7 @@ public interface ParsingWritingObjects {
             .threadId(Common.THREAD_ID)
             .mailboxIds(Common.MAILBOX_IDS)
             .inReplyToMessageId(Common.IN_REPLY_TO_MESSAGE_ID)
-            .isUnread(Common.IS_UNREAD)
-            .isFlagged(Common.IS_FLAGGED)
-            .isAnswered(Common.IS_ANSWERED)
-            .isDraft(Common.IS_DRAFT)
+            .flags(Common.FLAGS)
             .headers(Common.HEADERS)
             .from(Common.FROM)
             .to(Common.TO)

http://git-wip-us.apache.org/repos/asf/james-project/blob/53fdcbdd/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
index 0cd3a1f..bed119d 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/json/ParsingWritingObjectsTest.java
@@ -73,16 +73,6 @@ public class ParsingWritingObjectsTest {
     }
 
     @Test
-    public void parsingJsonShouldWorkOnMessage() throws Exception {
-        Message expected = MESSAGE;
-
-        Message message = testee.forParsing()
-            .readValue(IOUtils.toString(ClassLoader.getSystemResource("json/message.json"), StandardCharsets.UTF_8), Message.class);
-
-        assertThat(message).isEqualToComparingFieldByField(expected);
-    }
-
-    @Test
     public void writingJsonShouldWorkOnMessage() throws Exception {
         String expected = IOUtils.toString(ClassLoader.getSystemResource("json/message.json"), StandardCharsets.UTF_8);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/53fdcbdd/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 e036384..ba0c82f 100644
--- a/server/protocols/jmap/src/test/resources/json/message.json
+++ b/server/protocols/jmap/src/test/resources/json/message.json
@@ -4,7 +4,7 @@
     "threadId": "myThreadId",
     "mailboxIds": ["1", "2"],
     "inReplyToMessageId": "myInReplyToMessageId",
-    "isUnread": true,
+    "isUnread": false,
     "isFlagged": true,
     "isAnswered": true,
     "isDraft": true,
@@ -22,5 +22,6 @@
     "textBody": "myTextBody",
     "htmlBody": "<h1>myHtmlBody</h1>",
     "attachments": [ ],
-    "attachedMessages": { }
+    "attachedMessages": { },
+    "keywords": {"$Draft" : true, "$Flagged" : true, "$Answered" : true, "$Seen" : true}
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org