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-1681 Chain GetMessages to GetMessageList
Date Thu, 04 Feb 2016 13:15:01 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 409344c12 -> 6725117b8


JAMES-1681 Chain GetMessages to GetMessageList


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

Branch: refs/heads/master
Commit: 6725117b864711f5aa6a548cc7721be8a2820689
Parents: 409344c
Author: Antoine Duprat <antduprat@gmail.com>
Authored: Fri Jan 29 15:54:59 2016 +0100
Committer: Antoine Duprat <antduprat@gmail.com>
Committed: Thu Feb 4 14:14:24 2016 +0100

----------------------------------------------------------------------
 .../jmap/methods/GetMessageListMethodTest.java  | 60 +++++++++++++++-----
 .../jmap/methods/GetMessageListMethod.java      | 54 ++++++++++++------
 .../james/jmap/model/GetMessageListRequest.java |  3 +-
 .../jmap/model/GetMessageListResponse.java      | 17 ++----
 .../james/jmap/model/GetMessagesRequest.java    |  5 +-
 .../jmap/methods/GetMessagesMethodTest.java     | 16 +++---
 .../GetMailboxMessageListResponseTest.java      |  2 +-
 .../jmap/model/GetMessageListRequestTest.java   |  8 +--
 .../jmap/model/GetMessagesRequestTest.java      | 10 ++--
 9 files changed, 111 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/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 ddfbf30..91b4d33 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
@@ -25,6 +25,7 @@ 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.hasSize;
 import static org.hamcrest.Matchers.startsWith;
 
 import java.io.ByteArrayInputStream;
@@ -48,7 +49,10 @@ 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;
 
@@ -69,11 +73,15 @@ 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;
@@ -120,7 +128,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
         
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
     }
 
@@ -148,7 +156,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
         
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox2|1");
     }
 
@@ -181,7 +189,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
         
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|1");
     }
 
@@ -216,7 +224,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|1");
     }
 
@@ -241,7 +249,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .isEmpty();
     }
 
@@ -269,7 +277,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsExactly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
     }
 
@@ -297,7 +305,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsExactly("username@domain.tld|mailbox|2", "username@domain.tld|mailbox|1");
     }
 
@@ -325,7 +333,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsExactly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
     }
 
@@ -381,7 +389,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
     }
 
@@ -409,7 +417,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|2");
     }
 
@@ -437,7 +445,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|1", "username@domain.tld|mailbox|2");
     }
 
@@ -465,7 +473,7 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        assertThat(jsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
             .containsOnly("username@domain.tld|mailbox|1");
     }
 
@@ -497,7 +505,33 @@ public abstract class GetMessageListMethodTest {
             .extract()
             .asString();
 
-        assertThat(JsonPath.parse(response).<List<String>>read("$.[0].[1].messageIds"))
+        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");
     }
