james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject james-project git commit: JAMES-1684 Rewrite integration tests to use body() instead of JsonPath
Date Mon, 08 Feb 2016 08:55:53 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 6725117b8 -> 0a5403293


JAMES-1684 Rewrite integration tests to use body() instead of JsonPath


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

Branch: refs/heads/master
Commit: 0a5403293a2cabfab9cf32a3a500ef0183b9aa40
Parents: 6725117
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Thu Feb 4 14:44:04 2016 +0100
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Thu Feb 4 16:24:09 2016 +0100

----------------------------------------------------------------------
 .../protocols/jmap-integration-testing/pom.xml  |   5 -
 .../jmap/methods/GetMailboxesMethodTest.java    | 261 ++++++++-----------
 .../jmap/methods/GetMessageListMethodTest.java  | 151 ++++-------
 .../jmap/methods/GetMessagesMethodTest.java     | 180 +++++--------
 4 files changed, 227 insertions(+), 370 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0a540329/server/protocols/jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/pom.xml
index b7114d6..655c7e9 100644
--- a/server/protocols/jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/pom.xml
@@ -180,11 +180,6 @@
                     <artifactId>guice-multibindings</artifactId>
                 </dependency>
                 <dependency>
-                    <groupId>com.jayway.jsonpath</groupId>
-                    <artifactId>json-path</artifactId>
-                    <scope>test</scope>
-                </dependency>
-                <dependency>
                     <groupId>com.jayway.restassured</groupId>
                     <artifactId>rest-assured</artifactId>
                     <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/0a540329/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
index 7b23ab2..0d206d0 100644
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMailboxesMethodTest.java
@@ -22,16 +22,15 @@ package org.apache.james.jmap.methods;
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.hasSize;
 import static org.hamcrest.Matchers.isEmptyOrNullString;
-import static org.hamcrest.Matchers.startsWith;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.nullValue;
 
 import java.io.ByteArrayInputStream;
 import java.util.Date;
-import java.util.List;
-import java.util.Map;
 
 import javax.mail.Flags;
 
@@ -51,21 +50,17 @@ import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
 
 import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableMap;
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.ParseContext;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.http.ContentType;
 
 public abstract class GetMailboxesMethodTest {
+    private static final String NAME = "[0][0]";
+    private static final String ARGUMENTS = "[0][1]";
 
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
     private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
     private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
     private JmapServer jmapServer = jmapServer(temporaryFolder, embeddedElasticSearch, cassandra);
-    private ParseContext jsonPath;
 
     protected abstract JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra);
 
@@ -82,9 +77,6 @@ public abstract class GetMailboxesMethodTest {
     public void setup() throws Exception {
         RestAssured.port = jmapServer.getPort();
         RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-        jsonPath = JsonPath.using(Configuration.builder()
-            .options(Option.DEFAULT_PATH_LEAF_TO_NULL)
-            .build());
 
         String domain = "domain.tld";
         username = "username@" + domain;
@@ -105,7 +97,8 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(equalTo("[[\"error\",{\"type\":\"Not yet implemented\"},\"#0\"]]"));
+            .body(NAME, equalTo("error"))
+            .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
     }
 
     @Test
@@ -121,8 +114,8 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][0]", equalTo("mailboxes"))
-            .body("[0][1].list", hasSize(0));
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", hasSize(0));
     }
 
     @Test
@@ -145,10 +138,10 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][0]", equalTo("mailboxes"))
-            .body("[0][1].list", hasSize(2))
-            .body("[0][1].list[0].id", equalTo(mailboxId))
-            .body("[0][1].list[1].id", equalTo(mailboxId2));
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", hasSize(2))
+            .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId))
+            .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2));
     }
 
     @Test
@@ -169,9 +162,9 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][0]", equalTo("mailboxes"))
-            .body("[0][1].list", hasSize(1))
-            .body("[0][1].list[0].id", equalTo(mailboxId));
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", hasSize(1))
+            .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId));
     }
 
     @Test
@@ -187,8 +180,8 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][0]", equalTo("mailboxes"))
-            .body("[0][1].list", hasSize(0));
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", empty());
     }
 
     @Test
