james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [13/15] james-project git commit: MAILBOX-333 Configuration should allow passing templates
Date Thu, 10 May 2018 02:31:20 GMT
MAILBOX-333 Configuration should allow passing templates


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

Branch: refs/heads/master
Commit: ae9a8e6cf1d4f1089eceeb95d9941bc8bf521bde
Parents: 409792c
Author: benwa <btellier@linagora.com>
Authored: Wed May 9 09:51:58 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Thu May 10 09:24:27 2018 +0700

----------------------------------------------------------------------
 .../QuotaMailingListenerConfiguration.java      | 89 ++++++++++++++++++--
 .../QuotaThresholdConfigurationChangesTest.java | 83 +++++++++---------
 .../QuotaThresholdMailingIntegrationTest.java   | 12 ++-
 .../quota/model/QuotaThresholdFixture.java      |  8 +-
 4 files changed, 134 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ae9a8e6c/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/QuotaMailingListenerConfiguration.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/QuotaMailingListenerConfiguration.java
b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/QuotaMailingListenerConfiguration.java
index 25d504c..5551b20 100644
--- a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/QuotaMailingListenerConfiguration.java
+++ b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/QuotaMailingListenerConfiguration.java
@@ -20,24 +20,89 @@
 package org.apache.james.mailbox.quota.mailing;
 
 import java.time.Duration;
+import java.util.Collection;
 import java.util.Objects;
