james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [10/13] james-project git commit: JAMES-1943 Adding integration tests for FilterOperator on GetMessageList
Date Mon, 20 Feb 2017 09:08:54 GMT
JAMES-1943 Adding integration tests for FilterOperator on GetMessageList


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

Branch: refs/heads/master
Commit: 80489461e52710b4f6e0e33b82f0782625bdcb05
Parents: f415df2
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Feb 16 10:45:36 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Feb 20 16:07:11 2017 +0700

----------------------------------------------------------------------
 .../integration/GetMessageListMethodTest.java   | 113 ++++++++++++++++++-
 1 file changed, 112 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/80489461/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 034575c..c45ff64 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
@@ -39,6 +39,7 @@ import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.JmapJamesServer;
 import org.apache.james.jmap.HttpJmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
@@ -99,7 +100,117 @@ public abstract class GetMessageListMethodTest {
     public void teardown() {
         jmapServer.stop();
     }
-    
+
+    @Test
+    public void getMessageListANDOperatorShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotSeenNotFlagged = 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 messageNotSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.FLAGGED));
+        ComposedMessageId messageSeenNotFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, new Flags(Flags.Flag.SEEN));
+        ComposedMessageId messageSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, FlagsBuilder.builder().add(Flags.Flag.SEEN, Flags.Flag.FLAGGED).build());
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"operator\":\"AND\",\"conditions\":[{\"isFlagged\":\"true\"},{\"isUnread\":\"true\"}]}},
\"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains(messageNotSeenFlagged.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListOROperatorShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotSeenNotFlagged = 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 messageNotSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.FLAGGED));
+        ComposedMessageId messageSeenNotFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, new Flags(Flags.Flag.SEEN));
+        ComposedMessageId messageSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, FlagsBuilder.builder().add(Flags.Flag.SEEN, Flags.Flag.FLAGGED).build());
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"operator\":\"OR\",\"conditions\":[{\"isFlagged\":\"true\"},{\"isUnread\":\"true\"}]}},
\"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(messageNotSeenFlagged.getMessageId().serialize(),
+                messageSeenFlagged.getMessageId().serialize(),
+                messageNotSeenNotFlagged.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListNOTOperatorShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotSeenNotFlagged = 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 messageNotSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.FLAGGED));
+        ComposedMessageId messageSeenNotFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, new Flags(Flags.Flag.SEEN));
+        ComposedMessageId messageSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, FlagsBuilder.builder().add(Flags.Flag.SEEN, Flags.Flag.FLAGGED).build());
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"operator\":\"NOT\",\"conditions\":[{\"isFlagged\":\"true\"},{\"isUnread\":\"true\"}]}},
\"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(messageSeenNotFlagged.getMessageId().serialize()));
+    }
+
+    @Test
+    public void getMessageListNestedOperatorsShouldWork() throws Exception {
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        ComposedMessageId messageNotSeenNotFlagged = 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 messageNotSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/twoAttachments.eml"), new Date(),
false, new Flags(Flags.Flag.FLAGGED));
+        ComposedMessageId messageSeenNotFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, new Flags(Flags.Flag.SEEN));
+        ComposedMessageId messageSeenFlagged = jmapServer.serverProbe().appendMessage(username,
new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"),
+            ClassLoader.getSystemResourceAsStream("eml/oneInlinedImage.eml"), new Date(),
false, FlagsBuilder.builder().add(Flags.Flag.SEEN, Flags.Flag.FLAGGED).build());
+
+        await();
+
+        given()
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"filter\":{\"operator\":\"OR\",\"conditions\":["
+
+                "{\"operator\":\"AND\", \"conditions\":[{\"isFlagged\":\"true\"},{\"isUnread\":\"true\"}]},"
+
+                "{\"operator\":\"AND\", \"conditions\":[{\"isFlagged\":\"true\"},{\"isUnread\":\"false\"}]}"
+
+                "]}}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder(messageSeenFlagged.getMessageId().serialize(),
+                messageNotSeenFlagged.getMessageId().serialize()));
+    }
+
     @Test
     public void getMessageListShouldReturnErrorInvalidArgumentsWhenRequestIsInvalid() throws
Exception {
         given()


---------------------------------------------------------------------
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