Author: matthieu
Date: Fri Dec 11 12:36:28 2015
New Revision: 1719399

URL: http://svn.apache.org/viewvc?rev=1719399&view=rev
Log:
JAMES-1644 ids in response now use MessageId.serialize format

Modified:
    
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
    
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java

Modified: 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java?rev=1719399&r1=1719398&r2=1719399&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
 (original)
+++ 
james/project/trunk/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/methods/GetMessageListMethodTest.java
 Fri Dec 11 12:36:28 2015
@@ -65,6 +65,7 @@ public abstract class GetMessageListMeth
         .around(jmapServer);
 
     private AccessToken accessToken;
+    private String username;
 
     @Before
     public void setup() throws Exception {
@@ -72,11 +73,11 @@ public abstract class GetMessageListMeth
         RestAssured.config = 
newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
 
         String domain = "domain.tld";
-        String username = "username@" + domain;
+        this.username = "username@" + domain;
         String password = "password";
         jmapServer.serverProbe().addDomain(domain);
         jmapServer.serverProbe().addUser(username, password);
-        accessToken = JmapAuthentication.authenticateJamesUser(username, 
password);
+        this.accessToken = JmapAuthentication.authenticateJamesUser(username, 
password);
     }
 
     @Test
@@ -95,12 +96,11 @@ public abstract class GetMessageListMeth
 
     @Test
     public void 
getMessageListShouldReturnAllMessagesWhenSingleMailboxNoParameters() throws 
Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"name");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "name"), 
+        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());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "name"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -115,20 +115,20 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\",\"2\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + 
"\"messageIds\":[\"[email protected]\",\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Ignore("ISSUE-53")
     @Test
     public void 
getMessageListShouldReturnAllMessagesWhenMultipleMailboxesAndNoParameters() 
throws Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
+        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());
 
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox2");
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox2"), 
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox2");
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox2"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -149,10 +149,9 @@ public abstract class GetMessageListMeth
 
     @Test
     public void 
getMessageListShouldFilterMessagesWhenInMailboxesFilterMatches() throws 
Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        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());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -165,20 +164,29 @@ public abstract class GetMessageListMeth
             .post("/jmap")
         .then()
             .statusCode(200)
-            .content(startsWith("[[\"messageList\","
-                    + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\"]},"
-                    + "\"#0\"]]"));
+            .content(startsWith(""
+                    + "["
+                    +  "[\"messageList\","
+                    +   "{\"accountId\":null,"
+                    +    "\"filter\":null,"
+                    +    "\"sort\":[],"
+                    +    "\"collapseThreads\":false,"
+                    +    "\"state\":null,"
+                    +    "\"canCalculateUpdates\":false,"
+                    +    "\"position\":0,"
+                    +    "\"total\":0,"
+                    +    "\"threadIds\":[],"
+                    +    "\"messageIds\":[\"[email protected]\"]},"
+                    +  "\"#0\"]]"));
     }
 
     @Test
     public void 
getMessageListShouldFilterMessagesWhenMultipleInMailboxesFilterMatches() throws 
Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
+        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());
 
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox2");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox2");
         embeddedElasticSearch.awaitForElasticSearch();
 
         given()
@@ -192,16 +200,16 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + "\"messageIds\":[\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void 
getMessageListShouldFilterMessagesWhenInMailboxesFilterDoesntMatches() throws 
Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        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());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -222,13 +230,12 @@ public abstract class GetMessageListMeth
 
     @Test
     public void getMessageListShouldSortMessagesWhenSortedByDateDefault() 
throws Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -243,19 +250,19 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\",\"2\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + 
"\"messageIds\":[\"[email protected]\",\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void getMessageListShouldSortMessagesWhenSortedByDateAsc() throws 
Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -270,19 +277,19 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"2\",\"1\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + 
"\"messageIds\":[\"[email protected]\",\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void getMessageListShouldSortMessagesWhenSortedByDateDesc() throws 
Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -297,19 +304,19 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\",\"2\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + 
"\"messageIds\":[\"[email protected]\",\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void getMessageListShouldReturnAllMessagesWhenPositionIsNotGiven() 
throws Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -324,19 +331,19 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\",\"2\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + 
"\"messageIds\":[\"[email protected]\",\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void getMessageListShouldReturnSkipMessagesWhenPositionIsGiven() 
throws Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -351,19 +358,19 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"2\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + "\"messageIds\":[\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void getMessageListShouldReturnAllMessagesWhenLimitIsNotGiven() 
throws Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -378,19 +385,19 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\",\"2\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + 
"\"messageIds\":[\"[email protected]\",\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void getMessageListShouldReturnLimitMessagesWhenLimitGiven() throws 
Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -405,23 +412,23 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + "\"messageIds\":[\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 
     @Test
     public void 
