james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [5/6] james-project git commit: JAMES-1947 Add more combination testing between MessageManager and MessageIdManager
Date Tue, 28 Feb 2017 03:38:16 GMT
JAMES-1947 Add more combination testing between MessageManager and MessageIdManager


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

Branch: refs/heads/master
Commit: adc2e3babd246048e6b8c7e225b621f9afc93e15
Parents: 443d0a4
Author: Quynh Nguyen <qnguyen@linagora.com>
Authored: Wed Feb 22 15:54:12 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Feb 28 10:37:10 2017 +0700

----------------------------------------------------------------------
 .../store/AbstractCombinationManagerTest.java   | 72 ++++++++++++++++++++
 .../store/TestMailboxSessionMapperFactory.java  |  5 ++
 2 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/adc2e3ba/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 2bfa4dd..bba5bc0 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
@@ -28,6 +28,7 @@ import java.util.List;
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
+import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
@@ -59,6 +60,9 @@ public abstract class AbstractCombinationManagerTest {
     private static final byte[] MAIL_CONTENT = "Subject: test\r\n\r\ntestmail".getBytes();
     private static final int DEFAULT_MAXIMUM_LIMIT = 256;
 
+    private static final String USER_FLAGS_VALUE = "User Flags";
+    private static final String ANOTHER_USER_FLAGS_VALUE = "Another User Flags";
+
     private MailboxManager mailboxManager;
     private MessageIdManager messageIdManager;
     private MessageManager messageManager1;
@@ -360,6 +364,74 @@ public abstract class AbstractCombinationManagerTest {
             .extractingResultOf("getMessageId").containsOnly(messageId);
     }
 
+    @Test
+    public void appendMessageFromMessageManagerAndSetInMailboxFromMessageIdManagerShouldUpdateApplicableFlag()
throws Exception {
+        Flags messageFlag = new FlagsBuilder()
+            .add(Flag.ANSWERED)
+            .add(USER_FLAGS_VALUE)
+            .build();
+
+        MessageId messageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT),
new Date(), session, false, messageFlag).getMessageId();
+
+        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(),
mailbox2.getMailboxId()), session);
+
+        assertThat(messageManager1.getApplicableFlag(session))
+            .isEqualTo(messageFlag);
+        assertThat(messageManager2.getApplicableFlag(session))
+            .isEqualTo(messageFlag);
+    }
+
+    @Test
+    public void appendMessageFromMessageManagerAndSetFlagsFromMessageIdManagerShouldUnionApplicableFlag()
throws Exception {
+        Flags messageFlag = new FlagsBuilder()
+            .add(Flag.ANSWERED)
+            .add(USER_FLAGS_VALUE)
+            .build();
+
+        Flags deleted = new FlagsBuilder()
+            .add(Flag.DELETED)
+            .add(USER_FLAGS_VALUE, ANOTHER_USER_FLAGS_VALUE)
+            .build();
+
+        MessageId messageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT),
new Date(), session, false, messageFlag).getMessageId();
+
+        messageIdManager.setFlags(deleted, FlagsUpdateMode.ADD, messageId, ImmutableList.of(mailbox1.getMailboxId()),
session);
+
+        assertThat(messageManager1.getApplicableFlag(session))
+            .isEqualTo(new FlagsBuilder()
+                .add(Flag.ANSWERED, Flag.DELETED)
+                .add(USER_FLAGS_VALUE, ANOTHER_USER_FLAGS_VALUE)
+                .build());
+    }
+
+    @Test
+    public void setFlagsFromMessageManagerAndSetFlagsFromMessageIdManagerShouldUpdateSameApplicableFlag()
throws Exception {
+        Flags messageFlag = new Flags(Flag.ANSWERED);
+        Flags deleted = new Flags(Flag.DELETED);
+        MessageId messageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT),
new Date(), session, false, messageFlag).getMessageId();
+
+        messageIdManager.setFlags(deleted, FlagsUpdateMode.ADD, messageId, ImmutableList.of(mailbox1.getMailboxId()),
session);
+        messageManager1.setFlags(deleted, FlagsUpdateMode.ADD, MessageRange.all(), session);
+
+        Flags applicableFlags = messageManager1.getApplicableFlag(session);
+
+        assertThat(applicableFlags)
+            .isEqualTo(new FlagsBuilder().add(Flag.ANSWERED, Flag.DELETED).build());
+    }
+
+    @Test
+    public void setInMailboxFromMessageIdManagerAndSetFlagsFromMessageManagerShouldUnionApplicableFlag()
throws Exception {
+        Flags messageFlag = new Flags(Flag.ANSWERED);
+        Flags deleted = new Flags(Flag.DELETED);
+        MessageId messageId = messageManager1.appendMessage(new ByteArrayInputStream(MAIL_CONTENT),
new Date(), session, false, messageFlag).getMessageId();
+
+        messageIdManager.setInMailboxes(messageId, ImmutableList.of(mailbox1.getMailboxId(),
mailbox2.getMailboxId()), session);
+        messageManager2.setFlags(deleted, FlagsUpdateMode.ADD, MessageRange.all(), session);
+
+        assertThat(messageManager2.getApplicableFlag(session))
+            .isEqualTo(new FlagsBuilder().add(Flag.ANSWERED, Flag.DELETED).build());
+    }
+
     private Predicate<MessageResult> messageInMailbox2() {
         return new Predicate<MessageResult>() {
             @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/adc2e3ba/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
index d7e70bd..4804e98 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
@@ -210,6 +210,11 @@ public class TestMailboxSessionMapperFactory extends MailboxSessionMapperFactory
                 }
                 return builder.build();
             }
+
+            @Override
+            public Flags getApplicableFlag(MailboxId mailboxId) throws MailboxException {
+                return null;
+            }
         };
     }
 


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