james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [10/10] james-project git commit: JAMES-1818 Remove useless calls of MailboxUtils
Date Mon, 05 Sep 2016 12:44:06 GMT
JAMES-1818 Remove useless calls of MailboxUtils


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

Branch: refs/heads/master
Commit: 268f001185bf3bd7a41ff6940b38241fd99dca89
Parents: df3a8a0
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Wed Aug 31 16:40:58 2016 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Mon Sep 5 14:42:01 2016 +0200

----------------------------------------------------------------------
 .../jmap/methods/GetMessageListMethod.java      |  12 +-
 .../methods/SetMailboxesCreationProcessor.java  |  18 ++-
 .../SetMailboxesDestructionProcessor.java       |   4 +-
 .../methods/SetMailboxesUpdateProcessor.java    |  22 ++--
 .../apache/james/jmap/utils/MailboxUtils.java   |  26 ----
 .../SetMailboxesCreationProcessorTest.java      |   6 +-
 .../SetMailboxesUpdateProcessorTest.java        |   7 +-
 .../james/jmap/utils/MailboxUtilsTest.java      | 123 -------------------
 8 files changed, 44 insertions(+), 174 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/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 5b476ef..f2a859b 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
@@ -39,7 +39,6 @@ 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.FilterToSearchQuery;
-import org.apache.james.jmap.utils.MailboxUtils;
 import org.apache.james.jmap.utils.SortToComparatorConvertor;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