@@ -211,10 +204,10 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][0]", equalTo("mailboxes"))
-            .body("[0][1].list", hasSize(2))
-            .body("[0][1].list[0].id", equalTo(mailboxId))
-            .body("[0][1].list[1].id", equalTo(mailboxId2));
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", hasSize(2))
+            .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId))
+            .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2));
     }
     
     @Test
@@ -228,12 +221,13 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(equalTo("[[\"error\",{\"type\":\"invalidArguments\"},\"#0\"]]"));
+            .body(NAME, equalTo("error"))
+            .body(ARGUMENTS + ".type", equalTo("invalidArguments"));
     }
 
     @Test
     public void getMailboxesShouldReturnEmptyListWhenNoMailboxes() throws Exception {
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -242,12 +236,8 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"mailboxes\","))
-            .extract()
-            .asString();
-        
-        String firstResponsePath = "$.[0].[1]";
-        assertThat(jsonPath.parse(response).<Integer>read(firstResponsePath + ".list.length()")).isEqualTo(0);
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", empty());
     }
 
     @Test
@@ -260,20 +250,19 @@ public abstract class GetMailboxesMethodTest {
                 "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
 
         given()
-                .accept(ContentType.JSON)
-                .contentType(ContentType.JSON)
-                .header("Authorization", "Bearer " + authToken)
-                .body("[[\"getMailboxes\", {}, \"#0\"]]")
-                .when()
-                .post("/jmap")
-                .then()
-                .statusCode(200)
-                .body("[0][0]", equalTo("mailboxes"))
-                .body("[0][1].accountId", isEmptyOrNullString())
-                .body("[0][1].state", isEmptyOrNullString())
-                .body("[0][1].notFound", isEmptyOrNullString())
-                .body("[0][1].list", hasSize(0))
-                .body("[0][2]", equalTo("#0"));
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", "Bearer " + authToken)
+            .body("[[\"getMailboxes\", {}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".accountId", isEmptyOrNullString())
+            .body(ARGUMENTS + ".state", isEmptyOrNullString())
+            .body(ARGUMENTS + ".notFound", isEmptyOrNullString())
+            .body(ARGUMENTS + ".list", hasSize(0));
     }
 
 
@@ -287,14 +276,14 @@ public abstract class GetMailboxesMethodTest {
                 "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
 
         given()
-                .accept(ContentType.JSON)
-                .contentType(ContentType.JSON)
-                .header("Authorization", "Bearer " + badAuthToken)
-                .body("[[\"getMailboxes\", {}, \"#0\"]]")
-                .when()
-                .post("/jmap")
-                .then()
-                .statusCode(401);
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", "Bearer " + badAuthToken)
+            .body("[[\"getMailboxes\", {}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(401);
     }
 
     @Test
@@ -304,7 +293,7 @@ public abstract class GetMailboxesMethodTest {
         jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "name"), 
                 new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -313,136 +302,117 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"mailboxes\","))
-            .extract()
-            .asString();
-        
-        String firstMailboxPath = "$.[0].[1].list.[0]";
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".name")).isEqualTo("name");
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".parentId")).isNull();
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".role")).isNull();
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".sortOrder")).isEqualTo(1000);
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mustBeOnlyMailbox")).isFalse();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayReadItems")).isFalse();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayAddItems")).isFalse();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayRemoveItems")).isFalse();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayCreateChild")).isFalse();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayRename")).isFalse();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayDelete")).isFalse();
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".totalMessages")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".unreadMessages")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".unreadThreads")).isEqualTo(0);
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list[0].name", equalTo("name"))
+            .body(ARGUMENTS + ".list[0].parentId", nullValue())
+            .body(ARGUMENTS + ".list[0].role", nullValue())
+            .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000))
+            .body(ARGUMENTS + ".list[0].mustBeOnlyMailbox", equalTo(false))
+            .body(ARGUMENTS + ".list[0].mayReadItems", equalTo(false))
+            .body(ARGUMENTS + ".list[0].mayAddItems", equalTo(false))
+            .body(ARGUMENTS + ".list[0].mayRemoveItems", equalTo(false))
+            .body(ARGUMENTS + ".list[0].mayCreateChild", equalTo(false))
+            .body(ARGUMENTS + ".list[0].mayRename", equalTo(false))
+            .body(ARGUMENTS + ".list[0].mayDelete", equalTo(false))
+            .body(ARGUMENTS + ".list[0].totalMessages", equalTo(1))
+            .body(ARGUMENTS + ".list[0].unreadMessages", equalTo(1))
+            .body(ARGUMENTS + ".list[0].unreadThreads", equalTo(0));
     }
 
     @Test
     public void getMailboxesShouldReturnFilteredMailboxesPropertiesWhenRequestContainsFilterProperties() throws Exception {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMailboxes\", {\"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]")