getMessageListShouldReturnLimitMessagesWithDefaultValueWhenLimitIsNotGiven() 
throws Exception {
-        String user = "user";
-        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, user, 
"mailbox");
+        
jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, 
username, "mailbox");
 
         LocalDate date = LocalDate.now();
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test\r\n\r\ntestmail".getBytes()), new Date(date.plusDays(1).toEpochDay()), 
false, new Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test2\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test3\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
-        jmapServer.serverProbe().appendMessage(user, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, user, "mailbox"), 
+        jmapServer.serverProbe().appendMessage(username, new 
MailboxPath(MailboxConstants.USER_NAMESPACE, username, "mailbox"), 
                 new ByteArrayInputStream("Subject: 
test4\r\n\r\ntestmail".getBytes()), new Date(date.toEpochDay()), false, new 
Flags());
         embeddedElasticSearch.awaitForElasticSearch();
 
@@ -436,7 +443,8 @@ public abstract class GetMessageListMeth
             .statusCode(200)
             .content(startsWith("[[\"messageList\","
                     + 
"{\"accountId\":null,\"filter\":null,\"sort\":[],\"collapseThreads\":false,\"state\":null,"
-                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],\"messageIds\":[\"1\",\"2\",\"3\"]},"
+                    +   
"\"canCalculateUpdates\":false,\"position\":0,\"total\":0,\"threadIds\":[],"
+                    + 
"\"messageIds\":[\"[email protected]\",\"[email protected]\",\"[email protected]\"]},"
                     + "\"#0\"]]"));
     }
 }

Modified: 
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
URL: 
http://svn.apache.org/viewvc/james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java?rev=1719399&r1=1719398&r2=1719399&view=diff
==============================================================================
--- 
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
 (original)
+++ 
james/project/trunk/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
 Fri Dec 11 12:36:28 2015
@@ -23,6 +23,7 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -31,6 +32,7 @@ import org.apache.james.jmap.methods.Met
 import org.apache.james.jmap.model.FilterCondition;
 import org.apache.james.jmap.model.GetMessageListRequest;
 import org.apache.james.jmap.model.GetMessageListResponse;
+import org.apache.james.jmap.model.MessageId;
 import org.apache.james.jmap.utils.SortToComparatorConvertor;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -108,18 +110,21 @@ public class GetMessageListMethod<Id ext
         mailboxManager.list(mailboxSession)
             .stream()
             .filter(mailboxPath -> isMailboxRequested(jmapRequest, 
mailboxPath))
-            .map(mailboxPath -> getMessages(mailboxPath, mailboxSession))
-            .flatMap(List::stream)
-            .sorted(comparatorFor(jmapRequest))
+            .flatMap(mailboxPath -> listMessages(mailboxPath, mailboxSession, 
jmapRequest))
             .skip(jmapRequest.getPosition())
             .limit(limit(jmapRequest.getLimit()))
-            .map(Message::getUid)
-            .map(String::valueOf)
+            .map(MessageId::serialize)
             .forEach(builder::messageId);
 
         return builder.build();
     }
 
+    private Stream<MessageId> listMessages(MailboxPath mailboxPath, 
MailboxSession mailboxSession, GetMessageListRequest jmapRequest) {
+        return getMessages(mailboxPath, mailboxSession).stream()
+                .sorted(comparatorFor(jmapRequest))
+                .map(message -> new MessageId(mailboxSession.getUser(), 
mailboxPath, message.getUid()));
+    }
+    
     private long limit(Optional<Integer> limit) {
         return limit.orElse(maximumLimit);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to