+
+    @Test
+    public void getMessageListShouldChainFetchingMessagesWhenAskedFor() throws Exception
{
+        jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username,
"mailbox");
+
+        LocalDate date = LocalDate.now();
+        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());
+        embeddedElasticSearch.awaitForElasticSearch();
+
+        given()
+            .accept(ContentType.JSON)
+            .contentType(ContentType.JSON)
+            .header("Authorization", accessToken.serialize())
+            .body("[[\"getMessageList\", {\"fetchMessages\":true}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body("[0][0]", equalTo("messageList"))
+            .body("[1][0]", equalTo("messages"))
+            .body("[0][1].messageIds", hasSize(1))
+            .body("[0][1].messageIds[0]", equalTo("username@domain.tld|mailbox|1"))
+            .body("[1][1].list", hasSize(1))
+            .body("[1][1].list[0].id", equalTo("username@domain.tld|mailbox|1"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
index f65dc42..b2a1e5f 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
@@ -32,6 +32,7 @@ import org.apache.james.jmap.model.ClientId;
 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.GetMessagesRequest;
 import org.apache.james.jmap.model.MessageId;
 import org.apache.james.jmap.utils.SortToComparatorConvertor;
 import org.apache.james.mailbox.MailboxManager;
@@ -73,14 +74,16 @@ public class GetMessageListMethod<Id extends MailboxId> implements
Method {
     private final MailboxManager mailboxManager;
     private final MailboxSessionMapperFactory<Id> mailboxSessionMapperFactory;
     private final int maximumLimit;
+    private final GetMessagesMethod<Id> getMessagesMethod;
 
     @Inject
     @VisibleForTesting public GetMessageListMethod(MailboxManager mailboxManager, MailboxSessionMapperFactory<Id>
mailboxSessionMapperFactory,
-            @Named(MAXIMUM_LIMIT) int maximumLimit) {
+            @Named(MAXIMUM_LIMIT) int maximumLimit, GetMessagesMethod<Id> getMessagesMethod)
{
 
         this.mailboxManager = mailboxManager;
         this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
         this.maximumLimit = maximumLimit;
+        this.getMessagesMethod = getMessagesMethod;
     }
 
     @Override
@@ -96,24 +99,27 @@ public class GetMessageListMethod<Id extends MailboxId> implements
Method {
     @Override
     public Stream<JmapResponse> process(JmapRequest request, ClientId clientId, MailboxSession
mailboxSession) {
         Preconditions.checkArgument(request instanceof GetMessageListRequest);
-        return Stream.of(
-                JmapResponse.builder().clientId(clientId)
-                .response(getMessageListResponse((GetMessageListRequest) request, mailboxSession))
+        GetMessageListRequest messageListRequest = (GetMessageListRequest) request;
+        GetMessageListResponse messageListResponse = getMessageListResponse(messageListRequest,
clientId, mailboxSession);
+ 
+        Stream<JmapResponse> jmapResponse = Stream.of(JmapResponse.builder().clientId(clientId)
+                .response(messageListResponse)
                 .responseName(RESPONSE_NAME)
                 .build());
+        return Stream.<JmapResponse> concat(jmapResponse, 
+                processGetMessages(messageListRequest, messageListResponse, clientId, mailboxSession));
     }
 
-    private GetMessageListResponse getMessageListResponse(GetMessageListRequest jmapRequest,
MailboxSession mailboxSession) {
+    private GetMessageListResponse getMessageListResponse(GetMessageListRequest messageListRequest,
ClientId clientId, MailboxSession mailboxSession) {
         GetMessageListResponse.Builder builder = GetMessageListResponse.builder();
         try {
 
             List<MailboxPath> mailboxPaths = mailboxManager.list(mailboxSession);
-            listRequestedMailboxes(jmapRequest, mailboxPaths, mailboxSession)
+            listRequestedMailboxes(messageListRequest, mailboxPaths, mailboxSession)
                 .stream()
-                .flatMap(mailboxPath -> listMessages(mailboxPath, mailboxSession, jmapRequest))
-                .skip(jmapRequest.getPosition())
-                .limit(limit(jmapRequest.getLimit()))
-                .map(MessageId::serialize)
+                .flatMap(mailboxPath -> listMessages(mailboxPath, mailboxSession, messageListRequest))
+                .skip(messageListRequest.getPosition())
+                .limit(limit(messageListRequest.getLimit()))
                 .forEach(builder::messageId);
 
             return builder.build();
@@ -122,9 +128,25 @@ public class GetMessageListMethod<Id extends MailboxId> implements
Method {
         }
     }
 
-    private Stream<MessageId> listMessages(MailboxPath mailboxPath, MailboxSession
mailboxSession, GetMessageListRequest jmapRequest) {
+    private Stream<JmapResponse> processGetMessages(GetMessageListRequest messageListRequest,
GetMessageListResponse messageListResponse, ClientId clientId, MailboxSession mailboxSession)
{
+        if (shouldChainToGetMessages(messageListRequest)) {
+            GetMessagesRequest getMessagesRequest = GetMessagesRequest.builder()
+                    .ids(messageListResponse.getMessageIds())
+                    .properties(messageListRequest.getFetchMessageProperties())
+                    .build();
+            return getMessagesMethod.process(getMessagesRequest, clientId, mailboxSession);
+        }
+        return Stream.empty();
+    }
+
+    private boolean shouldChainToGetMessages(GetMessageListRequest messageListRequest) {
+        return messageListRequest.isFetchMessages().orElse(false) 
+                && !messageListRequest.isFetchThreads().orElse(false);
+    }
+
+    private Stream<MessageId> listMessages(MailboxPath mailboxPath, MailboxSession
mailboxSession, GetMessageListRequest messageListRequest) {
         return getMessages(mailboxPath, mailboxSession).stream()
-                .sorted(comparatorFor(jmapRequest))
+                .sorted(comparatorFor(messageListRequest))
                 .map(message -> new MessageId(mailboxSession.getUser(), mailboxPath, message.getUid()));
     }
     
@@ -132,13 +154,13 @@ public class GetMessageListMethod<Id extends MailboxId> implements
Method {
         return limit.orElse(maximumLimit);
     }
 
-    private Comparator<MailboxMessage<Id>> comparatorFor(GetMessageListRequest
jmapRequest) {
-        return SortToComparatorConvertor.comparatorFor(jmapRequest.getSort());
+    private Comparator<MailboxMessage<Id>> comparatorFor(GetMessageListRequest
messageListRequest) {
+        return SortToComparatorConvertor.comparatorFor(messageListRequest.getSort());
     }
 
-    private ImmutableSet<MailboxPath> listRequestedMailboxes(GetMessageListRequest
jmapRequest, List<MailboxPath> mailboxPaths, MailboxSession session) {
+    private ImmutableSet<MailboxPath> listRequestedMailboxes(GetMessageListRequest
messageListRequest, List<MailboxPath> mailboxPaths, MailboxSession session) {
         ImmutableSet<MailboxPath> mailboxPathSet = ImmutableSet.copyOf(mailboxPaths);
-        return jmapRequest.getFilter()
+        return messageListRequest.getFilter()
             .filter(FilterCondition.class::isInstance)
             .map(FilterCondition.class::cast)
             .map(FilterCondition::getInMailboxes)

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListRequest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListRequest.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListRequest.java
index e056d66..7f67006 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListRequest.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListRequest.java
@@ -101,7 +101,8 @@ public class GetMessageListRequest implements JmapRequest {
         }
 
         public Builder fetchMessages(boolean fetchMessages) {
-            throw new NotImplementedException();
+            this.fetchMessages = fetchMessages;
+            return this;
         }
 
         public Builder fetchMessageProperties(List<String> fetchMessageProperties)
{

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListResponse.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListResponse.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListResponse.java
index fdec79d..c3f9c78 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListResponse.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessageListResponse.java
@@ -44,7 +44,7 @@ public class GetMessageListResponse implements Method.Response {
         private int position;
         private int total;
         private final ImmutableList.Builder<String> threadIds;
-        private final ImmutableList.Builder<String> messageIds;
+        private final ImmutableList.Builder<MessageId> messageIds;
 
         private Builder() {
             sort = ImmutableList.builder();
@@ -90,17 +90,12 @@ public class GetMessageListResponse implements Method.Response {
             throw new NotImplementedException();
         }
 
-        public Builder messageId(String messageId) {
+        public Builder messageId(MessageId messageId) {
             this.messageIds.add(messageId);
             return this;
         }
 
-        public Builder messageId(long messageId) {
-            this.messageIds.add(String.valueOf(messageId));
-            return this;
-        }
-
-        public Builder messageIds(List<String> messageIds) {
+        public Builder messageIds(List<MessageId> messageIds) {
             this.messageIds.addAll(messageIds);
             return this;
         }
@@ -120,10 +115,10 @@ public class GetMessageListResponse implements Method.Response {
     private final int position;
     private final int total;
     private final List<String> threadIds;
-    private final List<String> messageIds;
+    private final List<MessageId> messageIds;
 
     @VisibleForTesting GetMessageListResponse(String accountId, Filter filter, List<String>
sort, boolean collapseThreads, String state,
-            boolean canCalculateUpdates, int position, int total, List<String> threadIds,
List<String> messageIds) {
+            boolean canCalculateUpdates, int position, int total, List<String> threadIds,
List<MessageId> messageIds) {
 
         this.accountId = accountId;
         this.filter = filter;
@@ -173,7 +168,7 @@ public class GetMessageListResponse implements Method.Response {
         return threadIds;
     }
 
-    public List<String> getMessageIds() {
+    public List<MessageId> getMessageIds() {
         return messageIds;
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessagesRequest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessagesRequest.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessagesRequest.java
index 4b67c55..651b829 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessagesRequest.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/GetMessagesRequest.java
@@ -18,7 +18,6 @@
  ****************************************************************/
 package org.apache.james.jmap.model;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
 
@@ -54,8 +53,8 @@ public class GetMessagesRequest implements JmapRequest {
             return this;
         }
 
-        public Builder ids(MessageId... ids) {
-            this.ids.addAll(Arrays.asList(ids));
+        public Builder ids(List<MessageId> ids) {
+            this.ids.addAll(ids);
             return this;
         }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
index ada2182..9447dd2 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
@@ -160,9 +160,9 @@ public class GetMessagesMethodTest {
         long message3Uid = inbox.appendMessage(message3Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
-                .ids(new MessageId(ROBERT, inboxPath, message1Uid),
+                .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid),
                           new MessageId(ROBERT, inboxPath, message2Uid),
-                          new MessageId(ROBERT, inboxPath, message3Uid))
+                          new MessageId(ROBERT, inboxPath, message3Uid)))
                 .build();
 
         GetMessagesMethod<InMemoryId> testee = new GetMessagesMethod<>(mailboxSessionMapperFactory,
mailboxSessionMapperFactory);
@@ -188,7 +188,7 @@ public class GetMessagesMethodTest {
         long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
-                .ids(new MessageId(ROBERT, inboxPath, message1Uid))
+                .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
                 .properties(ImmutableList.of())
                 .build();
 
@@ -210,7 +210,7 @@ public class GetMessagesMethodTest {
         long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
-                .ids(new MessageId(ROBERT, inboxPath, message1Uid))
+                .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
                 .build();
 
         GetMessagesMethod<InMemoryId> testee = new GetMessagesMethod<>(mailboxSessionMapperFactory,
mailboxSessionMapperFactory);
@@ -231,7 +231,7 @@ public class GetMessagesMethodTest {
         long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
-                .ids(new MessageId(ROBERT, inboxPath, message1Uid))
+                .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
                 .properties(ImmutableList.of(MessageProperty.subject.asFieldName()))
                 .build();
 
@@ -255,7 +255,7 @@ public class GetMessagesMethodTest {
         long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
-                .ids(new MessageId(ROBERT, inboxPath, message1Uid))
+                .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
                 .properties(ImmutableList.of(MessageProperty.body.asFieldName()))
                 .build();
 
@@ -282,7 +282,7 @@ public class GetMessagesMethodTest {
         long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
-                .ids(new MessageId(ROBERT, inboxPath, message1Uid))
+                .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
                 .properties(ImmutableList.of("headers.from", "headers.heADER2"))
                 .build();
 
@@ -310,7 +310,7 @@ public class GetMessagesMethodTest {
         long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
-                .ids(new MessageId(ROBERT, inboxPath, message1Uid))
+                .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
                 .properties(ImmutableList.of("headers.from", "headers.heADER2"))
                 .build();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxMessageListResponseTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxMessageListResponseTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxMessageListResponseTest.java
index 48b32d4..3c04ce5 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxMessageListResponseTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMailboxMessageListResponseTest.java
@@ -71,7 +71,7 @@ public class GetMailboxMessageListResponseTest {
                 .inMailboxes(ImmutableList.of("1", "2"))
                 .build();
         List<String> sort = ImmutableList.of("date desc");
-        List<String> messageIds = ImmutableList.of("3", "4");
+        List<MessageId> messageIds = ImmutableList.of(MessageId.of("user|mailbox|3"),
MessageId.of("user|mailbox|4"));
         GetMessageListResponse expectedGetMessageListResponse = new GetMessageListResponse(null,
filterCondition, sort, false, null, false, 0, 0, ImmutableList.of(), messageIds);
 
         GetMessageListResponse getMessageListResponse = GetMessageListResponse.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessageListRequestTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessageListRequestTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessageListRequestTest.java
index 80557c5..6ed8c68 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessageListRequestTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessageListRequestTest.java
@@ -62,11 +62,6 @@ public class GetMessageListRequestTest {
     }
 
     @Test(expected=NotImplementedException.class)
-    public void builderShouldThrowWhenFetchMessages() {
-        GetMessageListRequest.builder().fetchMessages(false);
-    }
-
-    @Test(expected=NotImplementedException.class)
     public void builderShouldThrowWhenFetchSearchSnippets() {
         GetMessageListRequest.builder().fetchSearchSnippets(false);
     }
@@ -79,7 +74,7 @@ public class GetMessageListRequestTest {
         List<String> sort = ImmutableList.of("date desc");
         List<String> fetchMessageProperties = ImmutableList.of("id", "blobId");
         GetMessageListRequest expectedGetMessageListRequest = new GetMessageListRequest(Optional.empty(),
Optional.of(filterCondition), sort, Optional.of(true), 1, Optional.empty(), Optional.empty(),
Optional.of(2),
-                Optional.empty(), Optional.empty(), fetchMessageProperties, Optional.empty());
+                Optional.empty(), Optional.of(true), fetchMessageProperties, Optional.empty());
 
         GetMessageListRequest getMessageListRequest = GetMessageListRequest.builder()
             .filter(filterCondition)
@@ -87,6 +82,7 @@ public class GetMessageListRequestTest {
             .collapseThreads(true)
             .position(1)
             .limit(2)
+            .fetchMessages(true)
             .fetchMessageProperties(fetchMessageProperties)
             .build();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/6725117b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
index 2d81ba9..ef892f6 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/GetMessagesRequestTest.java
@@ -33,7 +33,7 @@ public class GetMessagesRequestTest {
     @Test
     public void shouldAllowOptionalAccountId() {
         GetMessagesRequest result = GetMessagesRequest.builder()
-                .ids(MessageId.of("user|inbox|1"))
+                .ids(ImmutableList.of(MessageId.of("user|inbox|1")))
                 .build();
         assertThat(result).isNotNull();
         assertThat(result.getAccountId()).isEmpty();
@@ -49,7 +49,7 @@ public class GetMessagesRequestTest {
     public void shouldAllowEmptyMessagesList() {
         GetMessagesRequest result = GetMessagesRequest.builder()
                 .accountId("accountId")
-                .ids()
+                .ids(ImmutableList.of())
                 .build();
         assertThat(result).isNotNull();
         assertThat(result.getIds()).isEmpty();
@@ -59,7 +59,7 @@ public class GetMessagesRequestTest {
     public void shouldAllowAbsentPropertyList() {
         GetMessagesRequest result = GetMessagesRequest.builder()
                 .accountId("accountId")
-                .ids()
+                .ids(ImmutableList.of())
                 .build();
         assertThat(result).isNotNull();
         assertThat(result.getProperties().getOptionalMessageProperties()).isEmpty();
@@ -70,7 +70,7 @@ public class GetMessagesRequestTest {
     public void shouldAllowEmptyPropertyList() {
         GetMessagesRequest result = GetMessagesRequest.builder()
                 .accountId("accountId")
-                .ids()
+                .ids(ImmutableList.of())
                 .properties(ImmutableList.of())
                 .build();
         assertThat(result).isNotNull();
@@ -82,7 +82,7 @@ public class GetMessagesRequestTest {
     public void shouldConvertPropertiesWhenMessageAndHeaderPropertiesAreGiven() {
         GetMessagesRequest result = GetMessagesRequest.builder()
                 .accountId("accountId")
-                .ids()
+                .ids(ImmutableList.of())
                 .properties(ImmutableList.of("id", "headers.subject", "threadId", "headers.test"))
                 .build();
         assertThat(result).isNotNull();


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