james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [16/19] james-project git commit: JAMES-2616 Completely remove mailbox session in events
Date Fri, 07 Dec 2018 01:10:39 GMT
JAMES-2616 Completely remove mailbox session in events


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

Branch: refs/heads/master
Commit: 262e206e22e656456926f775069efd517d07829e
Parents: 713c824
Author: tran tien duc <dtran@linagora.com>
Authored: Mon Dec 3 17:22:05 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Dec 7 07:52:51 2018 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/mailbox/Event.java    |   8 +-
 .../apache/james/mailbox/MailboxListener.java   | 137 +------------------
 .../ElasticSearchQuotaMailboxListenerTest.java  |   7 +-
 .../mailbox/store/event/MessageMoveEvent.java   |   5 -
 .../quota/ListeningCurrentQuotaUpdater.java     |   6 +-
 .../event/AsynchronousEventDeliveryTest.java    |  18 ++-
 .../DefaultDelegatingMailboxListenerTest.java   |  25 ++--
 .../event/MailboxAnnotationListenerTest.java    |   2 +-
 .../store/event/MixedEventDeliveryTest.java     |   8 +-
 .../event/SynchronousEventDeliveryTest.java     |   9 +-
 .../base/FakeMailboxListenerAdded.java          |   6 +-
 .../base/FakeMailboxListenerFlagsUpdate.java    |   8 +-
 .../base/MailboxEventAnalyserTest.java          |  12 +-
 13 files changed, 65 insertions(+), 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
