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

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

commit 28d3fa06e86f89a2fe55e4be24f339bffe91adc4
Author: Benoit Tellier <[email protected]>
AuthorDate: Thu Apr 4 11:14:03 2019 +0700

    JAMES-2723 LuceneMailboxMessageSearchIndexTest should rely on standard 
SimpleMailbox
---
 .../LuceneMailboxMessageSearchIndexTest.java       | 96 ++--------------------
 1 file changed, 9 insertions(+), 87 deletions(-)

diff --git 
a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
 
b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
index 8c0e25a..6b811ef 100644
--- 
a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
+++ 
b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
@@ -35,9 +35,7 @@ import javax.mail.Flags.Flag;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
 import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.model.Mailbox;
-import org.apache.james.mailbox.model.MailboxACL;
-import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.SimpleMailbox;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.SearchQuery;
@@ -61,9 +59,9 @@ public class LuceneMailboxMessageSearchIndexTest {
     public static final long LIMIT = 100L;
     private LuceneMessageSearchIndex index;
     
-    private SimpleMailbox mailbox = new SimpleMailbox(0);
-    private SimpleMailbox mailbox2 = new SimpleMailbox(1);
-    private SimpleMailbox mailbox3 = new SimpleMailbox(2);
+    private SimpleMailbox mailbox = new 
SimpleMailbox(MailboxPath.forUser("bob", "box"), 18, TestId.of(0));
+    private SimpleMailbox mailbox2 = new 
SimpleMailbox(MailboxPath.forUser("bob", "box"), 19, TestId.of(1));
+    private SimpleMailbox mailbox3 = new 
SimpleMailbox(MailboxPath.forUser("bob", "box"), 12, TestId.of(2));
     private MailboxSession session;
 
     private static final String FROM_ADDRESS = "Harry <[email protected]>";
@@ -123,23 +121,23 @@ public class LuceneMailboxMessageSearchIndexTest {
         headersTestSubject.put("Cc", "test211 <test21@localhost>, test6 
<test6@foobar>");
         
         uid1 = MessageUid.of(1);
-        SimpleMailboxMembership m = new SimpleMailboxMembership(id1, 
mailbox.getMailboxId(), uid1, 0, new Date(), 200, new Flags(Flag.ANSWERED), "My 
Body".getBytes(), headersSubject);
+        SimpleMailboxMembership m = new SimpleMailboxMembership(id1, (TestId) 
mailbox.getMailboxId(), uid1, 0, new Date(), 200, new Flags(Flag.ANSWERED), "My 
Body".getBytes(), headersSubject);
         index.add(session, mailbox, m);
 
         uid2 = MessageUid.of(1);
-        SimpleMailboxMembership m2 = new SimpleMailboxMembership(id2, 
mailbox2.getMailboxId(), uid2, 0, new Date(), 20, new Flags(Flag.ANSWERED), "My 
Body".getBytes(), headersSubject);
+        SimpleMailboxMembership m2 = new SimpleMailboxMembership(id2, (TestId) 
mailbox2.getMailboxId(), uid2, 0, new Date(), 20, new Flags(Flag.ANSWERED), "My 
Body".getBytes(), headersSubject);
         index.add(session, mailbox2, m2);
         
         uid3 = MessageUid.of(2);
         Calendar cal = Calendar.getInstance();
         cal.set(1980, 2, 10);
-        SimpleMailboxMembership m3 = new SimpleMailboxMembership(id3, 
mailbox.getMailboxId(), uid3, 0, cal.getTime(), 20, new Flags(Flag.DELETED), 
"My Otherbody".getBytes(), headersTest);
+        SimpleMailboxMembership m3 = new SimpleMailboxMembership(id3, (TestId) 
mailbox.getMailboxId(), uid3, 0, cal.getTime(), 20, new Flags(Flag.DELETED), 
"My Otherbody".getBytes(), headersTest);
         index.add(session, mailbox, m3);
         
         uid4 = MessageUid.of(3);
         Calendar cal2 = Calendar.getInstance();
         cal2.set(8000, 2, 10);
-        SimpleMailboxMembership m4 = new SimpleMailboxMembership(id4, 
mailbox.getMailboxId(), uid4, 0, cal2.getTime(), 20, new Flags(Flag.DELETED), 
"My Otherbody2".getBytes(), headersTestSubject);
+        SimpleMailboxMembership m4 = new SimpleMailboxMembership(id4, (TestId) 
mailbox.getMailboxId(), uid4, 0, cal2.getTime(), 20, new Flags(Flag.DELETED), 
"My Otherbody2".getBytes(), headersTestSubject);
         index.add(session, mailbox, m4);
         
         uid5 = MessageUid.of(10);
@@ -150,7 +148,7 @@ public class LuceneMailboxMessageSearchIndexTest {
         builder.header("Date", "Thu, 14 Feb 2008 12:00:00 +0000 (GMT)");
         builder.body = Charset.forName("us-ascii").encode(BODY).array();
         builder.uid = uid5;
-        builder.mailboxId = mailbox3.getMailboxId();
+        builder.mailboxId = (TestId) mailbox3.getMailboxId();
         
         index.add(session, mailbox3, builder.build(id5));
 
@@ -636,80 +634,4 @@ public class LuceneMailboxMessageSearchIndexTest {
         Iterator<MessageUid> result = index.search(session, mailbox, query);
         assertThat(result).containsExactly(uid3, uid4);
     }
-    
-    private final class SimpleMailbox implements Mailbox {
-        private final TestId id;
-
-        public SimpleMailbox(long id) {
-            this.id = TestId.of(id);
-        }
-
-        @Override
-        public void setMailboxId(MailboxId id) {
-        }
-
-        @Override
-        public MailboxPath generateAssociatedPath() {
-            return new MailboxPath(getNamespace(), getUser(), getName());
-        }
-
-        @Override
-        public TestId getMailboxId() {
-            return id;
-        }
-
-        @Override
-        public String getNamespace() {
-            throw new UnsupportedOperationException("Not supported");
-        }
-
-        @Override
-        public void setNamespace(String namespace) {
-            throw new UnsupportedOperationException("Not supported");
-        }
-
-        @Override
-        public String getUser() {
-            throw new UnsupportedOperationException("Not supported");
-        }
-
-        @Override
-        public void setUser(String user) {
-            throw new UnsupportedOperationException("Not supported");
-        }
-
-        @Override
-        public String getName() {
-            return id.serialize();
-        }
-
-        @Override
-        public void setName(String name) {
-            throw new UnsupportedOperationException("Not supported");
-
-        }
-
-        @Override
-        public long getUidValidity() {
-            return 0;
-        }
-
-        @Override
-        public MailboxACL getACL() {
-            return MailboxACL.OWNER_FULL_ACL;
-        }
-
-        @Override
-        public void setACL(MailboxACL acl) {
-            throw new UnsupportedOperationException("Not supported");
-        }
-
-
-        @Override
-        public boolean isChildOf(Mailbox potentialParent, MailboxSession 
mailboxSession) {
-            throw new UnsupportedOperationException("Not supported");
-        }
-
-
-    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to