james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [03/15] james-project git commit: PROTOCOLS-117 General fixes: Solve confusion between MessageManager "message" search and MailboxManager "mailbox" search
Date Fri, 03 Nov 2017 12:27:26 GMT
PROTOCOLS-117 General fixes: Solve confusion between MessageManager "message" search and MailboxManager
"mailbox" search


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

Branch: refs/heads/master
Commit: f79e6f18caa52b28ca49fcf79160c7dae5e5de11
Parents: 99c1819
Author: benwa <btellier@linagora.com>
Authored: Wed Nov 1 15:23:48 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Fri Nov 3 09:34:03 2017 +0700

----------------------------------------------------------------------
 .../store/AbstractCombinationManagerTest.java   | 34 +++++++++-----------
 1 file changed, 15 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f79e6f18/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
index f4f4c99..fc67989 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractCombinationManagerTest.java
@@ -47,8 +47,6 @@ import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.MessageResult;
 import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
-import org.apache.james.mailbox.model.search.MailboxQuery;
-import org.apache.james.mailbox.model.search.PrefixedWildcard;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.junit.Test;
 
@@ -112,37 +110,35 @@ public abstract class AbstractCombinationManagerTest {
     }
 
     @Test
-    public void searchFromMailboxManagerShouldReturnMessagesUsingSetInMailboxesFromMessageIdManagerWhenSearchByMailboxQueryWithMailboxPath()
throws Exception {
+    public void searchFromMessageManagerShouldReturnMessagesUsingSetInMailboxesFromMessageIdManagerWhenSearchByMailboxQueryWithMailboxPath()
throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.all());
 
-        MailboxQuery mailboxQuery = MailboxQuery.privateMailboxesBuilder(session)
-            .expression(new PrefixedWildcard(MailboxFixture.INBOX_ALICE.getName()))
-            .build();
         MessageId messageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT),
new Date(), session, false, FLAGS).getMessageId();
 
-        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(),
mailbox2.getMailboxId()), session);
+        messageIdManager.setInMailboxes(messageId,
+            ImmutableList.of(mailbox1.getMailboxId(), mailbox2.getMailboxId()), session);
+
+        MessageUid uidInMailbox2 = messageIdManager.getMessages(ImmutableList.of(messageId),
FetchGroupImpl.MINIMAL, session)
+            .get(0)
+            .getUid();
 
-        assertThat(mailboxManager.search(mailboxQuery, session)).hasSize(1)
-            .extractingResultOf("getId")
-            .containsOnly(mailbox1.getMailboxId());
+        assertThat(messageManager2.search(query, session)).hasSize(1)
+            .containsExactly(uidInMailbox2);
     }
 
     @Test
-    public void searchFromMailboxManagerShouldReturnMessagesUsingSetInMailboxesFromMessageIdManagerWhenSearchByMailboxQueryWithUsername()
throws Exception {
+    public void searchFromMessageManagerShouldReturnMessagesUsingSetInMailboxesFromMessageIdManagerWhenSearchByMailboxQueryWithUsername()
throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.all());
 
-        MailboxQuery mailboxQuery = MailboxQuery.privateMailboxesBuilder(session)
-            .matchesAllMailboxNames()
-            .build();
-        MessageId messageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT),
new Date(), session, false, FLAGS).getMessageId();
+        ComposedMessageId composedMessageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT),
new Date(), session, false, FLAGS);
 
-        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(),
mailbox2.getMailboxId()), session);
+        messageIdManager.setInMailboxes(composedMessageId.getMessageId(),
+            ImmutableList.of(mailbox1.getMailboxId(), mailbox2.getMailboxId()), session);
 
-        assertThat(mailboxManager.search(mailboxQuery, session)).hasSize(2)
-            .extractingResultOf("getId")
-            .containsOnly(mailbox1.getMailboxId(), mailbox2.getMailboxId());
+        assertThat(messageManager1.search(query, session)).hasSize(1)
+            .containsExactly(composedMessageId.getUid());
     }
 
     @Test


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