This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 44c66bb3f62f5d95ff45b2e7c98c5b9665b9ad6e
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Wed Oct 9 14:13:12 2024 +0200

    JAMES-2182 PathConverter: more unit tests
---
 .../org/apache/james/imap/main/PathConverter.java  |  4 ---
 .../apache/james/imap/main/PathConverterTest.java  | 38 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java 
b/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java
index 7c62d6166f..09702031d1 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java
@@ -49,10 +49,6 @@ public interface PathConverter {
     class Default implements PathConverter{
         private static final int NAMESPACE = 0;
 
-        public static PathConverter forSession(ImapSession session) {
-            return new PathConverter.Default(session);
-        }
-
         private final ImapSession session;
 
         private Default(ImapSession session) {
diff --git 
a/protocols/imap/src/test/java/org/apache/james/imap/main/PathConverterTest.java
 
b/protocols/imap/src/test/java/org/apache/james/imap/main/PathConverterTest.java
index 93d2970bd9..b98c995532 100644
--- 
a/protocols/imap/src/test/java/org/apache/james/imap/main/PathConverterTest.java
+++ 
b/protocols/imap/src/test/java/org/apache/james/imap/main/PathConverterTest.java
@@ -34,7 +34,9 @@ import org.junit.jupiter.api.Test;
 class PathConverterTest {
 
     private static final Username USERNAME = Username.of("username");
+    private static final Username USERNAME2 = Username.of("username2");
     private static final char PATH_DELIMITER = '.';
+    public static final boolean RELATIVE = true;
 
     private FakeImapSession imapSession;
     private MailboxSession mailboxSession;
@@ -105,4 +107,40 @@ class PathConverterTest {
         assertThatThrownBy(() -> pathConverter.buildFullPath("#any"))
             .isInstanceOf(DeniedAccessOnSharedMailboxException.class);
     }
+
+    @Test
+    void mailboxNameShouldReturnNameOnlyWhenRelativeAndUserMailbox() {
+        assertThat(pathConverter.mailboxName(RELATIVE, 
MailboxPath.forUser(USERNAME, "abc"), mailboxSession))
+            .isEqualTo("abc");
+    }
+
+    @Test
+    void mailboxNameShouldReturnFQDNWhenRelativeAndOtherUserMailbox() {
+        assertThat(pathConverter.mailboxName(RELATIVE, 
MailboxPath.forUser(USERNAME2, "abc"), mailboxSession))
+            .isEqualTo("#private.username2.abc");
+    }
+
+    @Test
+    void mailboxNameShouldReturnFQDNWhenRelativeAndSharedMailbox() {
+        assertThat(pathConverter.mailboxName(RELATIVE, new 
MailboxPath("#Shared", Username.of("marketing"), "abc"), mailboxSession))
+            .isEqualTo("#Shared.marketing.abc");
+    }
+
+    @Test
+    void mailboxNameShouldReturnFQDNWhenNotRelativeAndUserMailbox() {
+        assertThat(pathConverter.mailboxName(!RELATIVE, 
MailboxPath.forUser(USERNAME, "abc"), mailboxSession))
+            .isEqualTo("#private.username.abc");
+    }
+
+    @Test
+    void mailboxNameShouldReturnFQDNWhenNotRelativeAndOtherUserMailbox() {
+        assertThat(pathConverter.mailboxName(!RELATIVE, 
MailboxPath.forUser(USERNAME2, "abc"), mailboxSession))
+            .isEqualTo("#private.username2.abc");
+    }
+
+    @Test
+    void mailboxNameShouldReturnFQDNWhenNotRelativeAndSharedMailbox() {
+        assertThat(pathConverter.mailboxName(!RELATIVE, new 
MailboxPath("#Shared", Username.of("marketing"), "abc"), mailboxSession))
+            .isEqualTo("#Shared.marketing.abc");
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to