index 4e80830..51c1078 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
@@ -24,13 +24,9 @@ import org.apache.james.core.User;
 
 public interface Event {
 
-    MailboxSession getSession();
-
-    default User getUser() {
-        return getSession().getUser().getCoreUser();
-    }
+    User getUser();
 
     default Optional<MailboxSession.SessionId> getSessionId() {
-        return Optional.ofNullable(getSession().getSessionId());
+        return Optional.empty();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/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 eb80e4b..91c94af 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
@@ -21,9 +21,7 @@ package org.apache.james.mailbox;
 
 import java.io.Serializable;
 import java.time.Instant;
-import java.util.Collection;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 
@@ -75,6 +73,7 @@ public interface MailboxListener {
     }
 
     class QuotaUsageUpdatedEvent implements QuotaEvent, Serializable {
+
         private final User user;
         private final QuotaRoot quotaRoot;
         private final Quota<QuotaCount> countQuota;
@@ -89,10 +88,6 @@ public interface MailboxListener {
             this.instant = instant;
         }
 
-        @Override
-        public MailboxSession getSession() {
-            throw new UnsupportedOperationException("this method will be removed");
-        }
 
         @Override
         public User getUser() {
@@ -141,84 +136,16 @@ public interface MailboxListener {
      * A mailbox event.
      */
     abstract class MailboxEvent implements Event, Serializable {
-        public static class DummyMailboxSession implements MailboxSession {
-
-            @Override
-            public SessionType getType() {
-                return null;
-            }
-
-            @Override
-            public SessionId getSessionId() {
-                return MailboxSession.SessionId.random();
-            }
-
-            @Override
-            public boolean isOpen() {
-                return false;
-            }
-
-            @Override
-            public void close() {
-
-            }
-
-            @Override
-            public User getUser() {
-                return null;
-            }
-
-            @Override
-            public String getPersonalSpace() {
-                return null;
-            }
-
-            @Override
-            public String getOtherUsersSpace() {
-                return null;
-            }
-
-            @Override
-            public Collection<String> getSharedSpaces() {
-                return null;
-            }
-
-            @Override
-            public Map<Object, Object> getAttributes() {
-                return null;
-            }
 
-            @Override
-            public char getPathDelimiter() {
-                return 0;
-            }
-        }
-
-        private final MailboxSession session;
         private final MailboxPath path;
         private final MailboxId mailboxId;
         private final User user;
         private final Optional<MailboxSession.SessionId> sessionId;
 
-        @Deprecated
-        public MailboxEvent(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
-            this.session = session;
-            this.path = path;
-            this.mailboxId = mailboxId;
-            // To pass some tests, which pass null MailboxSession to the constructors
-            this.user = Optional.ofNullable(session)
-                .map(MailboxSession::getUser)
-                .map(MailboxSession.User::getCoreUser)
-                .orElse(null);
-            this.sessionId = Optional.ofNullable(session)
-                .map(MailboxSession::getSessionId);
-        }
-
         public MailboxEvent(Optional<MailboxSession.SessionId> sessionId, User user,
MailboxPath path, MailboxId mailboxId) {
             this.user = user;
             this.path = path;
             this.mailboxId = mailboxId;
-            this.session = new DummyMailboxSession();
             this.sessionId = sessionId;
         }
 
@@ -233,18 +160,6 @@ public interface MailboxListener {
             return user;
         }
 
-
-        /**
-         * Gets the {@link MailboxSession} in which's context the {@link MailboxEvent}
-         * happened
-         *
-         * @return session
-         */
-        @Override
-        public MailboxSession getSession() {
-            return session;
-        }
-
         /**
          * Gets the sessionId in which's context the {@link MailboxEvent}
          * happened
@@ -289,15 +204,6 @@ public interface MailboxListener {
         private final QuotaCount deletedMessageCOunt;
         private final QuotaSize totalDeletedSize;
 
-        @Deprecated
-        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;
-        }
-
         public MailboxDeletion(Optional<MailboxSession.SessionId> sessionId, User user,
MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCOunt, QuotaSize totalDeletedSize,
                                MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
@@ -328,11 +234,6 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        @Deprecated
-        public MailboxAdded(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
-            super(session, path, mailboxId);
-        }
-
         public MailboxAdded(Optional<MailboxSession.SessionId> sessionId, User user,
MailboxPath path, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
         }
@@ -347,11 +248,6 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        @Deprecated
-        public MailboxRenamed(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
-            super(session, path, mailboxId);
-        }
-
         public MailboxRenamed(Optional<MailboxSession.SessionId> sessionId, User user,
MailboxPath path, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
         }
@@ -372,12 +268,6 @@ public interface MailboxListener {
         private final ACLDiff aclDiff;
         private static final long serialVersionUID = 1L;
 
-        @Deprecated
-        public MailboxACLUpdated(MailboxSession session, MailboxPath path, ACLDiff aclDiff,
MailboxId mailboxId) {
-            super(session, path, mailboxId);
-            this.aclDiff = aclDiff;
-        }
-
         public MailboxACLUpdated(Optional<MailboxSession.SessionId> sessionId, User
user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
             this.aclDiff = aclDiff;
@@ -399,11 +289,6 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        @Deprecated
-        public MessageEvent(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
-            super(session, path, mailboxId);
-        }
-
         public MessageEvent(Optional<MailboxSession.SessionId> sessionId, User user,
MailboxPath path, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
         }
@@ -418,11 +303,6 @@ public interface MailboxListener {
 
     abstract class MetaDataHoldingEvent extends MessageEvent {
 
-        @Deprecated
-        public MetaDataHoldingEvent(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
-            super(session, path, mailboxId);
-        }
-
         public MetaDataHoldingEvent(Optional<MailboxSession.SessionId> sessionId, User
user, MailboxPath path, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
         }
@@ -443,11 +323,6 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        @Deprecated
-        public Expunged(MailboxSession session, MailboxPath path, MailboxId mailboxId) {
-            super(session, path, mailboxId);
-        }
-
         public Expunged(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath
path, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
         }
@@ -471,11 +346,6 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        @Deprecated
-        public FlagsUpdated(MailboxSession session, MailboxPath path, MailboxId mailboxId)
{
-            super(session, path, mailboxId);
-        }
-
         public FlagsUpdated(Optional<MailboxSession.SessionId> sessionId, User user,
MailboxPath path, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
         }
@@ -493,11 +363,6 @@ public interface MailboxListener {
          */
         private static final long serialVersionUID = 1L;
 
-        @Deprecated
-        public Added(MailboxSession session, MailboxPath path, MailboxId mailboxId) {
-            super(session, path, mailboxId);
-        }
-
         public Added(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath
path, MailboxId mailboxId) {
             super(sessionId, user, path, mailboxId);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
index d515147..d749146 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
@@ -24,6 +24,7 @@ import static org.apache.james.quota.search.QuotaSearchFixture.TestConstants.NOW
 import static org.apache.james.quota.search.QuotaSearchFixture.TestConstants.QUOTAROOT;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.mockito.Mockito.mock;
 
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
@@ -34,7 +35,6 @@ import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener.QuotaUsageUpdatedEvent;
-import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.quota.QuotaFixture.Counts;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
 import org.apache.james.quota.search.elasticsearch.QuotaRatioElasticSearchConstants;
@@ -52,8 +52,7 @@ import org.junit.rules.TemporaryFolder;
 public class ElasticSearchQuotaMailboxListenerTest {
 
     private static final int BATCH_SIZE = 1;
-    private static final MailboxSession MAILBOX_SESSION = null;
-    private static final Event EVENT = () -> MAILBOX_SESSION;
+    private static final Event DUMB_EVENT = mock(Event.class);
 
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
     private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
@@ -80,7 +79,7 @@ public class ElasticSearchQuotaMailboxListenerTest {
 
     @Test
     public void eventShouldDoNothingWhenNoQuotaEvent() throws Exception {
-        quotaMailboxListener.event(EVENT);
+        quotaMailboxListener.event(DUMB_EVENT);
 
         embeddedElasticSearch.awaitForElasticSearch();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java
index 5ba1ddf..cb504c9 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java
@@ -105,11 +105,6 @@ public class MessageMoveEvent implements Event {
     }
 
     @Override
-    public MailboxSession getSession() {
-        throw new UnsupportedOperationException("wiil be removed");
-    }
-
-    @Override
     public User getUser() {
         return user;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
index e8f4e54..d08afda 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
@@ -87,7 +87,8 @@ public class ListeningCurrentQuotaUpdater implements MailboxListener, QuotaUpdat
         if (addedCount != 0 && addedSize != 0) {
             currentQuotaManager.decrease(quotaRoot, addedCount, addedSize);
         }
-        dispatcher.quota(expunged.getUser(),
+        dispatcher.quota(
+            expunged.getUser(),
             quotaRoot,
             quotaManager.getMessageQuota(quotaRoot),
             quotaManager.getStorageQuota(quotaRoot));
@@ -104,7 +105,8 @@ public class ListeningCurrentQuotaUpdater implements MailboxListener,
QuotaUpdat
         if (addedCount != 0 && addedSize != 0) {
             currentQuotaManager.increase(quotaRoot, addedCount, addedSize);
         }
-        dispatcher.quota(added.getUser(),
+        dispatcher.quota(
+            added.getUser(),
             quotaRoot,
             quotaManager.getMessageQuota(quotaRoot),
             quotaManager.getStorageQuota(quotaRoot));

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/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 44ffae0..45ef1ea 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
@@ -24,10 +24,10 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
 
+import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.junit.After;
@@ -53,23 +53,27 @@ public class AsynchronousEventDeliveryTest {
     }
 
     @Test
-    public void deliverShouldWork() throws Exception {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, null, null) {};
+    public void deliverShouldWork() {
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
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, null) {};
+    public void deliverShouldNotPropagateException() {
+        MockMailboxSession session = new MockMailboxSession("test");
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(session.getSessionId()),
+            session.getUser().getCoreUser(), null, null) {};
         doThrow(new RuntimeException()).when(mailboxListener).event(event);
         asynchronousEventDelivery.deliver(mailboxListener, event);
         verify(mailboxListener, timeout(ONE_MINUTE)).event(event);
     }
 
     @Test
-    public void deliverShouldWorkWhenThePoolIsFull() throws Exception {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(new MockMailboxSession("test"),
null, null) {};
+    public void deliverShouldWorkWhenThePoolIsFull() {
+        MockMailboxSession session = new MockMailboxSession("test");
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(session.getSessionId()),
+            session.getUser().getCoreUser(), 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/262e206e/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 7442a98..87ce925 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
@@ -83,7 +83,7 @@ public class DefaultDelegatingMailboxListenerTest {
 
     @Test
     public void eventShouldWork() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -92,7 +92,7 @@ public class DefaultDelegatingMailboxListenerTest {
 
     @Test
     public void eventShouldOnlyTriggerMAILBOXListenerRelatedToTheEvent() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, OTHER_MAILBOX_PATH, OTHER_MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, OTHER_MAILBOX_PATH, OTHER_MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).isEmpty();
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -104,9 +104,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((MailboxSession)
null, MAILBOX_PATH, quotaRoot, deletedMessageCount, totalDeletedSize, MAILBOX_ID) {};
+        MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(Optional.empty(),
null, MAILBOX_PATH, quotaRoot, deletedMessageCount, totalDeletedSize, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
-        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent((MailboxSession)
null, MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(Optional.empty(),
null, MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(secondEvent);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent);
@@ -118,9 +118,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((MailboxSession)
null, MAILBOX_PATH, quotaRoot, quotaCount, quotaSize, MAILBOX_ID) {};
+        MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(Optional.empty(),
null, MAILBOX_PATH, quotaRoot, quotaCount, quotaSize, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
-        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent((MailboxSession)
null, OTHER_MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(Optional.empty(),
null, OTHER_MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(secondEvent);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent);
@@ -130,7 +130,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void removeListenerShouldWork() {
         defaultDelegatingMailboxListener.removeListener(MAILBOX_ID, mailboxEventCollector,
null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).isEmpty();
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -140,7 +140,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void removeListenerShouldNotRemoveAListenerFromADifferentPath() {
         defaultDelegatingMailboxListener.removeListener(OTHER_MAILBOX_ID, mailboxEventCollector,
null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -150,7 +150,7 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void removeGlobalListenerShouldWorkForONCE() {
         defaultDelegatingMailboxListener.removeGlobalListener(eachNodeEventCollector, null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).isEmpty();
@@ -158,9 +158,9 @@ public class DefaultDelegatingMailboxListenerTest {
     }
 
     @Test
-    public void removeGlobalListenerShouldWorkForEACH_NODE() {
+    public void removeGlobalListenerShouldWorkForEACH_NODE() throws Exception {
         defaultDelegatingMailboxListener.removeGlobalListener(onceEventCollector, null);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, MAILBOX_PATH, MAILBOX_ID) {};
         defaultDelegatingMailboxListener.event(event);
         assertThat(mailboxEventCollector.getEvents()).containsExactly(event);
         assertThat(eachNodeEventCollector.getEvents()).containsExactly(event);
@@ -170,7 +170,8 @@ public class DefaultDelegatingMailboxListenerTest {
     @Test
     public void listenersErrorsShouldNotBePropageted() throws Exception {
         MailboxSession session = new MockMailboxSession("benwa");
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session, MAILBOX_PATH,
MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.of(session.getSessionId()),
+            session.getUser().getCoreUser(), 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/262e206e/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 f9e1ec1..ea6f4bd 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
@@ -96,7 +96,7 @@ public class MailboxAnnotationListenerTest {
 
     @Test
     public void eventShouldDoNothingIfDoNotHaveMailboxDeletionEvent() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, MAILBOX_PATH, MAILBOX_ID) {};
         listener.event(event);
 
         verifyNoMoreInteractions(mailboxSessionMapperFactory);

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/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 c2cc095..8c19b3a 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
@@ -25,11 +25,11 @@ import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import java.util.Optional;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.junit.After;
 import org.junit.Before;
@@ -59,14 +59,14 @@ public class MixedEventDeliveryTest {
     @Test
     public void deliverShouldWorkOnSynchronousListeners() {
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, null, null) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, null, null) {};
         mixedEventDelivery.deliver(listener, event);
         verify(listener).event(event);
     }
 
     @Test
     public void deliverShouldEventuallyDeliverOnAsynchronousListeners() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, null, null) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
null, null, null) {};
         when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
         mixedEventDelivery.deliver(listener, event);
         verify(listener, timeout(DELIVERY_DELAY * 10)).event(event);
@@ -74,7 +74,7 @@ public class MixedEventDeliveryTest {
 
     @Test(timeout = ONE_MINUTE)
     public void deliverShouldNotBlockOnAsynchronousListeners() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, null, null) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
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/262e206e/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 4a1ebda..64ad475 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
@@ -23,8 +23,9 @@ import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
+import java.util.Optional;
+
 import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.junit.Before;
@@ -43,14 +44,16 @@ public class SynchronousEventDeliveryTest {
 
     @Test
     public void deliverShouldWork() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent((MailboxSession)
null, null, null) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(),
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, null) {};
+        MockMailboxSession session = new MockMailboxSession("test");
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(session.getSessionId()),
+            session.getUser().getCoreUser(),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/262e206e/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 c80b019..320fd36 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
@@ -21,9 +21,11 @@ package org.apache.james.imap.processor.base;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Optional;
 
 import javax.mail.Flags;
 
+import org.apache.james.core.User;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
@@ -36,8 +38,8 @@ public class FakeMailboxListenerAdded extends MailboxListener.Added {
 
     public List<MessageUid> uids;
 
-    public FakeMailboxListenerAdded(MailboxSession session, List<MessageUid> uids,
MailboxPath path, MailboxId mailboxId) {
-        super(session, path, mailboxId);
+    public FakeMailboxListenerAdded(MailboxSession.SessionId sessionId, User user, List<MessageUid>
uids, MailboxPath path, MailboxId mailboxId) {
+        super(Optional.ofNullable(sessionId), user, path, mailboxId);
         this.uids = uids;
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/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 dbedabe..2ca6120 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
@@ -20,7 +20,9 @@
 package org.apache.james.imap.processor.base;
 
 import java.util.List;
+import java.util.Optional;
 
+import org.apache.james.core.User;
 import org.apache.james.mailbox.MailboxListener.FlagsUpdated;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
@@ -35,7 +37,11 @@ public class FakeMailboxListenerFlagsUpdate extends FlagsUpdated {
     public List<UpdatedFlags> flags;
 
     public FakeMailboxListenerFlagsUpdate(MailboxSession session, List<MessageUid>
uids, List<UpdatedFlags> flags, MailboxPath path, MailboxId mailboxId) {
-        super(session, path, mailboxId);
+        this(session.getSessionId(), session.getUser().getCoreUser(), uids, flags, path,
mailboxId);
+    }
+
+    FakeMailboxListenerFlagsUpdate(MailboxSession.SessionId sessionId, User user, List<MessageUid>
uids, List<UpdatedFlags> flags, MailboxPath path, MailboxId mailboxId) {
+        super(Optional.ofNullable(sessionId), user, path, mailboxId);
         this.uids = uids;
         this.flags = flags;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/262e206e/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 5cd3449..5774f57 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
@@ -24,6 +24,8 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import java.util.Optional;
+
 import javax.mail.Flags;
 
 import org.apache.commons.lang3.NotImplementedException;
@@ -124,7 +126,8 @@ public class MailboxEventAnalyserTest {
 
     @Test
     public void testShouldBeNoSizeChangeOnOtherEvent() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(MAILBOX_SESSION,
MAILBOX_PATH, MAILBOX_ID) {};
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(MAILBOX_SESSION.getSessionId()),
+            MAILBOX_SESSION.getUser().getCoreUser(), MAILBOX_PATH, MAILBOX_ID) {};
       
         testee.event(event);
 
@@ -133,13 +136,16 @@ public class MailboxEventAnalyserTest {
 
     @Test
     public void testShouldBeNoSizeChangeOnAdded() {
-        testee.event(new FakeMailboxListenerAdded(MAILBOX_SESSION, ImmutableList.of(MessageUid.of(11)),
MAILBOX_PATH, MAILBOX_ID));
+        testee.event(new FakeMailboxListenerAdded(MAILBOX_SESSION.getSessionId(),
+            MAILBOX_SESSION.getUser().getCoreUser(),
+            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, MAILBOX_ID));
+        testee.event(new FakeMailboxListenerAdded(MAILBOX_SESSION.getSessionId(),
+            MAILBOX_SESSION.getUser().getCoreUser(), ImmutableList.of(MessageUid.of(11)),
MAILBOX_PATH, MAILBOX_ID));
         testee.resetEvents();
 
         assertThat(testee.isSizeChanged()).isFalse();


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