@@ -78,17 +77,15 @@ public class GetMessageListMethod implements Method {
     private final MailboxManager mailboxManager;
     private final int maximumLimit;
     private final GetMessagesMethod getMessagesMethod;
-    private final MailboxUtils mailboxUtils;
     private final Factory mailboxIdFactory;
 
     @Inject
     @VisibleForTesting public GetMessageListMethod(MailboxManager mailboxManager,
-            @Named(MAXIMUM_LIMIT) int maximumLimit, GetMessagesMethod getMessagesMethod,
MailboxUtils mailboxUtils, MailboxId.Factory mailboxIdFactory) {
+            @Named(MAXIMUM_LIMIT) int maximumLimit, GetMessagesMethod getMessagesMethod,
MailboxId.Factory mailboxIdFactory) {
 
         this.mailboxManager = mailboxManager;
         this.maximumLimit = maximumLimit;
         this.getMessagesMethod = getMessagesMethod;
-        this.mailboxUtils = mailboxUtils;
         this.mailboxIdFactory = mailboxIdFactory;
     }
 
@@ -140,7 +137,7 @@ public class GetMessageListMethod implements Method {
         for (Map.Entry<MailboxId, Collection<Long>> mailboxResults: searchResults.entrySet())
{
             try {
                 aggregate(mailboxSession, messages, mailboxResults);
-            } catch (MailboxNotFoundException e) {
+            } catch (MailboxException e) {
                 LOGGER.error("Error retrieving mailbox", e);
                 throw Throwables.propagate(e);
             }
@@ -148,9 +145,8 @@ public class GetMessageListMethod implements Method {
         return messages;
     }
 
-    private void aggregate(MailboxSession mailboxSession, Multimap<MailboxPath, MessageResult>
aggregation, Map.Entry<MailboxId, Collection<Long>> mailboxResults) throws MailboxNotFoundException
{
-        MailboxPath mailboxPath = mailboxUtils.mailboxPathFromMailboxId(mailboxResults.getKey(),
mailboxSession)
-            .orElseThrow(() -> new MailboxNotFoundException(mailboxResults.getKey().serialize()));
+    private void aggregate(MailboxSession mailboxSession, Multimap<MailboxPath, MessageResult>
aggregation, Map.Entry<MailboxId, Collection<Long>> mailboxResults) throws MailboxNotFoundException,
MailboxException {
+        MailboxPath mailboxPath = mailboxManager.getMailbox(mailboxResults.getKey(), mailboxSession).getMailboxPath();
         MessageManager messageManager = getMessageManager(mailboxPath, mailboxSession)
             .orElseThrow(() -> new MailboxNotFoundException(mailboxPath));
         List<MessageResult> mailboxMessages = MessageRange.toRanges(mailboxResults.getValue()).stream()

http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
index cc4cb4d..01dc2d7 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessor.java
@@ -40,6 +40,7 @@ import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
+import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxId.Factory;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -144,7 +145,7 @@ public class SetMailboxesCreationProcessor implements SetMailboxesProcessor
{
             MailboxCreationId parentId = mailboxRequest.getParentId().get();
             String parentName = getMailboxNameFromId(parentId, mailboxSession)
                     .orElseGet(Throwing.supplier(() ->
-                        mailboxUtils.getMailboxNameFromId(creationIdsToCreatedMailboxId.get(parentId),
mailboxSession)
+                        getMailboxNameFromId(creationIdsToCreatedMailboxId.get(parentId),
mailboxSession)
                             .orElseThrow(() -> new MailboxParentNotFoundException(parentId))
                     ));
 
@@ -155,7 +156,7 @@ public class SetMailboxesCreationProcessor implements SetMailboxesProcessor
{
     }
 
     private Optional<String> getMailboxNameFromId(MailboxCreationId creationId, MailboxSession
mailboxSession) {
-        ThrowingFunction<? super MailboxId, Optional<String>> toName = parentId
-> mailboxUtils.getMailboxNameFromId(parentId, mailboxSession);
+        ThrowingFunction<? super MailboxId, Optional<String>> toName = parentId
-> getMailboxNameFromId(parentId, mailboxSession);
         return getMailboxIdFromCreationId(creationId)
                 .flatMap(Throwing.function(toName).sneakyThrow());
     }
@@ -167,4 +168,17 @@ public class SetMailboxesCreationProcessor implements SetMailboxesProcessor
{
             return Optional.empty();
         }
     }
+
+    @VisibleForTesting
+    Optional<String> getMailboxNameFromId(MailboxId mailboxId, MailboxSession mailboxSession)
throws MailboxException {
+        if (mailboxId == null) {
+            return Optional.empty();
+        }
+        try {
+            return Optional.of(mailboxManager.getMailbox(mailboxId, mailboxSession).getMailboxPath().getName());
+        } catch (MailboxNotFoundException e) {
+            return Optional.empty();
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesDestructionProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesDestructionProcessor.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesDestructionProcessor.java
index 9fa4aab..a777c44 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesDestructionProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesDestructionProcessor.java
@@ -39,6 +39,7 @@ import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -96,7 +97,8 @@ public class SetMailboxesDestructionProcessor implements SetMailboxesProcessor
{
             Mailbox mailbox = entry.getValue();
             preconditions(mailbox, mailboxSession);
 
-            mailboxManager.deleteMailbox(mailboxUtils.getMailboxPath(mailbox, mailboxSession),
mailboxSession);
+            MailboxPath mailboxPath = mailboxManager.getMailbox(mailbox.getId(), mailboxSession).getMailboxPath();
+            mailboxManager.deleteMailbox(mailboxPath, mailboxSession);
             builder.destroyed(entry.getKey());
         } catch (MailboxHasChildException e) {
             builder.notDestroyed(entry.getKey(), SetError.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java
index 69a07fe..438e101 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java
@@ -43,6 +43,8 @@ import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 
+import com.github.fge.lambdas.Throwing;
+import com.github.fge.lambdas.functions.ThrowingFunction;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Splitter;
 import com.google.common.collect.Iterables;
@@ -156,8 +158,11 @@ public class SetMailboxesUpdateProcessor implements SetMailboxesProcessor
{
 
         if (isParentIdInRequest(updateRequest)) {
             MailboxId newParentId = updateRequest.getParentId().get();
-            mailboxUtils.mailboxPathFromMailboxId(newParentId, mailboxSession)
-                    .orElseThrow(() -> new MailboxParentNotFoundException(newParentId));
+            try {
+                mailboxManager.getMailbox(newParentId, mailboxSession);
+            } catch (MailboxNotFoundException e) {
+                throw new MailboxParentNotFoundException(newParentId);
+            }
             if (mustChangeParent(mailbox.getParentId(), newParentId) && mailboxUtils.hasChildren(mailbox.getId(),
mailboxSession)) {
                 throw new MailboxHasChildException();
             }
@@ -176,14 +181,14 @@ public class SetMailboxesUpdateProcessor implements SetMailboxesProcessor
{
     }
 
     private void updateMailbox(Mailbox mailbox, MailboxUpdateRequest updateRequest, MailboxSession
mailboxSession) throws MailboxException {
-        MailboxPath originMailboxPath = mailboxUtils.getMailboxPath(mailbox, mailboxSession);
+        MailboxPath originMailboxPath = mailboxManager.getMailbox(mailbox.getId(), mailboxSession).getMailboxPath();
         MailboxPath destinationMailboxPath = computeNewMailboxPath(mailbox, originMailboxPath,
updateRequest, mailboxSession);
         if (!originMailboxPath.equals(destinationMailboxPath)) {
             mailboxManager.renameMailbox(originMailboxPath, destinationMailboxPath, mailboxSession);
         }
     }
 
-    private MailboxPath computeNewMailboxPath(Mailbox mailbox, MailboxPath originMailboxPath,
MailboxUpdateRequest updateRequest, MailboxSession mailboxSession) {
+    private MailboxPath computeNewMailboxPath(Mailbox mailbox, MailboxPath originMailboxPath,
MailboxUpdateRequest updateRequest, MailboxSession mailboxSession) throws MailboxException
{
         Optional<MailboxId> parentId = updateRequest.getParentId();
         if (parentId == null) {
             return new MailboxPath(mailboxSession.getPersonalSpace(), 
@@ -194,8 +199,9 @@ public class SetMailboxesUpdateProcessor implements SetMailboxesProcessor
{
         MailboxPath modifiedMailboxPath = updateRequest.getName()
                 .map(newName -> computeMailboxPathWithNewName(originMailboxPath, newName))
                 .orElse(originMailboxPath);
+        ThrowingFunction<MailboxId, MailboxPath> computeNewMailboxPath = parentMailboxId
-> computeMailboxPathWithNewParentId(modifiedMailboxPath, parentMailboxId, mailboxSession);
         return parentId
-                .map(parentMailboxId -> computeMailboxPathWithNewParentId(modifiedMailboxPath,
parentMailboxId, mailboxSession))
+                .map(Throwing.function(computeNewMailboxPath).sneakyThrow())
                 .orElse(modifiedMailboxPath);
     }
 
@@ -203,10 +209,10 @@ public class SetMailboxesUpdateProcessor implements SetMailboxesProcessor
{
         return new MailboxPath(originMailboxPath, newName);
     }
 
-    private MailboxPath computeMailboxPathWithNewParentId(MailboxPath originMailboxPath,
MailboxId parentMailboxId, MailboxSession mailboxSession) {
-        Optional<MailboxPath> newParentMailboxPath = mailboxUtils.mailboxPathFromMailboxId(parentMailboxId,
mailboxSession);
+    private MailboxPath computeMailboxPathWithNewParentId(MailboxPath originMailboxPath,
MailboxId parentMailboxId, MailboxSession mailboxSession) throws MailboxException {
+        MailboxPath newParentMailboxPath = mailboxManager.getMailbox(parentMailboxId, mailboxSession).getMailboxPath();
         String lastName = getCurrentMailboxName(originMailboxPath, mailboxSession);
-        return new MailboxPath(originMailboxPath, newParentMailboxPath.get().getName() +
mailboxSession.getPathDelimiter() + lastName);
+        return new MailboxPath(originMailboxPath, newParentMailboxPath.getName() + mailboxSession.getPathDelimiter()
+ lastName);
     }
 
     private String getCurrentMailboxName(MailboxPath originMailboxPath, MailboxSession mailboxSession)
{

http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
index bfb9acc..666b149 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
@@ -40,7 +40,6 @@ import org.slf4j.LoggerFactory;
 import com.github.fge.lambdas.Throwing;
 import com.github.fge.lambdas.functions.ThrowingFunction;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 
 public class MailboxUtils {
@@ -99,12 +98,6 @@ public class MailboxUtils {
         return name;
     }
 
-    public Optional<String> getMailboxNameFromId(MailboxId mailboxId, MailboxSession
mailboxSession) throws MailboxException {
-        return getMailboxFromId(mailboxId, mailboxSession)
-                .map(Throwing.function(MessageManager::getMailboxPath).sneakyThrow())
-                .map(MailboxPath::getName);
-    }
-
     private Optional<MessageManager> getMailboxFromId(MailboxId mailboxId, MailboxSession
mailboxSession) throws MailboxException {
         try {
             return Optional.of(mailboxManager.getMailbox(mailboxId, mailboxSession));
@@ -132,29 +125,10 @@ public class MailboxUtils {
         }
     }
 
-    public MailboxPath getMailboxPath(Mailbox mailbox, MailboxSession mailboxSession) {
-        return new MailboxPath(mailboxSession.getPersonalSpace(), mailboxSession.getUser().getUserName(),
getMailboxName(mailbox, mailboxSession));
-    }
-
-    private String getMailboxName(Mailbox mailbox, MailboxSession mailboxSession) {
-        if (mailbox.getParentId().isPresent()) {
-            return getMailboxName(mailboxFromMailboxId(mailbox.getParentId().get(), mailboxSession).get(),
mailboxSession) +
-                    mailboxSession.getPathDelimiter() + mailbox.getName();
-        }
-        return mailbox.getName();
-    }
-
     public boolean hasChildren(MailboxId mailboxId, MailboxSession mailboxSession) throws
MailboxException {
         return getMailboxFromId(mailboxId, mailboxSession)
                 .map(Throwing.function(MessageManager::getMailboxPath).sneakyThrow())
                 .map(Throwing.function(path -> mailboxManager.hasChildren(path, mailboxSession)))
                 .orElse(false);
     }
-
-    public Optional<MailboxPath> mailboxPathFromMailboxId(MailboxId mailboxId, MailboxSession
mailboxSession) {
-        Preconditions.checkState(mailboxId != null, "'mailboxId' is mandatory");
-        Preconditions.checkState(mailboxSession != null, "'mailboxId' is mandatory");
-        return mailboxFromMailboxId(mailboxId, mailboxSession)
-                .map(mailbox -> getMailboxPath(mailbox, mailboxSession));
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessorTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessorTest.java
index f8f67bc..fdf8f31 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesCreationProcessorTest.java
@@ -43,12 +43,14 @@ public class SetMailboxesCreationProcessorTest {
     private MailboxUtils mailboxUtils;
     private Factory mailboxIdFactory;
     private SetMailboxesCreationProcessor sut;
+    private MailboxManager mailboxManager;
 
     @Before
     public void setup() {
         mailboxUtils = mock(MailboxUtils.class);
+        mailboxManager = mock(MailboxManager.class);
         mailboxIdFactory = new InMemoryId.Factory();
-        sut = new SetMailboxesCreationProcessor(mock(MailboxManager.class), mailboxUtils,
mailboxIdFactory);
+        sut = new SetMailboxesCreationProcessor(mailboxManager, mailboxUtils, mailboxIdFactory);
     }
 
     @Test
@@ -61,7 +63,7 @@ public class SetMailboxesCreationProcessorTest {
                 .build();
 
         MailboxSession mailboxSession = mock(MailboxSession.class);
-        when(mailboxUtils.getMailboxNameFromId(parentMailboxId, mailboxSession))
+        when(mailboxManager.getMailbox(parentMailboxId, mailboxSession))
             .thenThrow(new MailboxException());
 
         SetMailboxesResponse setMailboxesResponse = sut.process(request, mailboxSession);

http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessorTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessorTest.java
index 0fdc0a5..377681c 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessorTest.java
@@ -33,9 +33,9 @@ import org.apache.james.jmap.model.mailbox.MailboxUpdateRequest;
 import org.apache.james.jmap.utils.MailboxUtils;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
-import org.apache.james.mailbox.model.MailboxPath;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -59,15 +59,14 @@ public class SetMailboxesUpdateProcessorTest {
         // Given
         InMemoryId mailboxId = InMemoryId.of(1);
         InMemoryId newParentId = InMemoryId.of(2);
-        MailboxPath newParentMailboxPath = new MailboxPath("#private", "user", "newParentName");
         SetMailboxesRequest request = SetMailboxesRequest.builder()
                 .update(mailboxId, MailboxUpdateRequest.builder().parentId(newParentId).build())
                 .build();
         Mailbox mailbox = Mailbox.builder().id(mailboxId).name("name").role(Optional.empty()).build();
         when(mockedMailboxUtils.mailboxFromMailboxId(mailboxId, mockedMailboxSession))
             .thenReturn(Optional.of(mailbox));
-        when(mockedMailboxUtils.mailboxPathFromMailboxId(newParentId, mockedMailboxSession))
-            .thenReturn(Optional.of(newParentMailboxPath));
+        when(mockedMailboxManager.getMailbox(newParentId, mockedMailboxSession))
+            .thenReturn(mock(MessageManager.class));
         when(mockedMailboxUtils.hasChildren(mailboxId, mockedMailboxSession))
             .thenThrow(new MailboxException());
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/268f0011/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
index ef0a93c..f374a04 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
@@ -102,27 +102,6 @@ public class MailboxUtilsTest {
     }
 
     @Test
-    public void getMailboxNameFromIdShouldReturnNotEmptyWhenMailboxExists() throws Exception
{
-        String expected = "mailbox";
-        MailboxPath mailboxPath = new MailboxPath("#private", user, expected);
-        mailboxManager.createMailbox(mailboxPath, mailboxSession);
-        MailboxId mailboxId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-            .findMailboxByPath(mailboxPath)
-            .getMailboxId();
-
-        Optional<String> optionalName = sut.getMailboxNameFromId(mailboxId, mailboxSession);
-        assertThat(optionalName).isPresent();
-        String name = optionalName.get();
-        assertThat(name).isEqualTo(expected);
-    }
-
-    @Test
-    public void getMailboxNameFromIdShouldReturnEmptyWhenMailboxDoesntExist() throws Exception
{
-        Optional<String> optionalName = sut.getMailboxNameFromId(InMemoryId.of(987),
mailboxSession);
-        assertThat(optionalName).isEmpty();
-    }
-
-    @Test
     public void getParentIdFromMailboxPathShouldReturNullWhenRootMailbox() throws Exception
{
         MailboxPath mailboxPath = new MailboxPath("#private", user, "mailbox");
         mailboxManager.createMailbox(mailboxPath, mailboxSession);
@@ -183,108 +162,6 @@ public class MailboxUtilsTest {
     }
 
     @Test
-    public void mailboxPathFromMailboxIdShouldReturnPresentWhenExists() throws Exception
{
-        MailboxPath mailboxPath = new MailboxPath("#private", user, "myBox");
-        mailboxManager.createMailbox(mailboxPath, mailboxSession);
-        MailboxId mailboxId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(mailboxPath)
-                .getMailboxId();
-
-        Optional<MailboxPath> actual = sut.mailboxPathFromMailboxId(mailboxId, mailboxSession);
-        assertThat(actual).isPresent();
-        assertThat(actual.get()).isEqualTo(mailboxPath);
-    }
-
-    @Test
-    public void mailboxPathFromMailboxIdShouldReturnAbsentWhenDoesntExist() throws Exception
{
-        Optional<MailboxPath> mailboxPath = sut.mailboxPathFromMailboxId(InMemoryId.of(123),
mailboxSession);
-        assertThat(mailboxPath).isEmpty();
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void mailboxPathFromMailboxIdShouldThrowWhenNullMailboxId() throws Exception {
-        sut.mailboxPathFromMailboxId(null, mailboxSession);
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void mailboxPathFromMailboxIdShouldThrowWhenNullMailboxSession() throws Exception
{
-        sut.mailboxPathFromMailboxId(InMemoryId.of(123), null);
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void mailboxPathFromMailboxIdShouldThrowWhenNullMailboxSessionAndMailboxId() throws
Exception {
-        sut.mailboxPathFromMailboxId(null, null);
-    }
-
-    @Test
-    public void getMailboxPathShouldReturnThePathWhenRootMailbox() throws Exception {
-        MailboxPath expected = new MailboxPath("#private", user, "myBox");
-        mailboxManager.createMailbox(expected, mailboxSession);
-        MailboxId mailboxId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(expected)
-                .getMailboxId();
-
-        Mailbox mailbox = Mailbox.builder()
-                .id(mailboxId)
-                .name("myBox")
-                .build();
-
-        MailboxPath mailboxPath = sut.getMailboxPath(mailbox, mailboxSession);
-        assertThat(mailboxPath).isEqualTo(expected);
-    }
-
-    @Test
-    public void getMailboxPathShouldReturnThePathWhenChildMailbox() throws Exception {
-        MailboxPath parentMailboxPath = new MailboxPath("#private", user, "inbox");
-        mailboxManager.createMailbox(parentMailboxPath, mailboxSession);
-        MailboxId parentId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(parentMailboxPath)
-                .getMailboxId();
-
-        MailboxPath expected = new MailboxPath("#private", user, "inbox.myBox");
-        mailboxManager.createMailbox(expected, mailboxSession);
-        MailboxId mailboxId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(expected)
-                .getMailboxId();
-
-        Mailbox mailbox = Mailbox.builder()
-                .id(mailboxId)
-                .name("myBox")
-                .parentId(parentId)
-                .build();
-
-        MailboxPath mailboxPath = sut.getMailboxPath(mailbox, mailboxSession);
-        assertThat(mailboxPath).isEqualTo(expected);
-    }
-
-    @Test
-    public void getMailboxPathShouldReturnThePathWhenChildOfChildMailbox() throws Exception
{
-        MailboxPath parentMailboxPath = new MailboxPath("#private", user, "inbox");
-        mailboxManager.createMailbox(parentMailboxPath, mailboxSession);
-
-        MailboxPath childMailboxPath = new MailboxPath("#private", user, "inbox.child");
-        mailboxManager.createMailbox(childMailboxPath, mailboxSession);
-        MailboxId childId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(childMailboxPath)
-                .getMailboxId();
-
-        MailboxPath expected = new MailboxPath("#private", user, "inbox.child.myBox");
-        mailboxManager.createMailbox(expected, mailboxSession);
-        MailboxId mailboxId = mailboxMapperFactory.getMailboxMapper(mailboxSession)
-                .findMailboxByPath(expected)
-                .getMailboxId();
-
-        Mailbox mailbox = Mailbox.builder()
-                .id(mailboxId)
-                .name("myBox")
-                .parentId(childId)
-                .build();
-
-        MailboxPath mailboxPath = sut.getMailboxPath(mailbox, mailboxSession);
-        assertThat(mailboxPath).isEqualTo(expected);
-    }
-
-    @Test
     public void hasChildrenShouldReturnFalseWhenNoChild() throws Exception {
         MailboxPath mailboxPath = new MailboxPath("#private", user, "myBox");
         mailboxManager.createMailbox(mailboxPath, mailboxSession);


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