+import java.util.Optional;
 
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.mailbox.quota.model.QuotaThreshold;
 import org.apache.james.mailbox.quota.model.QuotaThresholds;
 
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableList;
 
 public class QuotaMailingListenerConfiguration {
-    public static QuotaMailingListenerConfiguration DEFAULT = new QuotaMailingListenerConfiguration(
-        new QuotaThresholds(ImmutableList.of()),
-        Duration.ofDays(1));
+
+    public static class Builder {
+        private ImmutableList.Builder<QuotaThreshold> thresholds;
+        private Optional<Duration> gradePeriod;
+        private Optional<String> bodyTemplate;
+        private Optional<String> subjectTemplate;
+
+        private Builder() {
+            thresholds = ImmutableList.builder();
+            gradePeriod = Optional.empty();
+            bodyTemplate = Optional.empty();
+            subjectTemplate = Optional.empty();
+        }
+
+        public Builder addThreshold(QuotaThreshold quotaThreshold) {
+            thresholds.add(quotaThreshold);
+            return this;
+        }
+
+        public Builder addThresholds(QuotaThreshold... quotaThresholds) {
+            thresholds.add(quotaThresholds);
+            return this;
+        }
+
+        public Builder addThresholds(Collection<QuotaThreshold> quotaThresholds) {
+            thresholds.addAll(quotaThresholds);
+            return this;
+        }
+
+        public Builder withGracePeriod(Duration duration) {
+            this.gradePeriod = Optional.of(duration);
+            return this;
+        }
+        
+        public Builder withBodyTemplate(String bodyTemplate) {
+            this.bodyTemplate = Optional.of(bodyTemplate);
+            return this;
+        }
+
+        public Builder withSubjectTemplate(String subjectTemplate) {
+            this.subjectTemplate = Optional.of(subjectTemplate);
+            return this;
+        }
+
+        public QuotaMailingListenerConfiguration build() {
+            return new QuotaMailingListenerConfiguration(
+                new QuotaThresholds(thresholds.build()),
+                gradePeriod.orElse(DEFAULT_GRACE_PERIOD),
+                bodyTemplate.orElse(DEFAULT_BODY_TEMPLATE),
+                subjectTemplate.orElse(DEFAULT_SUBJECT_TEMPLATE));
+        }
+    }
+
+    public static final String DEFAULT_BODY_TEMPLATE = FileSystem.CLASSPATH_PROTOCOL + "//templates/QuotaThresholdMailBody.mustache";
+    public static final String DEFAULT_SUBJECT_TEMPLATE = FileSystem.CLASSPATH_PROTOCOL +
"//templates/QuotaThresholdMailSubject.mustache";
+    public static final Duration DEFAULT_GRACE_PERIOD = Duration.ofDays(1);
+
+    public static Builder builder() {
+        return new Builder();
+    }
 
     private final QuotaThresholds thresholds;
     private final Duration gracePeriod;
+    private final String bodyTemplate;
+    private final String subjectTemplate;
 
-    public QuotaMailingListenerConfiguration(QuotaThresholds thresholds, Duration gracePeriod)
{
+    private QuotaMailingListenerConfiguration(QuotaThresholds thresholds, Duration gracePeriod,
String bodyTemplate, String subjectTemplate) {
         this.thresholds = thresholds;
         this.gracePeriod = gracePeriod;
+        this.bodyTemplate = bodyTemplate;
+        this.subjectTemplate = subjectTemplate;
     }
 
     public QuotaThresholds getThresholds() {
@@ -48,20 +113,30 @@ public class QuotaMailingListenerConfiguration {
         return gracePeriod;
     }
 
+    public String getBodyTemplate() {
+        return bodyTemplate;
+    }
+
+    public String getSubjectTemplate() {
+        return subjectTemplate;
+    }
+
     @Override
     public final boolean equals(Object o) {
         if (o instanceof QuotaMailingListenerConfiguration) {
             QuotaMailingListenerConfiguration that = (QuotaMailingListenerConfiguration)
o;
 
             return Objects.equals(this.thresholds, that.thresholds)
-                && Objects.equals(this.gracePeriod, that.gracePeriod);
+                && Objects.equals(this.gracePeriod, that.gracePeriod)
+                && Objects.equals(this.bodyTemplate, that.bodyTemplate)
+                && Objects.equals(this.subjectTemplate, that.subjectTemplate);
         }
         return false;
     }
 
     @Override
     public final int hashCode() {
-        return Objects.hash(thresholds, gracePeriod);
+        return Objects.hash(thresholds, gracePeriod, bodyTemplate, subjectTemplate);
     }
 
     @Override
@@ -69,6 +144,8 @@ public class QuotaMailingListenerConfiguration {
         return MoreObjects.toStringHelper(this)
             .add("thresholds", thresholds)
             .add("gracePeriod", gracePeriod)
+            .add("bodyTemplate", bodyTemplate)
+            .add("subjectTemplate", subjectTemplate)
             .toString();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/ae9a8e6c/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 135b84c..fe57929 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
@@ -33,24 +33,33 @@ import org.apache.james.mailbox.MailboxListener.QuotaUsageUpdatedEvent;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
 import org.apache.james.mailbox.quota.model.QuotaThresholdFixture.Quotas.Counts;
 import org.apache.james.mailbox.quota.model.QuotaThresholdFixture.Quotas.Sizes;
-import org.apache.james.mailbox.quota.model.QuotaThresholds;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.junit.jupiter.api.Test;
 
-import com.google.common.collect.ImmutableList;
-
 public interface QuotaThresholdConfigurationChangesTest {
 
+    QuotaMailingListenerConfiguration CONFIGURATION_50 = QuotaMailingListenerConfiguration.builder()
+        .addThreshold(_50)
+        .gracePeriod(GRACE_PERIOD)
+        .build();
+    QuotaMailingListenerConfiguration CONFIGURATION_75 = QuotaMailingListenerConfiguration.builder()
+        .addThreshold(_75)
+        .gracePeriod(GRACE_PERIOD)
+        .build();
+    QuotaMailingListenerConfiguration CONFIGURATION_50_75 = QuotaMailingListenerConfiguration.builder()
+        .addThresholds(_50, _75)
+        .gracePeriod(GRACE_PERIOD)
+        .build();
+
     @Test
     default void shouldNotSendMailWhenNoNewExceededThresholdAfterThresholdIncrease(EventStore
store) throws Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_50);
+
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._55_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._55_PERCENT, NOW));
@@ -61,13 +70,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldNotSendMailAfterThresholdDecreaseWhenAboveAll(EventStore store) throws
Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_75);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
@@ -78,13 +85,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldSendMailWhenNewExceededThresholdAfterThresholdIncrease(EventStore
store) throws Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_50);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
@@ -95,13 +100,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldNotSendMailAfterThresholdIncreaseWhenBelowAll(EventStore store) throws
Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_50);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._30_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._30_PERCENT, NOW));
@@ -112,13 +115,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldNotSendMailAfterThresholdDecreaseWhenBelowAll(EventStore store) throws
Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_75);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._30_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._30_PERCENT, NOW));
@@ -129,13 +130,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldSendMailWhenNewExceededThresholdAfterThresholdDecrease(EventStore
store) throws Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_75);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._60_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._60_PERCENT, NOW));
@@ -146,13 +145,12 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldSendEmailWhenAddingANewHighestExceededThreshold(EventStore store)
throws Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_50);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
 
         testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50,
_75)), GRACE_PERIOD));
+            CONFIGURATION_50_75);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
@@ -163,13 +161,12 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldNotSendEmailWhenAddingAHighestNonExceededThreshold(EventStore store)
throws Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_50);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._60_PERCENT, NOW));
 
         testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50,