-            .when()
+        .when()
             .post("/jmap")
-            .then()
+        .then()
             .statusCode(200)
-            .content(startsWith("[[\"mailboxes\","))
-            .extract()
-            .asString();
-
-        String firstMailboxPath = "$.[0].[1].list.[0]";
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".id")).isNotEmpty();
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".name")).isNull();
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".parentId")).isNull();
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".role")).isNull();
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".sortOrder")).isEqualTo(1000);
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mustBeOnlyMailbox")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayReadItems")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayAddItems")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayRemoveItems")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayCreateChild")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayRename")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMailboxPath + ".mayDelete")).isNull();
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".totalMessages")).isNull();
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".unreadMessages")).isEqualTo(0);
-        assertThat(jsonPath.parse(response).<Integer>read(firstMailboxPath + ".unreadThreads")).isNull();
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
+            .body(ARGUMENTS + ".list[0].name", nullValue())
+            .body(ARGUMENTS + ".list[0].parentId", nullValue())
+            .body(ARGUMENTS + ".list[0].role", nullValue())
+            .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000))
+            .body(ARGUMENTS + ".list[0].mustBeOnlyMailbox", nullValue())
+            .body(ARGUMENTS + ".list[0].mayReadItems", nullValue())
+            .body(ARGUMENTS + ".list[0].mayAddItems", nullValue())
+            .body(ARGUMENTS + ".list[0].mayRemoveItems", nullValue())
+            .body(ARGUMENTS + ".list[0].mayCreateChild", nullValue())
+            .body(ARGUMENTS + ".list[0].mayRename", nullValue())
+            .body(ARGUMENTS + ".list[0].mayDelete", nullValue())
+            .body(ARGUMENTS + ".list[0].totalMessages", nullValue())
+            .body(ARGUMENTS + ".list[0].unreadMessages", equalTo(0))
+            .body(ARGUMENTS + ".list[0].unreadThreads", nullValue());
     }
 
     @Test
     public void getMailboxesShouldReturnIdWhenRequestContainsEmptyPropertyListFilter() throws Exception {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMailboxes\", {\"properties\" : []}, \"#0\"]]")
-            .when()
+        .when()
             .post("/jmap")
-            .then()
+        .then()
             .statusCode(200)
-            .content(startsWith("[[\"mailboxes\","))
-            .extract()
-            .asString();
-
-        String firstMailboxPath = "$.[0].[1].list.[0]";
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".id")).isNotEmpty();
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".name")).isNull();
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
+            .body(ARGUMENTS + ".list[0].name", nullValue());
     }
 
     @Test
     public void getMailboxesShouldIgnoreUnknownPropertiesWhenRequestContainsUnknownPropertyListFilter() throws Exception {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name");
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
             .body("[[\"getMailboxes\", {\"properties\" : [\"unknown\"]}, \"#0\"]]")
-            .when()
+        .when()
             .post("/jmap")
-            .then()
+        .then()
             .statusCode(200)
-            .content(startsWith("[[\"mailboxes\","))
-            .extract()
-            .asString();
-
-        String firstMailboxPath = "$.[0].[1].list.[0]";
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".id")).isNotEmpty();
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".name")).isNull();
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list[0].id", not(isEmptyOrNullString()))
+            .body(ARGUMENTS + ".list[0].name", nullValue());
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void getMailboxesShouldReturnMailboxesWithSortOrder() throws Exception {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox");
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "trash");
 
