james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [11/13] james-project git commit: JAMES-1943 Add JMAP integration tests for flags criterion convertions
Date Mon, 20 Feb 2017 09:08:55 GMT
JAMES-1943 Add JMAP integration tests for flags criterion convertions


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

Branch: refs/heads/master
Commit: 3590659793d1aee39debd0d4de9ce920be0e6a43
Parents: c1ae26e
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Feb 16 10:47:17 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Feb 20 16:07:12 2017 +0700

----------------------------------------------------------------------
 .../integration/GetMessageListMethodTest.java   | 174 +++++++++++++++++++
 1 file changed, 174 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/35906597/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index c45ff64..b15a0ef 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -102,6 +102,180 @@ public abstract class GetMessageListMethodTest {
     }
 
     @Test
+    public void getMessageListSetFlaggedFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.FLAGGED));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isFlagged\":\"true\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageFlagged.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListUnsetFlaggedFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.FLAGGED));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isFlagged\":\"false\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageNotFlagged.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListReadFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotRead = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageRead = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.SEEN));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isUnread\":\"false\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageRead.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListUnreadFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotRead = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageRead = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.SEEN));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isUnread\":\"true\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageNotRead.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListSetDraftFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotDraft = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageDraft = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.DRAFT));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isDraft\":\"true\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageDraft.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListUnsetDraftFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotDraft = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageDraft = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.DRAFT));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isDraft\":\"false\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageNotDraft.getMessageId().serialize()));
+    } @Test
+    public void getMessageListSetAnsweredFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotAnswered = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageAnswered = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.ANSWERED));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isAnswered\":\"true\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageAnswered.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListUnsetAnsweredFilterShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotAnswered = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(),
false, new Flags());
+        ComposedMessageId messageAnswered = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.ANSWERED));
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"isAnswered\":\"false\"}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageNotAnswered.getMessageId().serialize()));
+    }
+    
+    @Test
     public void getMessageListANDOperatorShouldWork() throws Exception {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
 


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


Mime
View raw message