james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [6/9] james-project git commit: MAILBOX-352 Put MailboxId inside MailboxEvent(literally)
Date Wed, 28 Nov 2018 10:46:38 GMT
MAILBOX-352 Put MailboxId inside MailboxEvent(literally)


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

Branch: refs/heads/master
Commit: f37816206bf65bf4dd57de322665014ad8148590
Parents: 5100702
Author: tran tien duc <dtran@linagora.com>
Authored: Tue Nov 27 11:13:03 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Nov 28 17:18:55 2018 +0700

----------------------------------------------------------------------
 .../apache/james/mailbox/MailboxListener.java   | 51 ++++++++++++--------
 .../james/mailbox/store/StoreRightManager.java  |  4 +-
 .../james/mailbox/store/event/EventFactory.java | 17 ++++---
 .../store/event/MailboxEventDispatcher.java     |  5 +-
 .../event/AsynchronousEventDeliveryTest.java    |  6 +--
 .../DefaultDelegatingMailboxListenerTest.java   | 33 +++++++------
 .../event/MailboxAnnotationListenerTest.java    |  2 +-
 .../store/event/MixedEventDeliveryTest.java     |  6 +--
 .../event/SynchronousEventDeliveryTest.java     |  4 +-
 .../base/FakeMailboxListenerAdded.java          |  5 +-
 .../base/FakeMailboxListenerFlagsUpdate.java    |  5 +-
 .../base/MailboxEventAnalyserTest.java          | 28 +++++++----
 12 files changed, 97 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index 3112378..5e52828 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -27,6 +27,7 @@ import java.util.Objects;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.Quota;