-        String response = given()
-                .accept(ContentType.JSON)
-                .contentType(ContentType.JSON)
-                .header("Authorization", accessToken.serialize())
-                .body("[[\"getMailboxes\", {}, \"#0\"]]")
-            .when()
-                .post("/jmap")
-            .then()
-                .statusCode(200)
-                .content(startsWith("[[\"mailboxes\",{\"accountId\":null,\"state\":null,\"list\":[{\"id\":\""))
-                .extract()
-                .asString();
-        assertThat(jsonPath.parse(response).<List<Map<String, Object>>>read("$.[0].[1].list[*].['name','sortOrder']"))
-                .hasSize(2)
-                .containsOnly(
-                        ImmutableMap.of("name", "trash", "sortOrder", 60),
-                        ImmutableMap.of("name", "inbox", "sortOrder", 10));
+        given()
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMailboxes\", {}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", hasSize(2))
+            .body(ARGUMENTS + ".list[0].name", equalTo("inbox"))
+            .body(ARGUMENTS + ".list[0].sortOrder", equalTo(10))
+            .body(ARGUMENTS + ".list[1].name", equalTo("trash"))
+            .body(ARGUMENTS + ".list[1].sortOrder", equalTo(60));
     }
 
     @Test
     public void getMailboxesShouldReturnMailboxesWithRolesInLowerCase() throws Exception {
         jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "outbox");
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -451,12 +421,9 @@ public abstract class GetMailboxesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"mailboxes\","))
-            .extract()
-            .asString();
-        
-        String firstMailboxPath = "$.[0].[1].list.[0]";
-        assertThat(jsonPath.parse(response).<String>read(firstMailboxPath + ".role")).isEqualTo("outbox");
+            .body(NAME, equalTo("mailboxes"))
+            .body(ARGUMENTS + ".list", hasSize(1))
+            .body(ARGUMENTS + ".list[0].role", equalTo("outbox"));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/0a540329/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
index 91b4d33..ca2460d 100644
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
@@ -23,10 +23,11 @@ import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.RestAssured.with;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.startsWith;
 
 import java.io.ByteArrayInputStream;
 import java.time.LocalDate;
@@ -49,14 +50,12 @@ import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
 
 import com.google.common.base.Charsets;
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.ParseContext;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.http.ContentType;
 
 public abstract class GetMessageListMethodTest {
+    private static final String NAME = "[0][0]";
+    private static final String ARGUMENTS = "[0][1]";
 
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
     private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
@@ -73,15 +72,11 @@ public abstract class GetMessageListMethodTest {
 
     private AccessToken accessToken;
     private String username;
-    private ParseContext jsonPath;
 
     @Before
     public void setup() throws Exception {
         RestAssured.port = jmapServer.getPort();
         RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-        jsonPath = JsonPath.using(Configuration.builder()
-                .options(Option.DEFAULT_PATH_LEAF_TO_NULL)
-                .build());
 
         String domain = "domain.tld";
         this.username = "username@" + domain;
@@ -102,7 +97,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(equalTo("[[\"error\",{\"type\":\"invalidArguments\"},\"#0\"]]"));
+            .body(NAME, equalTo("error"))
+            .body(ARGUMENTS + ".type", equalTo("invalidArguments"));
     }
 
     @Test
@@ -115,7 +111,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -124,12 +120,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-        
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
     }
 
     @Test
@@ -143,7 +135,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -152,12 +144,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-        
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox2|1");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox2|1"));
     }
 
     @Test
@@ -176,7 +164,7 @@ public abstract class GetMessageListMethodTest {
                 .post("/jmap")
                 .path("[0][1].list[0].id");
         
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -185,12 +173,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-        
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
     }
 
     @Test
@@ -211,7 +195,7 @@ public abstract class GetMessageListMethodTest {
                 .post("/jmap")
                 .path("[0][1].list.id");
         
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -220,12 +204,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
     }
 
     @Test