_75)), GRACE_PERIOD));
+            CONFIGURATION_50_75);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._60_PERCENT, NOW));
@@ -180,13 +177,12 @@ public interface QuotaThresholdConfigurationChangesTest {
     @Test
     default void shouldNotSendEmailWhenAddingANonHighestExceededThreshold(EventStore store)
throws Exception {
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, CONFIGURATION_75);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
 
         testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50,
_75)), GRACE_PERIOD));
+            CONFIGURATION_50_75);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
@@ -198,12 +194,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     default void shouldNotSendEmailWhenRemovingANonHighestExceededThreshold(EventStore store)
throws Exception {
         FakeMailContext mailetContext = mailetContext();
         QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50,
_75)), GRACE_PERIOD));
+            CONFIGURATION_50_75);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_75)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_75);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
@@ -215,12 +210,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     default void shouldNotSendEmailWhenRemovingHighestExceededThreshold(EventStore store)
throws Exception {
         FakeMailContext mailetContext = mailetContext();
         QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50,
_75)), GRACE_PERIOD));
+            CONFIGURATION_50_75);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._92_PERCENT, NOW));
@@ -232,12 +226,11 @@ public interface QuotaThresholdConfigurationChangesTest {
     default void shouldNotSendEmailWhenRemovingHighestNonExceededThreshold(EventStore store)
throws Exception {
         FakeMailContext mailetContext = mailetContext();
         QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50,
_75)), GRACE_PERIOD));
+            CONFIGURATION_50_75);
 
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._60_PERCENT, NOW));
 
-        testee = new QuotaThresholdListenersTestSystem(mailetContext, store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(ImmutableList.of(_50)),
GRACE_PERIOD));
+        testee = new QuotaThresholdListenersTestSystem(mailetContext, store, CONFIGURATION_50);
 
         mailetContext.resetSentMails();
         testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._60_PERCENT, NOW));

http://git-wip-us.apache.org/repos/asf/james-project/blob/ae9a8e6c/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 54854cc..86e947e 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
@@ -42,7 +42,6 @@ import org.apache.james.mailbox.MailboxListener.QuotaUsageUpdatedEvent;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
 import org.apache.james.mailbox.quota.model.QuotaThresholdFixture.Quotas.Counts;
 import org.apache.james.mailbox.quota.model.QuotaThresholdFixture.Quotas.Sizes;
-import org.apache.james.mailbox.quota.model.QuotaThresholds;
 import org.apache.james.util.concurrency.ConcurrentTestRunner;
 import org.apache.mailet.base.test.FakeMailContext;
 import org.junit.jupiter.api.Test;
@@ -191,7 +190,10 @@ public interface QuotaThresholdMailingIntegrationTest {
     default void shouldSendOneNoticePerThreshold(EventStore store) throws Exception {
         FakeMailContext mailetContext = mailetContext();
         QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
-            new QuotaMailingListenerConfiguration(new QuotaThresholds(_50, _80), GRACE_PERIOD));
+            QuotaMailingListenerConfiguration.builder()
+                .addThresholds(_50, _80)
+                .withGracePeriod(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));
@@ -203,7 +205,11 @@ public interface QuotaThresholdMailingIntegrationTest {
     @Test
     default void shouldSendOneMailUponConcurrentEvents(EventStore store) throws Exception
{
         FakeMailContext mailetContext = mailetContext();
-        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store, new QuotaMailingListenerConfiguration(new QuotaThresholds(_50, _80), GRACE_PERIOD));
+        QuotaThresholdListenersTestSystem testee = new QuotaThresholdListenersTestSystem(mailetContext,
store,
+            QuotaMailingListenerConfiguration.builder()
+                .addThresholds(_50, _80)
+                .withGracePeriod(GRACE_PERIOD)
+                .build());
 
         new ConcurrentTestRunner(10, 1, (threadNb, step) ->
             testee.event(new QuotaUsageUpdatedEvent(BOB_SESSION, QUOTAROOT, Counts._40_PERCENT,
Sizes._55_PERCENT, NOW)))

http://git-wip-us.apache.org/repos/asf/james-project/blob/ae9a8e6c/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 1770420..7445fb7 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
@@ -32,8 +32,6 @@ import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
 import org.apache.mailet.base.MailAddressFixture;
 import org.apache.mailet.base.test.FakeMailContext;
 
-import com.google.common.collect.ImmutableList;
-
 public interface QuotaThresholdFixture {
     QuotaThreshold _50 = new QuotaThreshold(0.50);
     QuotaThreshold _75 = new QuotaThreshold(0.75);
@@ -124,8 +122,10 @@ public interface QuotaThresholdFixture {
 
     interface TestConstants {
         Duration GRACE_PERIOD = Duration.ofDays(1);
-        QuotaThresholds SINGLE_THRESHOLD = new QuotaThresholds(ImmutableList.of(_50));
-        QuotaMailingListenerConfiguration DEFAULT_CONFIGURATION = new QuotaMailingListenerConfiguration(SINGLE_THRESHOLD,
GRACE_PERIOD);
+        QuotaMailingListenerConfiguration DEFAULT_CONFIGURATION = QuotaMailingListenerConfiguration.builder()
+            .addThresholds(_50)
+            .withGracePeriod(GRACE_PERIOD)
+            .build();
         String BOB = "bob@domain";
         MockMailboxSession BOB_SESSION = new MockMailboxSession(BOB);
         Instant NOW = Instant.now();


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