JAMES-1664 Fix GetMessages integration tests

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

Branch: refs/heads/master
Commit: 6b87c3dd501645f2aae341187b1c484b7b17e8e7
Parents: df5d417
Author: Antoine Duprat <antdup...@gmail.com>
Authored: Fri Jan 22 10:49:07 2016 +0100
Committer: Antoine Duprat <antdup...@gmail.com>
Committed: Mon Feb 1 13:20:34 2016 +0100

----------------------------------------------------------------------
 .../jmap/methods/GetMessagesMethodTest.java     | 27 ++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6b87c3dd/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 56d1c75..7930c8f 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
@@ -74,6 +74,7 @@ public abstract class GetMessagesMethodTest {
 
     private AccessToken accessToken;
     private ParseContext jsonPath;
+    private String username;
 
     @Before
     public void setup() throws Exception {
@@ -84,7 +85,7 @@ public abstract class GetMessagesMethodTest {
                 .build());
 
         String domain = "domain.tld";
-        String username = "username@" + domain;
+        username = "username@" + domain;
         String password = "password";
         jmapServer.serverProbe().addDomain(domain);
         jmapServer.serverProbe().addUser(username, password);
@@ -176,8 +177,10 @@ public abstract class GetMessagesMethodTest {
     
     @Test
     public void getMessagesShouldReturnMessagesWhenAvailable() throws 
Exception {
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "inbox");
+
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        jmapServer.serverProbe().appendMessage("username", new 
MailboxPath(MailboxConstants.USER_NAMESPACE, "username", "inbox"),
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
                 new ByteArrayInputStream("Subject: my test 
subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, 
new Flags());
         
         embeddedElasticSearch.awaitForElasticSearch();
@@ -186,7 +189,7 @@ public abstract class GetMessagesMethodTest {
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"]}, 
\"#0\"]]")
+            .body("[[\"getMessages\", {\"ids\": [\"" + username + 
"|inbox|1\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -200,7 +203,7 @@ public abstract class GetMessagesMethodTest {
 
         
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("usern...@domain.tld|inbox|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")).isEqualTo("testmail");
         assertThat(JsonPath.parse(response).<Boolean>read(firstMessagePath + 
".isUnread")).isTrue();
@@ -211,8 +214,10 @@ public abstract class GetMessagesMethodTest {
     
     @Test
     public void getMessagesShouldReturnFilteredPropertiesMessagesWhenAsked() 
throws Exception {
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "inbox");
+
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        jmapServer.serverProbe().appendMessage("username", new 
MailboxPath(MailboxConstants.USER_NAMESPACE, "username", "inbox"),
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
                 new ByteArrayInputStream("Subject: my test 
subject\r\n\r\ntestmail".getBytes()), Date.from(dateTime.toInstant()), false, 
new Flags());
         
         embeddedElasticSearch.awaitForElasticSearch();
@@ -221,7 +226,7 @@ public abstract class GetMessagesMethodTest {
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"], 
\"properties\": [\"id\", \"subject\"]}, \"#0\"]]")
+            .body("[[\"getMessages\", {\"ids\": [\"" + username + 
"|inbox|1\"], \"properties\": [\"id\", \"subject\"]}, \"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -235,7 +240,7 @@ public abstract class GetMessagesMethodTest {
 
         
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("usern...@domain.tld|inbox|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();
@@ -246,8 +251,10 @@ public abstract class GetMessagesMethodTest {
     
     @Test
     public void getMessagesShouldReturnFilteredHeaderPropertyWhenAsked() 
throws Exception {
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "inbox");
+
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
-        jmapServer.serverProbe().appendMessage("username", new 
MailboxPath(MailboxConstants.USER_NAMESPACE, "username", "inbox"),
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "inbox"),
                 new ByteArrayInputStream(("From: u...@domain.tld\r\n"
                         + "header1: Header1Content\r\n"
                         + "HEADer2: Header2Content\r\n"
@@ -261,7 +268,7 @@ public abstract class GetMessagesMethodTest {
             .accept(ContentType.JSON)
             .contentType(ContentType.JSON)
             .header("Authorization", accessToken.serialize())
-            .body("[[\"getMessages\", {\"ids\": [\"username|inbox|1\"], 
\"properties\": [\"headers.from\", \"headers.heADER2\"]}, \"#0\"]]")
+            .body("[[\"getMessages\", {\"ids\": [\"" + username + 
"|inbox|1\"], \"properties\": [\"headers.from\", \"headers.heADER2\"]}, 
\"#0\"]]")
         .when()
             .post("/jmap")
         .then()
@@ -275,7 +282,7 @@ public abstract class GetMessagesMethodTest {
 
         
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("usern...@domain.tld|inbox|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();


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