@@ -236,7 +216,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -245,12 +225,7 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .isEmpty();
+            .body(ARGUMENTS + ".messageIds", empty());
     }
 
     @Test
@@ -264,7 +239,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -273,12 +248,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsExactly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
     }
 
     @Test
@@ -292,7 +263,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -301,12 +272,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsExactly("username@domain.tld|mailbox|2", "username@domain.tld|mailbox|1");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|2", "username@domain.tld|mailbox|1"));
     }
 
     @Test
@@ -320,7 +287,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -329,12 +296,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsExactly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
     }
 
     @Test
@@ -348,7 +311,7 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][0]", equalTo("messageList"));
+            .body(NAME, equalTo("messageList"));
     }
     
     @Test
@@ -362,7 +325,7 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][0]", equalTo("messageList"));
+            .body(NAME, equalTo("messageList"));
     }
     
     @Test
@@ -376,7 +339,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -385,12 +348,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
     }
 
     @Test
@@ -404,7 +363,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -413,12 +372,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|2");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|2"));
     }
 
     @Test
@@ -432,7 +387,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -441,12 +396,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2"));
     }
 
     @Test
@@ -460,7 +411,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -469,12 +420,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", contains("username@domain.tld|mailbox|1"));
     }
 
     @Test
@@ -492,7 +439,7 @@ public abstract class GetMessageListMethodTest {
                 new ByteArrayInputStream("Subject: test4\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -501,12 +448,8 @@ public abstract class GetMessageListMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","))
-            .extract()
-            .asString();
-
-        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
-            .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2", "username@domain.tld|mailbox|3");
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", containsInAnyOrder("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2", "username@domain.tld|mailbox|3"));
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/james-project/blob/0a540329/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
index 3356b1f..26fcb1e 100644
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
@@ -22,16 +22,15 @@ package org.apache.james.jmap.methods;
 import static com.jayway.restassured.RestAssured.given;
 import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
 import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.startsWith;
+import static org.hamcrest.Matchers.nullValue;
 
 import java.io.ByteArrayInputStream;
 import java.time.ZonedDateTime;
 import java.util.Date;
-import java.util.List;
-import java.util.Map;
 
 import javax.mail.Flags;
 
@@ -42,7 +41,7 @@ import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.assertj.core.data.MapEntry;
+import org.elasticsearch.common.collect.ImmutableMap;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -50,14 +49,12 @@ import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
 
 import com.google.common.base.Charsets;
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.ParseContext;
 import com.jayway.restassured.RestAssured;
 import com.jayway.restassured.http.ContentType;
 
 public abstract class GetMessagesMethodTest {
+    private static final String NAME = "[0][0]";
+    private static final String ARGUMENTS = "[0][1]";
 
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
     private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
@@ -73,16 +70,12 @@ public abstract class GetMessagesMethodTest {
         .around(jmapServer);
 
     private AccessToken accessToken;
-    private ParseContext jsonPath;
     private String username;
 
     @Before
     public void setup() throws Exception {
         RestAssured.port = jmapServer.getPort();
         RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-        jsonPath = JsonPath.using(Configuration.builder()
-                .options(Option.DEFAULT_PATH_LEAF_TO_NULL)
-                .build());
 
         String domain = "domain.tld";
         username = "username@" + domain;
@@ -104,7 +97,8 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(equalTo("[[\"error\",{\"type\":\"Not yet implemented\"},\"#0\"]]"));
+            .body(NAME, equalTo("error"))
+            .body(ARGUMENTS + ".type", equalTo("Not yet implemented"));
     }
     
     @Test
@@ -118,28 +112,28 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .body("[0][1].notFound", hasSize(0))
-            .body("[0][1].list", hasSize(0))
-            .body("[0][2]", equalTo("#0"));
+            .body(ARGUMENTS + ".notFound", empty())
+            .body(ARGUMENTS + ".list", empty());
     }
 
     @Test
     public void getMessagesShouldErrorInvalidArgumentsWhenRequestContainsInvalidArgument() throws Exception {
         given()
-                .accept(ContentType.JSON)
-                .contentType(ContentType.JSON)
-                .header("Authorization", accessToken.serialize())
-                .body("[[\"getMessages\", {\"ids\": null}, \"#0\"]]")
-                .when()
-                .post("/jmap")
-                .then()
-                .statusCode(200)
-                .content(equalTo("[[\"error\",{\"type\":\"invalidArguments\"},\"#0\"]]"));
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessages\", {\"ids\": null}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("error"))
+            .body(ARGUMENTS + ".type", equalTo("invalidArguments"));
     }
 
     @Test
     public void getMessagesShouldReturnEmptyListWhenNoMessage() throws Exception {
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -148,17 +142,13 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messages\","))
-            .extract()
-            .asString();
-        
-        assertThat(JsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        assertThat(JsonPath.parse(response).<Integer>read("$.[0].[1].list.length()")).isEqualTo(0);
+            .body(NAME, equalTo("messages"))
+            .body(ARGUMENTS + ".list", empty());
     }
 
     @Test
     public void getMessagesShouldReturnNoFoundIndicesWhenMessageNotFound() throws Exception {
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -167,12 +157,8 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messages\","))
-            .extract()
-            .asString();
-        
-        assertThat(JsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].notFound")).containsExactly("username|inbox|12");
+            .body(NAME, equalTo("messages"))
+            .body(ARGUMENTS + ".notFound", contains("username|inbox|12"));
     }
 
     @Test
