james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [2/4] james-project git commit: JAMES-1712 Mailbox parentId is empty be default
Date Mon, 04 Apr 2016 14:28:09 GMT
JAMES-1712 Mailbox parentId is empty be default


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

Branch: refs/heads/master
Commit: 64ff43e6a86bab3e057511274898e93e02ed3c09
Parents: beaecf7
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Tue Mar 29 15:34:05 2016 +0200
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Mon Apr 4 16:27:11 2016 +0200

----------------------------------------------------------------------
 .../org/apache/james/jmap/model/mailbox/Mailbox.java    |  7 ++++---
 .../apache/james/jmap/model/mailbox/MailboxTest.java    | 12 ++++++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/64ff43e6/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Mailbox.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Mailbox.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Mailbox.java
index a0b5d70..6c3330d 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Mailbox.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Mailbox.java
@@ -44,7 +44,7 @@ public class Mailbox {
 
         private String id;
         private String name;
-        private String parentId;
+        private Optional<String> parentId;
         private Optional<Role> role;
         private SortOrder sortOrder;
         private boolean mustBeOnlyMailbox;
@@ -60,6 +60,7 @@ public class Mailbox {
         private long unreadThreads;
 
         private Builder() {
+            parentId = Optional.empty();
         }
 
         public Builder id(String id) {
@@ -75,7 +76,7 @@ public class Mailbox {
         }
 
         public Builder parentId(String parentId) {
-            this.parentId = parentId;
+            this.parentId = Optional.ofNullable(parentId);
             return this;
         }
 
@@ -148,7 +149,7 @@ public class Mailbox {
             Preconditions.checkState(!Strings.isNullOrEmpty(name), "'name' is mandatory");
             Preconditions.checkState(!Strings.isNullOrEmpty(id), "'id' is mandatory");
 
-            return new Mailbox(id, name, Optional.ofNullable(parentId), role, sortOrder,
mustBeOnlyMailbox, mayReadItems, mayAddItems, mayRemoveItems, mayCreateChild, mayRename, mayDelete,
+            return new Mailbox(id, name, parentId, role, sortOrder, mustBeOnlyMailbox, mayReadItems,
mayAddItems, mayRemoveItems, mayCreateChild, mayRename, mayDelete,
                     totalMessages, unreadMessages, totalThreads, unreadThreads);
         }
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/64ff43e6/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
index 6510ba4..760d890 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/MailboxTest.java
@@ -23,8 +23,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Optional;
 
-import org.apache.james.jmap.model.mailbox.Mailbox;
-import org.apache.james.jmap.model.mailbox.Role;
 import org.junit.Test;
 
 public class MailboxTest {
@@ -94,4 +92,14 @@ public class MailboxTest {
 
         assertThat(mailbox).isEqualToComparingFieldByField(expectedMailbox);
     }
+
+    @Test
+    public void parentIdDefaultValueIsEmpty() {
+        Mailbox mailbox = Mailbox.builder()
+            .id("id")
+            .name("name")
+            .build();
+
+        assertThat(mailbox.getParentId()).isEmpty();
+    }
 }


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