james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [2/4] james-project git commit: JAMES-2340 MailboxPath should know if it's INBOX or not
Date Wed, 04 Apr 2018 02:57:11 GMT
JAMES-2340 MailboxPath should know if it's INBOX or not


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

Branch: refs/heads/master
Commit: 612138a809c29f32bba496c6ebbed463e897e7d3
Parents: 9ddc6ff
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Fri Mar 30 15:48:01 2018 +0200
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Tue Apr 3 13:03:41 2018 +0200

----------------------------------------------------------------------
 .../apache/james/mailbox/model/MailboxPath.java  |  5 +++++
 .../james/mailbox/model/MailboxPathTest.java     | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/612138a8/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
index de5e9ef..46924a1 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
 
+import org.apache.james.mailbox.DefaultMailboxes;
 import org.apache.james.mailbox.MailboxSession;
 
 import com.google.common.collect.ImmutableList;
@@ -151,6 +152,10 @@ public class MailboxPath {
         return namespace + ":" + user + ":" + name;
     }
 
+    public boolean isInbox() {
+        return DefaultMailboxes.INBOX.equalsIgnoreCase(name);
+    }
+
     @Override
     public String toString() {
         return asString();

http://git-wip-us.apache.org/repos/asf/james-project/blob/612138a8/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxPathTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxPathTest.java
b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxPathTest.java
index 5292690..7e0d330 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxPathTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxPathTest.java
@@ -22,6 +22,7 @@ package org.apache.james.mailbox.model;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.james.mailbox.DefaultMailboxes;
 import org.junit.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;
@@ -124,4 +125,22 @@ public class MailboxPathTest {
             .isEqualTo(
                 MailboxPath.forUser("user", "a..a"));
     }
+
+    @Test
+    public void isInboxShouldReturnTrueWhenINBOX() {
+        MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, "user",
DefaultMailboxes.INBOX);
+        assertThat(mailboxPath.isInbox()).isTrue();
+    }
+
+    @Test
+    public void isInboxShouldReturnTrueWhenINBOXWithOtherCase() {
+        MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, "user",
"InBoX");
+        assertThat(mailboxPath.isInbox()).isTrue();
+    }
+
+    @Test
+    public void isInboxShouldReturnFalseWhenOtherThanInbox() {
+        MailboxPath mailboxPath = new MailboxPath(MailboxConstants.USER_NAMESPACE, "user",
DefaultMailboxes.ARCHIVE);
+        assertThat(mailboxPath.isInbox()).isFalse();
+    }
 }


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