JAMES-2616 replace getSession() in QuotaThresholdCrossingListener
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7a799699 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7a799699 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7a799699 Branch: refs/heads/master Commit: 7a7996993f3142efc663fb03f61bfc767a26a515 Parents: 4602954 Author: tran tien duc <dt...@linagora.com> Authored: Fri Nov 30 11:57:00 2018 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Fri Dec 7 07:52:51 2018 +0700 ---------------------------------------------------------------------- .../QuotaThresholdCrossingListener.java | 10 +--- .../QuotaThresholdConfigurationChangesTest.java | 50 ++++++++--------- .../QuotaThresholdMailingIntegrationTest.java | 56 ++++++++++---------- .../quota/model/QuotaThresholdFixture.java | 4 +- .../ElasticSearchQuotaMailboxListenerTest.java | 4 +- .../json/QuotaRatioToElasticSearchJsonTest.java | 6 +-- .../james/quota/search/QuotaSearchFixture.java | 4 +- 7 files changed, 63 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/7a799699/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java index d669cba..3f421c3 100644 --- a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java +++ b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java @@ -70,7 +70,7 @@ public class QuotaThresholdCrossingListener implements MailboxListener { public void event(Event event) { try { if (event instanceof QuotaUsageUpdatedEvent) { - handleEvent(getUser(event), (QuotaUsageUpdatedEvent) event); + handleEvent(event.getUser(), (QuotaUsageUpdatedEvent) event); } } catch (Exception e) { LOGGER.error("Can not re-emmit quota threshold events", e); @@ -81,12 +81,4 @@ public class QuotaThresholdCrossingListener implements MailboxListener { eventSourcingSystem.dispatch( new DetectThresholdCrossing(user, event.getCountQuota(), event.getSizeQuota(), event.getInstant())); } - - private User getUser(Event event) { - return User.fromUsername( - event.getSession() - .getUser() - .getUserName()); - } - } http://git-wip-us.apache.org/repos/asf/james-project/blob/7a799699/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java index 4876b3a..87d720d 100644 --- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java +++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java @@ -19,7 +19,7 @@ package org.apache.james.mailbox.quota.mailing.listeners; -import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.BOB_SESSION; +import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.BOB_USER; import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.GRACE_PERIOD; import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.NOW; import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.QUOTAROOT; @@ -57,12 +57,12 @@ public interface QuotaThresholdConfigurationChangesTest { QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -72,12 +72,12 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -87,12 +87,12 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -102,12 +102,12 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -117,12 +117,12 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -132,12 +132,12 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -147,13 +147,13 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50_75); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -163,13 +163,13 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50_75); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -179,13 +179,13 @@ public interface QuotaThresholdConfigurationChangesTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50_75); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -196,12 +196,12 @@ public interface QuotaThresholdConfigurationChangesTest { QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50_75); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -212,12 +212,12 @@ public interface QuotaThresholdConfigurationChangesTest { QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50_75); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._92_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -228,12 +228,12 @@ public interface QuotaThresholdConfigurationChangesTest { QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50_75); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } http://git-wip-us.apache.org/repos/asf/james-project/blob/7a799699/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java index 0409a45..f1a8343 100644 --- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java +++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java @@ -19,7 +19,7 @@ package org.apache.james.mailbox.quota.mailing.listeners; -import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.BOB_SESSION; +import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.BOB_USER; import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.DEFAULT_CONFIGURATION; import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.GRACE_PERIOD; import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.TestConstants.NOW; @@ -53,7 +53,7 @@ public interface QuotaThresholdMailingIntegrationTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -62,10 +62,10 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldNotSendMailWhenNoThresholdUpdate(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, ONE_HOUR_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, ONE_HOUR_AGO)); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -74,11 +74,11 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldNotSendMailWhenThresholdOverPassedRecently(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, TWELVE_HOURS_AGO)); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_HOURS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, TWELVE_HOURS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_HOURS_AGO)); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -88,7 +88,7 @@ public interface QuotaThresholdMailingIntegrationTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -97,9 +97,9 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldNotSendDuplicates(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, ONE_HOUR_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, ONE_HOUR_AGO)); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -108,9 +108,9 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldNotifySeparatelyCountAndSize(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, ONE_HOUR_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, ONE_HOUR_AGO)); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._60_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._60_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(2); } @@ -120,7 +120,7 @@ public interface QuotaThresholdMailingIntegrationTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._55_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -129,11 +129,11 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldSendMailWhenThresholdOverPassedOverGracePeriod(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, TWELVE_DAYS_AGO)); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_DAYS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, TWELVE_DAYS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_DAYS_AGO)); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -142,10 +142,10 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldNotSendMailWhenNoThresholdUpdateForCount(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._32_PERCENT, Sizes._55_PERCENT, TWO_DAYS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._32_PERCENT, Sizes._55_PERCENT, TWO_DAYS_AGO)); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, TWO_DAYS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._60_PERCENT, TWO_DAYS_AGO)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -154,11 +154,11 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldNotSendMailWhenThresholdOverPassedRecentlyForCount(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, TWELVE_HOURS_AGO)); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_HOURS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, TWELVE_HOURS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_HOURS_AGO)); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).isEmpty(); } @@ -168,7 +168,7 @@ public interface QuotaThresholdMailingIntegrationTest { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, TWELVE_HOURS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, TWELVE_HOURS_AGO)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -177,11 +177,11 @@ public interface QuotaThresholdMailingIntegrationTest { default void shouldSendMailWhenThresholdOverPassedOverGracePeriodForCount(EventStore store) throws Exception { FakeMailContext mailetContext = mailetContext(); QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext, store, DEFAULT_CONFIGURATION); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, TWELVE_DAYS_AGO)); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_DAYS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, TWELVE_DAYS_AGO)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._30_PERCENT, SIX_DAYS_AGO)); mailetContext.resetSentMails(); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, NOW)); assertThat(mailetContext.getSentMails()).hasSize(1); } @@ -195,8 +195,8 @@ public interface QuotaThresholdMailingIntegrationTest { .gracePeriod(GRACE_PERIOD) .build()); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, NOW)); - testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._85_PERCENT, Sizes._42_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._30_PERCENT, NOW)); + testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._85_PERCENT, Sizes._42_PERCENT, NOW)); assertThat(mailetContext.getSentMails()) .hasSize(2); @@ -212,7 +212,7 @@ public interface QuotaThresholdMailingIntegrationTest { .build()); ConcurrentTestRunner.builder() - .operation((threadNb, step) -> testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW))) + .operation((threadNb, step) -> testee.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._40_PERCENT, Sizes._55_PERCENT, NOW))) .threadCount(10) .runSuccessfullyWithin(Duration.ofMinutes(1)); http://git-wip-us.apache.org/repos/asf/james-project/blob/7a799699/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdFixture.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdFixture.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdFixture.java index d5ed137..01f1e0a 100644 --- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdFixture.java +++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/model/QuotaThresholdFixture.java @@ -23,7 +23,7 @@ import java.time.Duration; import java.time.Instant; import java.util.Optional; -import org.apache.james.mailbox.mock.MockMailboxSession; +import org.apache.james.core.User; import org.apache.james.mailbox.model.QuotaRoot; import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration; import org.apache.mailet.base.MailAddressFixture; @@ -45,7 +45,7 @@ public interface QuotaThresholdFixture { .gracePeriod(GRACE_PERIOD) .build(); String BOB = "bob@domain"; - MockMailboxSession BOB_SESSION = new MockMailboxSession(BOB); + User BOB_USER = User.fromUsername(BOB); Instant NOW = Instant.now(); QuotaRoot QUOTAROOT = QuotaRoot.quotaRoot("any", Optional.empty()); Instant ONE_HOUR_AGO = NOW.minus(Duration.ofHours(1)); http://git-wip-us.apache.org/repos/asf/james-project/blob/7a799699/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 dabec13..d515147 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 @@ -19,7 +19,7 @@ package org.apache.james.quota.search.elasticsearch.events; -import static org.apache.james.quota.search.QuotaSearchFixture.TestConstants.BOB_SESSION; +import static org.apache.james.quota.search.QuotaSearchFixture.TestConstants.BOB_USER; 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; @@ -94,7 +94,7 @@ public class ElasticSearchQuotaMailboxListenerTest { @Test public void eventShouldIndexEventWhenQuotaEvent() throws Exception { - quotaMailboxListener.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._52_PERCENT, Sizes._55_PERCENT, NOW)); + quotaMailboxListener.event(new QuotaUsageUpdatedEvent(BOB_USER, QUOTAROOT, Counts._52_PERCENT, Sizes._55_PERCENT, NOW)); embeddedElasticSearch.awaitForElasticSearch(); http://git-wip-us.apache.org/repos/asf/james-project/blob/7a799699/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java index 6684a16..4564be1 100644 --- a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java +++ b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java @@ -26,8 +26,8 @@ import java.time.Instant; import java.util.Optional; import org.apache.james.core.Domain; +import org.apache.james.core.User; import org.apache.james.mailbox.MailboxListener.QuotaUsageUpdatedEvent; -import org.apache.james.mailbox.mock.MockMailboxSession; import org.apache.james.mailbox.model.QuotaRoot; import org.apache.james.mailbox.quota.QuotaFixture; import org.apache.james.util.ClassLoaderUtils; @@ -39,7 +39,7 @@ public class QuotaRatioToElasticSearchJsonTest { public void quotaRatioShouldBeWellConvertedToJson() throws IOException { String user = "u...@domain.org"; QuotaUsageUpdatedEvent event = new QuotaUsageUpdatedEvent( - new MockMailboxSession(user), + User.fromUsername(user), QuotaRoot.quotaRoot("any", Optional.of(Domain.of("domain.org"))), QuotaFixture.Counts._52_PERCENT, QuotaFixture.Sizes._55_PERCENT, @@ -58,7 +58,7 @@ public class QuotaRatioToElasticSearchJsonTest { public void quotaRatioShouldBeWellConvertedToJsonWhenNoDomain() throws IOException { String user = "user"; QuotaUsageUpdatedEvent event = new QuotaUsageUpdatedEvent( - new MockMailboxSession(user), + User.fromUsername(user), QuotaRoot.quotaRoot("any", Optional.empty()), QuotaFixture.Counts._52_PERCENT, QuotaFixture.Sizes._55_PERCENT, http://git-wip-us.apache.org/repos/asf/james-project/blob/7a799699/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearchFixture.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearchFixture.java b/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearchFixture.java index 515a004..c291bfa 100644 --- a/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearchFixture.java +++ b/mailbox/plugin/quota-search/src/test/java/org/apache/james/quota/search/QuotaSearchFixture.java @@ -22,14 +22,14 @@ package org.apache.james.quota.search; import java.time.Instant; import java.util.Optional; -import org.apache.james.mailbox.mock.MockMailboxSession; +import org.apache.james.core.User; import org.apache.james.mailbox.model.QuotaRoot; public interface QuotaSearchFixture { interface TestConstants { String BOB = "bob@domain"; - MockMailboxSession BOB_SESSION = new MockMailboxSession(BOB); + User BOB_USER = User.fromUsername(BOB); Instant NOW = Instant.now(); QuotaRoot QUOTAROOT = QuotaRoot.quotaRoot("any", Optional.empty()); } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org