@@ -185,7 +171,7 @@ public abstract class GetMessagesMethodTest {
         
         embeddedElasticSearch.awaitForElasticSearch();
         
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -194,23 +180,16 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messages\","))
-            .extract()
-            .asString();
-
-        String firstResponsePath = "$.[0].[1]";
-        String firstMessagePath = firstResponsePath + ".list[0]";
-
-        assertThat(JsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        assertThat(JsonPath.parse(response).<Integer>read(firstResponsePath + ".list.length()")).isEqualTo(1);
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".id")).isEqualTo(username + "|inbox|1");
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".threadId")).isEqualTo(username + "|inbox|1");
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".subject")).isEqualTo("my test subject");
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".textBody")).isEqualTo("testmail");
-        assertThat(JsonPath.parse(response).<Boolean>read(firstMessagePath + ".isUnread")).isTrue();
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".preview")).isEqualTo("testmail");
-        assertThat(JsonPath.parse(response).<Map<String, String>>read(firstMessagePath + ".headers")).containsExactly(MapEntry.entry("subject", "my test subject"));
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".date")).isEqualTo("2014-10-30T14:12:00Z");
+            .body(NAME, equalTo("messages"))
+            .body(ARGUMENTS + ".list", hasSize(1))
+            .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
+            .body(ARGUMENTS + ".list[0].threadId", equalTo(username + "|inbox|1"))
+            .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
+            .body(ARGUMENTS + ".list[0].textBody", equalTo("testmail"))
+            .body(ARGUMENTS + ".list[0].isUnread", equalTo(true))
+            .body(ARGUMENTS + ".list[0].preview", equalTo("testmail"))
+            .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("subject", "my test subject")))
+            .body(ARGUMENTS + ".list[0].date", equalTo("2014-10-30T14:12:00Z"));
     }
     
     @Test
@@ -223,7 +202,7 @@ public abstract class GetMessagesMethodTest {
         
         embeddedElasticSearch.awaitForElasticSearch();
         
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -232,22 +211,15 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messages\","))
-            .extract()
-            .asString();
-
-        String firstResponsePath = "$.[0].[1]";
-        String firstMessagePath = firstResponsePath + ".list[0]";
-
-        assertThat(jsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<Integer>read(firstResponsePath + ".list.length()")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".id")).isEqualTo(username + "|inbox|1");
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".subject")).isEqualTo("my test subject");
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".textBody")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMessagePath + ".isUnread")).isNull();
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".preview")).isNull();
-        assertThat(jsonPath.parse(response).<Map<String, String>>read(firstMessagePath + ".headers")).isNull();
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".date")).isNull();
+            .body(NAME, equalTo("messages"))
+            .body(ARGUMENTS + ".list", hasSize(1))
+            .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
+            .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"))
+            .body(ARGUMENTS + ".list[0].textBody", nullValue())
+            .body(ARGUMENTS + ".list[0].isUnread", nullValue())
+            .body(ARGUMENTS + ".list[0].preview", nullValue())
+            .body(ARGUMENTS + ".list[0].headers", nullValue())
+            .body(ARGUMENTS + ".list[0].date", nullValue());
     }
     
     @Test