@@ -133,10 +134,12 @@ public interface MailboxListener {
     abstract class MailboxEvent implements Event, Serializable {
         private final MailboxSession session;
         private final MailboxPath path;
+        private final MailboxId mailboxId;
 
-        public MailboxEvent(MailboxSession session, MailboxPath path) {
+        public MailboxEvent(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
             this.session = session;
             this.path = path;
+            this.mailboxId = mailboxId;
         }
 
         /**
@@ -158,6 +161,15 @@ public interface MailboxListener {
         public MailboxPath getMailboxPath() {
             return path;
         }
+
+        /**
+         * Return the id of the Mailbox this event belongs to.
+         *
+         * @return mailboxId
+         */
+        public MailboxId getMailboxId() {
+            return mailboxId;
+        }
     }
 
     /**
@@ -174,8 +186,9 @@ public interface MailboxListener {
         private final QuotaCount deletedMessageCOunt;
         private final QuotaSize totalDeletedSize;
 
-        public MailboxDeletion(MailboxSession session, MailboxPath path, QuotaRoot quotaRoot,
QuotaCount deletedMessageCOunt, QuotaSize totalDeletedSize) {
-            super(session, path);
+        public MailboxDeletion(MailboxSession session, MailboxPath path, QuotaRoot quotaRoot,
QuotaCount deletedMessageCOunt, QuotaSize totalDeletedSize,
+                               MailboxId mailboxId) {
+            super(session, path, mailboxId);
             this.quotaRoot = quotaRoot;
             this.deletedMessageCOunt = deletedMessageCOunt;
             this.totalDeletedSize = totalDeletedSize;
@@ -203,8 +216,8 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        public MailboxAdded(MailboxSession session, MailboxPath path) {
-            super(session, path);
+        public MailboxAdded(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
+            super(session, path, mailboxId);
         }
     }
 
@@ -217,8 +230,8 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        public MailboxRenamed(MailboxSession session, MailboxPath path) {
-            super(session, path);
+        public MailboxRenamed(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
+            super(session, path, mailboxId);
         }
 
         /**
@@ -237,8 +250,8 @@ public interface MailboxListener {
         private final ACLDiff aclDiff;
         private static final long serialVersionUID = 1L;
 
-        public MailboxACLUpdated(MailboxSession session, MailboxPath path, ACLDiff aclDiff)
{
-            super(session, path);
+        public MailboxACLUpdated(MailboxSession session, MailboxPath path, ACLDiff aclDiff,
MailboxId mailboxId) {
+            super(session, path, mailboxId);
             this.aclDiff = aclDiff;
         }
 
@@ -258,8 +271,8 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        public MessageEvent(MailboxSession session, MailboxPath path) {
-            super(session, path);
+        public MessageEvent(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
+            super(session, path, mailboxId);
         }
 
         /**
@@ -272,8 +285,8 @@ public interface MailboxListener {
 
     abstract class MetaDataHoldingEvent extends MessageEvent {
 
-        public MetaDataHoldingEvent(MailboxSession session, MailboxPath path) {
-            super(session, path);
+        public MetaDataHoldingEvent(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
+            super(session, path, mailboxId);
         }
 
         /**
@@ -292,8 +305,8 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        public Expunged(MailboxSession session, MailboxPath path) {
-            super(session, path);
+        public Expunged(MailboxSession session, MailboxPath path, MailboxId mailboxId) {
+            super(session, path, mailboxId);
         }
         
         /**
@@ -315,8 +328,8 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        public FlagsUpdated(MailboxSession session, MailboxPath path) {
-            super(session, path);
+        public FlagsUpdated(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
+            super(session, path, mailboxId);
         }
 
         public abstract List<UpdatedFlags> getUpdatedFlags();
@@ -332,8 +345,8 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        public Added(MailboxSession session, MailboxPath path) {
-            super(session, path);
+        public Added(MailboxSession session, MailboxPath path, MailboxId mailboxId) {
+            super(session, path, mailboxId);
         }
         
         /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index d17b41f..5fd6491 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -138,7 +138,7 @@ public class StoreRightManager implements RightManager {
         Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
         ACLDiff aclDiff = mapper.updateACL(mailbox, mailboxACLCommand);
 
-        dispatcher.aclUpdated(session, mailboxPath, aclDiff);
+        dispatcher.aclUpdated(session, mailboxPath, aclDiff, mailbox.getMailboxId());
     }
 
     private void assertSharesBelongsToUserDomain(String user, ACLCommand mailboxACLCommand)
throws DifferentDomainException {
@@ -216,7 +216,7 @@ public class StoreRightManager implements RightManager {
     private void setRights(MailboxACL mailboxACL, MailboxMapper mapper, Mailbox mailbox,
MailboxSession session) throws MailboxException {
         ACLDiff aclDiff = mapper.setACL(mailbox, mailboxACL);
 
-        dispatcher.aclUpdated(session, mailbox.generateAssociatedPath(), aclDiff);
+        dispatcher.aclUpdated(session, mailbox.generateAssociatedPath(), aclDiff, mailbox.getMailboxId());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 4ee78b6..2af8b42 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -29,6 +29,7 @@ import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageMoves;
@@ -53,7 +54,7 @@ public class EventFactory {
         private final Mailbox mailbox;
 
         public AddedImpl(MailboxSession session, Mailbox mailbox, SortedMap<MessageUid,
MessageMetaData> uids, Map<MessageUid, MailboxMessage> availableMessages) {
-            super(session, new StoreMailboxPath(mailbox));
+            super(session, new StoreMailboxPath(mailbox), mailbox.getMailboxId());
             this.added = ImmutableMap.copyOf(uids);
             this.mailbox = mailbox;
             this.availableMessages = ImmutableMap.copyOf(availableMessages);
@@ -84,7 +85,7 @@ public class EventFactory {
         private final Mailbox mailbox;
 
         public ExpungedImpl(MailboxSession session, Mailbox mailbox,  Map<MessageUid,
MessageMetaData> uids) {
-            super(session,  new StoreMailboxPath(mailbox));
+            super(session,  new StoreMailboxPath(mailbox), mailbox.getMailboxId());
             this.uids = ImmutableMap.copyOf(uids);
             this.mailbox = mailbox;
         }
@@ -113,7 +114,7 @@ public class EventFactory {
         private final List<UpdatedFlags> uFlags;
 
         public FlagsUpdatedImpl(MailboxSession session, Mailbox mailbox, List<MessageUid>
uids, List<UpdatedFlags> uFlags) {
-            super(session, new StoreMailboxPath(mailbox));
+            super(session, new StoreMailboxPath(mailbox), mailbox.getMailboxId());
             this.uids = ImmutableList.copyOf(uids);
             this.uFlags = ImmutableList.copyOf(uFlags);
             this.mailbox = mailbox;
@@ -140,7 +141,7 @@ public class EventFactory {
         private final Mailbox mailbox;
 
         public MailboxDeletionImpl(MailboxSession session, Mailbox mailbox, QuotaRoot quotaRoot,
QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) {
-            super(session, new StoreMailboxPath(mailbox), quotaRoot, deletedMessageCount,
totalDeletedSize);
+            super(session, new StoreMailboxPath(mailbox), quotaRoot, deletedMessageCount,
totalDeletedSize, mailbox.getMailboxId());
             this.mailbox = mailbox;
         }
 
@@ -157,7 +158,7 @@ public class EventFactory {
         private final Mailbox mailbox;
 
         public MailboxAddedImpl(MailboxSession session, Mailbox mailbox) {
-            super(session,  new StoreMailboxPath(mailbox));
+            super(session,  new StoreMailboxPath(mailbox), mailbox.getMailboxId());
             this.mailbox = mailbox;
         }
 
@@ -175,7 +176,7 @@ public class EventFactory {
         private final Mailbox newMailbox;
 
         public MailboxRenamedEventImpl(MailboxSession session, MailboxPath oldPath, Mailbox
newMailbox) {
-            super(session, oldPath);
+            super(session, oldPath, newMailbox.getMailboxId());
             this.newPath = new StoreMailboxPath(newMailbox);
             this.newMailbox = newMailbox;
         }
@@ -216,8 +217,8 @@ public class EventFactory {
         return new MailboxAddedImpl(session, mailbox);
     }
 
-    public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession session, MailboxPath
mailboxPath, ACLDiff aclDiff) {
-        return new MailboxListener.MailboxACLUpdated(session, mailboxPath, aclDiff);
+    public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession session, MailboxPath
mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
+        return new MailboxListener.MailboxACLUpdated(session, mailboxPath, aclDiff, mailboxId);
     }
 
     public MessageMoveEvent moved(MailboxSession session, MessageMoves messageMoves, Map<MessageUid,
MailboxMessage> messages) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index da0f503..d6eee58 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -33,6 +33,7 @@ import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageMoves;
@@ -157,8 +158,8 @@ public class MailboxEventDispatcher {
         listener.event(eventFactory.mailboxAdded(session, mailbox));
     }
 
-    public void aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff)
{
-        listener.event(eventFactory.aclUpdated(session, mailboxPath, aclDiff));
+    public void aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff,
MailboxId mailboxId) {
+        listener.event(eventFactory.aclUpdated(session, mailboxPath, aclDiff, mailboxId));
     }
 
     public void moved(MailboxSession session, MessageMoves messageMoves, Map<MessageUid,
MailboxMessage> messages) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java
index 1fbe4d7..7cd2176 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java
@@ -53,14 +53,14 @@ public class AsynchronousEventDeliveryTest {
 
     @Test
     public void deliverShouldWork() throws Exception {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null,
null) {};
         asynchronousEventDelivery.deliver(mailboxListener, event);
         verify(mailboxListener, timeout(ONE_MINUTE)).event(event);
     }
 
     @Test
     public void deliverShouldNotPropagateException() throws Exception {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(new MockMailboxSession("test"),
null) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(new MockMailboxSession("test"),
null, null) {};
         doThrow(new RuntimeException()).when(mailboxListener).event(event);
         asynchronousEventDelivery.deliver(mailboxListener, event);
         verify(mailboxListener, timeout(ONE_MINUTE)).event(event);
@@ -68,7 +68,7 @@ public class AsynchronousEventDeliveryTest {
 
     @Test
     public void deliverShouldWorkWhenThePoolIsFull() throws Exception {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(new MockMailboxSession("test"),
null) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(new MockMailboxSession("test"),
null, null) {};
         int operationCount = 10;
         for (int i = 0; i < operationCount; i++) {
             asynchronousEventDelivery.deliver(mailboxListener, event);

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
index fe509ec..190e0b2 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java
@@ -32,8 +32,10 @@ import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.QuotaRoot;
+import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.util.EventCollector;
 import org.junit.Before;
 import org.junit.Test;
@@ -42,6 +44,7 @@ public class DefaultDelegatingMailboxListenerTest {
 
     private static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", "user",
"name");
     private static final MailboxPath OTHER_MAILBOX_PATH = new MailboxPath("namespace", "other",
"name");
+    private static final MailboxId MAILBOX_ID = TestId.of(100);
 
     private DefaultDelegatingMailboxListener defaultDelegatingMailboxListener;
     private EventCollector mailboxEventCollector;
@@ -79,7 +82,7 @@ public class DefaultDelegatingMailboxListenerTest {
 
     @Test
     public void eventShouldWork() throws Exception {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH,
MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -88,7 +91,7 @@ public class DefaultDelegatingMailboxListenerTest {
 
     @Test
     public void eventShouldOnlyTriggerMAILBOXListenerRelatedToTheEvent() throws Exception
{
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, OTHER_MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, OTHER_MAILBOX_PATH,
MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).isEmpty();
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -97,14 +100,14 @@ public class DefaultDelegatingMailboxListenerTest {
 
     @Test
     public void mailboxRenamedEventShouldUnregisterMAILBOXFromTheirPreviousPath() throws
Exception {
-        MailboxListener.MailboxRenamed event = new MailboxListener.MailboxRenamed(null, MAILBOX_PATH)
{
+        MailboxListener.MailboxRenamed event = new MailboxListener.MailboxRenamed(null, MAILBOX_PATH,
MAILBOX_ID) {
             @Override
             public MailboxPath getNewPath() {
                 return OTHER_MAILBOX_PATH;
             }
         };
         defaultDelegatingMailboxListener.event(event);
-        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
MAILBOX_PATH) {};
+        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(secondEvent);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent);
@@ -113,14 +116,14 @@ public class DefaultDelegatingMailboxListenerTest {
 
     @Test
     public void mailboxRenamedEventShouldRegisterMAILBOXToTheirNewPath() throws Exception
{
-        MailboxListener.MailboxRenamed event = new MailboxListener.MailboxRenamed(null, MAILBOX_PATH)
{
+        MailboxListener.MailboxRenamed event = new MailboxListener.MailboxRenamed(null, MAILBOX_PATH,
MAILBOX_ID) {
             @Override
             public MailboxPath getNewPath() {
                 return OTHER_MAILBOX_PATH;
             }
         };
         defaultDelegatingMailboxListener.event(event);
-        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
OTHER_MAILBOX_PATH) {};
+        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
OTHER_MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(secondEvent);
         assertThat(mailboxEventCollector.getEvents()).containsOnly(event, secondEvent);
         assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent);
@@ -132,9 +135,9 @@ public class DefaultDelegatingMailboxListenerTest {
         QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", Optional.empty());
         QuotaCount deletedMessageCount = QuotaCount.count(123);
         QuotaSize totalDeletedSize = QuotaSize.size(456);
-        MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(null,
MAILBOX_PATH, quotaRoot, deletedMessageCount, totalDeletedSize) {};
+        MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(null,
MAILBOX_PATH, quotaRoot, deletedMessageCount, totalDeletedSize, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
-        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
MAILBOX_PATH) {};
+        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(secondEvent);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent);
@@ -146,9 +149,9 @@ public class DefaultDelegatingMailboxListenerTest {
         QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", Optional.empty());
         QuotaCount quotaCount = QuotaCount.count(123);
         QuotaSize quotaSize = QuotaSize.size(456);
-        MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(null,
MAILBOX_PATH, quotaRoot, quotaCount, quotaSize) {};
+        MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(null,
MAILBOX_PATH, quotaRoot, quotaCount, quotaSize, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
-        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
OTHER_MAILBOX_PATH) {};
+        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null,
OTHER_MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(secondEvent);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent);
@@ -158,7 +161,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void removeListenerShouldWork() throws Exception {
         defaultDelegatingMailboxListener.removeListener(MAILBOX_PATH, mailboxEventCollector,
null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH,
MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).isEmpty();
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -168,7 +171,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void removeListenerShouldNotRemoveAListenerFromADifferentPath() throws Exception
{
         defaultDelegatingMailboxListener.removeListener(OTHER_MAILBOX_PATH, mailboxEventCollector,
null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH,
MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -178,7 +181,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void removeGlobalListenerShouldWorkForONCE() throws Exception {
         defaultDelegatingMailboxListener.removeGlobalListener(eachNodeEventCollector, null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH,
MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).isEmpty();
@@ -188,7 +191,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void removeGlobalListenerShouldWorkForEACH_NODE() throws Exception {
         defaultDelegatingMailboxListener.removeGlobalListener(onceEventCollector, null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH,
MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -198,7 +201,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void listenersErrorsShouldNotBePropageted() throws Exception {
         MailboxSession session = new MockMailboxSession("benwa");
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session, MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session, MAILBOX_PATH,
MAILBOX_ID) {};
         MailboxListener mockedListener = mock(MailboxListener.class);
         when(mockedListener.getType()).thenReturn(MailboxListener.ListenerType.ONCE);
         doThrow(new RuntimeException()).when(mockedListener).event(event);

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
index 524ad7d..69a1257 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
@@ -91,7 +91,7 @@ public class MailboxAnnotationListenerTest {
 
     @Test
     public void eventShouldDoNothingIfDoNotHaveMailboxDeletionEvent() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, MAILBOX_PATH,
MAILBOX_ID) {};
         listener.event(event);
 
         verifyNoMoreInteractions(mailboxSessionMapperFactory);

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
index 5a6dc92..7eecc59 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
@@ -58,14 +58,14 @@ public class MixedEventDeliveryTest {
     @Test
     public void deliverShouldWorkOnSynchronousListeners() {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null,
null) {};
         mixedEventDelivery.deliver(listener, event);
         verify(listener).event(event);
     }
 
     @Test
     public void deliverShouldEventuallyDeliverOnAsynchronousListeners() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null,
null) {};
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
         mixedEventDelivery.deliver(listener, event);
         verify(listener, timeout(DELIVERY_DELAY * 10)).event(event);
@@ -73,7 +73,7 @@ public class MixedEventDeliveryTest {
 
     @Test(timeout = ONE_MINUTE)
     public void deliverShouldNotBlockOnAsynchronousListeners() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null,
null) {};
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
         final CountDownLatch latch = new CountDownLatch(1);
         doAnswer(invocation -> {

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
index 85bc13f..2b3e90a 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
@@ -42,14 +42,14 @@ public class SynchronousEventDeliveryTest {
 
     @Test
     public void deliverShouldWork() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null)
{};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null,
null) {};
         synchronousEventDelivery.deliver(mailboxListener, event);
         verify(mailboxListener).event(event);
     }
 
     @Test
     public void deliverShouldNotPropagateException() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(new MockMailboxSession("test"),
null) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(new MockMailboxSession("test"),
null, null) {};
         doThrow(new RuntimeException()).when(mailboxListener).event(event);
         synchronousEventDelivery.deliver(mailboxListener, event);
         verify(mailboxListener).event(event);

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
index fae3525..c80b019 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
@@ -27,6 +27,7 @@ import javax.mail.Flags;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.MessageMetaData;
@@ -35,8 +36,8 @@ public class FakeMailboxListenerAdded extends MailboxListener.Added {
 
     public List<MessageUid> uids;
 
-    public FakeMailboxListenerAdded(MailboxSession session, List<MessageUid> uids,
MailboxPath path) {
-        super(session, path);
+    public FakeMailboxListenerAdded(MailboxSession session, List<MessageUid> uids,
MailboxPath path, MailboxId mailboxId) {
+        super(session, path, mailboxId);
         this.uids = uids;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
index eb794bd..dbedabe 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
@@ -24,6 +24,7 @@ import java.util.List;
 import org.apache.james.mailbox.MailboxListener.FlagsUpdated;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.UpdatedFlags;
 
@@ -33,8 +34,8 @@ public class FakeMailboxListenerFlagsUpdate extends FlagsUpdated {
 
     public List<UpdatedFlags> flags;
 
-    public FakeMailboxListenerFlagsUpdate(MailboxSession session, List<MessageUid>
uids, List<UpdatedFlags> flags, MailboxPath path) {
-        super(session, path);
+    public FakeMailboxListenerFlagsUpdate(MailboxSession session, List<MessageUid>
uids, List<UpdatedFlags> flags, MailboxPath path, MailboxId mailboxId) {
+        super(session, path, mailboxId);
         this.uids = uids;
         this.flags = flags;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f3781620/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 87f7c76..48c6fd8 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -49,6 +49,7 @@ import org.junit.Test;
 import com.google.common.collect.ImmutableList;
 
 public class MailboxEventAnalyserTest {
+
     public static class SingleMessageResultIterator implements MessageResultIterator {
         private final MessageResult messageResult;
         private boolean done;
@@ -86,6 +87,7 @@ public class MailboxEventAnalyserTest {
     private static final MockMailboxSession OTHER_MAILBOX_SESSION = new MockMailboxSession("user");
     private static final char PATH_DELIMITER = '.';
     private static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", "user",
"name");
+    private static final TestId MAILBOX_ID = TestId.of(36);
 
     private SelectedMailboxImpl testee;
 
@@ -105,7 +107,7 @@ public class MailboxEventAnalyserTest {
             .thenReturn(messageManager);
 
         MessageResult messageResult = mock(MessageResult.class);
-        when(messageResult.getMailboxId()).thenReturn(TestId.of(36));
+        when(messageResult.getMailboxId()).thenReturn(MAILBOX_ID);
         when(messageResult.getUid()).thenReturn(MESSAGE_UID);
 
         when(messageManager.getApplicableFlags(any()))
@@ -120,7 +122,7 @@ public class MailboxEventAnalyserTest {
 
     @Test
     public void testShouldBeNoSizeChangeOnOtherEvent() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(MAILBOX_SESSION,
MAILBOX_PATH) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(MAILBOX_SESSION,
MAILBOX_PATH, MAILBOX_ID) {};
       
         testee.event(event);
 
@@ -129,13 +131,13 @@ public class MailboxEventAnalyserTest {
 
     @Test
     public void testShouldBeNoSizeChangeOnAdded() {
-        testee.event(new FakeMailboxListenerAdded(MAILBOX_SESSION, ImmutableList.of(MessageUid.of(11)),
MAILBOX_PATH));
+        testee.event(new FakeMailboxListenerAdded(MAILBOX_SESSION, ImmutableList.of(MessageUid.of(11)),
MAILBOX_PATH, MAILBOX_ID));
         assertThat(testee.isSizeChanged()).isTrue();
     }
 
     @Test
     public void testShouldNoSizeChangeAfterReset() {
-        testee.event(new FakeMailboxListenerAdded(MAILBOX_SESSION, ImmutableList.of(MessageUid.of(11)),
MAILBOX_PATH));
+        testee.event(new FakeMailboxListenerAdded(MAILBOX_SESSION, ImmutableList.of(MessageUid.of(11)),
MAILBOX_PATH, MAILBOX_ID));
         testee.resetEvents();
 
         assertThat(testee.isSizeChanged()).isFalse();
@@ -151,7 +153,8 @@ public class MailboxEventAnalyserTest {
                 .oldFlags(new Flags())
                 .newFlags(new Flags())
                 .build()),
-            MAILBOX_PATH);
+            MAILBOX_PATH,
+            MAILBOX_ID);
         testee.event(update);
 
         assertThat(testee.flagUpdateUids()).isEmpty();
@@ -169,7 +172,8 @@ public class MailboxEventAnalyserTest {
                 .oldFlags(new Flags())
                 .newFlags(new Flags(Flags.Flag.ANSWERED))
                 .build()),
-            MAILBOX_PATH);
+            MAILBOX_PATH,
+            MAILBOX_ID);
         testee.event(update);
 
        assertThat(testee.flagUpdateUids().iterator()).containsExactly(uid);
@@ -188,7 +192,8 @@ public class MailboxEventAnalyserTest {
                 .oldFlags(new Flags())
                 .newFlags(new Flags(Flags.Flag.ANSWERED))
                 .build()),
-            MAILBOX_PATH);
+            MAILBOX_PATH,
+            MAILBOX_ID);
         analyser.event(update);
         analyser.event(update);
         analyser.deselect();
@@ -208,7 +213,8 @@ public class MailboxEventAnalyserTest {
                 .oldFlags(new Flags())
                 .newFlags(new Flags(Flags.Flag.ANSWERED))
                 .build()),
-            MAILBOX_PATH);
+            MAILBOX_PATH,
+            MAILBOX_ID);
         testee.event(update);
         testee.setSilentFlagChanges(true);
         testee.event(update);
@@ -226,7 +232,8 @@ public class MailboxEventAnalyserTest {
                 .oldFlags(new Flags())
                 .newFlags(new Flags())
                 .build()),
-            MAILBOX_PATH);
+            MAILBOX_PATH,
+            MAILBOX_ID);
         testee.event(update);
         testee.setSilentFlagChanges(true);
         testee.event(update);
@@ -244,7 +251,8 @@ public class MailboxEventAnalyserTest {
                 .oldFlags(new Flags())
                 .newFlags(new Flags(Flags.Flag.RECENT))
                 .build()),
-            MAILBOX_PATH);
+            MAILBOX_PATH,
+            MAILBOX_ID);
         testee.event(update);
 
         assertThat(testee.flagUpdateUids().iterator()).isEmpty();


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