JAMES-2186 Correct JMAP integration test

The test was incorrect, as it looked for the messageId of the message in the 
Outbox, while the INBOX messageId is different.

The meaning is, if the test was fast enough to pass before message is removed 
from outbox, it pass. If message is remove from outbox before the test execute 
GetMessageList, it fails.

I corrected the scenario of this test.


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

Branch: refs/heads/master
Commit: 5d1cb7d96c962ab6a8a6cebbc0a7de86c72b8ee2
Parents: 7eb65cf
Author: benwa <btell...@linagora.com>
Authored: Fri Oct 20 15:08:12 2017 +0700
Committer: Matthieu Baechler <matth...@apache.org>
Committed: Fri Oct 20 12:34:52 2017 +0200

----------------------------------------------------------------------
 .../integration/SetMessagesMethodTest.java        | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5d1cb7d9/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 23027ab..d72a60e 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
@@ -31,7 +31,6 @@ import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.endsWith;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasEntry;
-import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasKey;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.isEmptyOrNullString;
@@ -3765,6 +3764,7 @@ public abstract class SetMessagesMethodTest {
         String messageCreationId = "creationId";
         String fromAddress = USERNAME;
         String outboxId = getOutboxId(accessToken);
+        String inboxId = getMailboxId(accessToken, Role.INBOX);
         String requestBody = "[" +
                 "  [" +
                 "    \"setMessages\","+
@@ -3787,28 +3787,26 @@ public abstract class SetMessagesMethodTest {
                 "  ]" +
                 "]";
 
-        String messageId = with()
+        with()
             .header("Authorization", accessToken.serialize())
             .body(requestBody)
-        // When
-        .post("/jmap")
-        .then()
-            .extract()
-            .body()
-            .<String>path(ARGUMENTS + ".created."+ messageCreationId +".id");
+        .post("/jmap");
 
         calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> 
isAnyMessageFoundInInbox(accessToken));
 
         given()
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessageList\", {\"filter\":{\"body\": \"Test\"}}, 
\"#0\"]]")
+            .body("[[\"getMessageList\", {\"filter\":{" +
+                "   \"body\": \"Test body\", " +
+                "   \"inMailboxes\":[\"" + inboxId  + "\"]}}, " +
+                "\"#0\"]]")
             .when()
             .post("/jmap")
         .then()
             .statusCode(200)
             .log().ifValidationFails()
             .body(NAME, equalTo("messageList"))
-            .body(ARGUMENTS + ".messageIds", hasItem(messageId));
+            .body(ARGUMENTS + ".messageIds", hasSize(1));
     }
 
     @Test


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

Reply via email to