@@ -265,7 +237,7 @@ public abstract class GetMessagesMethodTest {
         
         embeddedElasticSearch.awaitForElasticSearch();
         
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -274,22 +246,15 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messages\","))
-            .extract()
-            .asString();
-
-        String firstResponsePath = "$.[0].[1]";
-        String firstMessagePath = firstResponsePath + ".list[0]";
-
-        assertThat(jsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<Integer>read(firstResponsePath + ".list.length()")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".id")).isEqualTo(username + "|inbox|1");
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".subject")).isNull();
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".textBody")).isNull();
-        assertThat(jsonPath.parse(response).<Boolean>read(firstMessagePath + ".isUnread")).isNull();
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".preview")).isNull();
-        assertThat(jsonPath.parse(response).<Map<String, String>>read(firstMessagePath + ".headers")).containsOnly(MapEntry.entry("from", "user@domain.tld"), MapEntry.entry("header2", "Header2Content"));
-        assertThat(jsonPath.parse(response).<String>read(firstMessagePath + ".date")).isNull();
+            .body(NAME, equalTo("messages"))
+            .body(ARGUMENTS + ".list", hasSize(1))
+            .body(ARGUMENTS + ".list[0].id", equalTo(username + "|inbox|1"))
+            .body(ARGUMENTS + ".list[0].subject", nullValue())
+            .body(ARGUMENTS + ".list[0].textBody", nullValue())
+            .body(ARGUMENTS + ".list[0].isUnread", nullValue())
+            .body(ARGUMENTS + ".list[0].preview", nullValue())
+            .body(ARGUMENTS + ".list[0].headers", equalTo(ImmutableMap.of("from", "user@domain.tld", "header2", "Header2Content")))
+            .body(ARGUMENTS + ".list[0].date", nullValue());
     }
 
     @Test
@@ -302,7 +267,7 @@ public abstract class GetMessagesMethodTest {
         
         embeddedElasticSearch.awaitForElasticSearch();
         
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -311,15 +276,9 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messages\","))
-            .extract()
-            .asString();
-
-        String firstResponsePath = "$.[0].[1]";
-
-        assertThat(jsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        assertThat(jsonPath.parse(response).<Integer>read(firstResponsePath + ".list.length()")).isEqualTo(0);
-        assertThat(jsonPath.parse(response).<Integer>read(firstResponsePath + ".notFound.length()")).isEqualTo(1);
+            .body(NAME, equalTo("messages"))
+            .body(ARGUMENTS + ".list", empty())
+            .body(ARGUMENTS + ".notFound", hasSize(1));
     }
 
     @Test
@@ -331,7 +290,7 @@ public abstract class GetMessagesMethodTest {
                 new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
-        String response = given()
+        given()
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
@@ -340,16 +299,9 @@ public abstract class GetMessagesMethodTest {
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messages\","))
-            .extract()
-            .asString();
-
-        String firstResponsePath = "$.[0].[1]";
-        String firstMessagePath = firstResponsePath + ".list[0]";
-
-        assertThat(JsonPath.parse(response).<Integer>read("$.length()")).isEqualTo(1);
-        assertThat(JsonPath.parse(response).<Integer>read(firstResponsePath + ".list.length()")).isEqualTo(1);
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".id")).isEqualTo("username@domain.tld|mailbox|1");
-        assertThat(JsonPath.parse(response).<String>read(firstMessagePath + ".subject")).isEqualTo("my test subject");
+            .body(NAME, equalTo("messages"))
+            .body(ARGUMENTS + ".list", hasSize(1))
+            .body(ARGUMENTS + ".list[0].id", equalTo("username@domain.tld|mailbox|1"))
+            .body(ARGUMENTS + ".list[0].subject", equalTo("my test subject"));
     }
 }


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