JAMES-1692 setMessages.create is actually a map of ids and messages

... not just a list of message


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

Branch: refs/heads/master
Commit: 0625fb5dc4bb384c58c748c58ebb9f760718e469
Parents: 7c7f377
Author: Fabien Vignon <[email protected]>
Authored: Fri Feb 12 18:43:49 2016 +0100
Committer: Raphael Ouazana <[email protected]>
Committed: Tue Mar 1 15:42:53 2016 +0100

----------------------------------------------------------------------
 .../james/jmap/model/SetMessagesRequest.java    | 16 +++++++--------
 .../jmap/model/SetMessagesRequestTest.java      | 21 ++------------------
 2 files changed, 9 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0625fb5d/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/SetMessagesRequest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/SetMessagesRequest.java
 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/SetMessagesRequest.java
index ba81c35..aadb886 100644
--- 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/SetMessagesRequest.java
+++ 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/SetMessagesRequest.java
@@ -48,13 +48,13 @@ public class SetMessagesRequest implements JmapRequest {
 
         private String accountId;
         private String ifInState;
-        private ImmutableList.Builder<Message> create;
+        private ImmutableMap.Builder<MessageId, Message> create;
         private ImmutableMap.Builder<MessageId, 
Function<UpdateMessagePatchConverter, UpdateMessagePatch>> updatesProvider;
 
         private ImmutableList.Builder<MessageId> destroy;
 
         private Builder() {
-            create = ImmutableList.builder();
+            create = ImmutableMap.builder();
             updatesProvider = ImmutableMap.builder();
             destroy = ImmutableList.builder();
         }
@@ -73,10 +73,8 @@ public class SetMessagesRequest implements JmapRequest {
             return this;
         }
 
-        public Builder create(List<Message> create) {
-            if (create != null && !create.isEmpty()) {
-                throw new NotImplementedException();
-            }
+        public Builder create(Map<MessageId, Message> creates) {
+            this.create.putAll(creates);
             return this;
         }
 
@@ -97,11 +95,11 @@ public class SetMessagesRequest implements JmapRequest {
 
     private final Optional<String> accountId;
     private final Optional<String> ifInState;
-    private final List<Message> create;
+    private final Map<MessageId, Message> create;
     private final Map<MessageId, Function<UpdateMessagePatchConverter, 
UpdateMessagePatch>> update;
     private final List<MessageId> destroy;
 
-    @VisibleForTesting SetMessagesRequest(Optional<String> accountId, 
Optional<String> ifInState, List<Message> create, Map<MessageId, 
Function<UpdateMessagePatchConverter, UpdateMessagePatch>>  update, 
List<MessageId> destroy) {
+    @VisibleForTesting SetMessagesRequest(Optional<String> accountId, 
Optional<String> ifInState, Map<MessageId, Message> create, Map<MessageId, 
Function<UpdateMessagePatchConverter, UpdateMessagePatch>>  update, 
List<MessageId> destroy) {
         this.accountId = accountId;
         this.ifInState = ifInState;
         this.create = create;
@@ -117,7 +115,7 @@ public class SetMessagesRequest implements JmapRequest {
         return ifInState;
     }
 
-    public List<Message> getCreate() {
+    public Map<MessageId, Message> getCreate() {
         return create;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/0625fb5d/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesRequestTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesRequestTest.java
 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesRequestTest.java
index 0a079b6..7be03e1 100644
--- 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesRequestTest.java
+++ 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/SetMessagesRequestTest.java
@@ -22,7 +22,6 @@ package org.apache.james.jmap.model;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
-import java.time.ZonedDateTime;
 import java.util.Optional;
 
 import org.apache.commons.lang.NotImplementedException;
@@ -46,31 +45,15 @@ public class SetMessagesRequestTest {
     }
 
     @Test
-    public void builderShouldThrowWhenCreateIsNotEmpty() {
-        assertThatThrownBy(() -> 
SetMessagesRequest.builder().create(ImmutableList.of(Message.builder()
-                .id(MessageId.of("user|create|1"))
-                .blobId("blobId")
-                .threadId("threadId")
-                .mailboxIds(ImmutableList.of("mailboxId"))
-                .headers(ImmutableMap.of("key", "value"))
-                .subject("subject")
-                .size(123)
-                .date(ZonedDateTime.now())
-                .preview("preview")
-                .build())))
-            .isInstanceOf(NotImplementedException.class);
-    }
-
-    @Test
     public void builderShouldWork() {
         ImmutableList<MessageId> destroy = 
ImmutableList.of(MessageId.of("user|destroy|1"));
 
-        SetMessagesRequest expected = new SetMessagesRequest(Optional.empty(), 
Optional.empty(), ImmutableList.of(), ImmutableMap.of(), destroy);
+        SetMessagesRequest expected = new SetMessagesRequest(Optional.empty(), 
Optional.empty(), ImmutableMap.of(), ImmutableMap.of(), destroy);
 
         SetMessagesRequest setMessagesRequest = SetMessagesRequest.builder()
             .accountId(null)
             .ifInState(null)
-            .create(ImmutableList.of())
+            .create(ImmutableMap.of())
             .update(ImmutableMap.of())
             .destroy(destroy)
             .build();


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

Reply via email to