MAILBOX-333 Demonstrate a bug upon unlimited quotas exceeding a threshold
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d11d5d51 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d11d5d51 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d11d5d51 Branch: refs/heads/master Commit: d11d5d517923258ddc2926955af7fa406701e350 Parents: ae9a8e6 Author: benwa <btell...@linagora.com> Authored: Wed May 9 10:13:36 2018 +0700 Committer: benwa <btell...@linagora.com> Committed: Thu May 10 09:24:27 2018 +0700 ---------------------------------------------------------------------- .../subscribers/QuotaThresholdNoticeTest.java | 22 ++++++++++++++++++++ .../quota/model/QuotaThresholdFixture.java | 5 +++++ 2 files changed, 27 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/d11d5d51/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java index 03c2ea2..b656cf0 100644 --- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java +++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/subscribers/QuotaThresholdNoticeTest.java @@ -34,6 +34,7 @@ import org.apache.james.mailbox.quota.model.HistoryEvolution; import org.apache.james.mailbox.quota.model.QuotaThresholdChange; import org.apache.james.mailbox.quota.model.QuotaThresholdFixture.Quotas.Counts; import org.apache.james.mailbox.quota.model.QuotaThresholdFixture.Quotas.Sizes; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import nl.jqno.equalsverifier.EqualsVerifier; @@ -199,4 +200,25 @@ class QuotaThresholdNoticeTest { "You need to be aware that actions leading to exceeded quotas will be denied. This will result in a degraded service.\n" + "To mitigate this issue you might reach your administrator in order to increase your configured quota. You might also delete some non important emails."); } + + @Disabled + @Test + void generateReportShouldNotFailWhenUnlimitedQuotaExceedsAThreshold() { + QuotaThresholdChange countThresholdChange = new QuotaThresholdChange(_80, NOW); + + assertThat(QuotaThresholdNotice.builder() + .sizeQuota(Sizes._82_PERCENT) + .countQuota(Counts._UNLIMITED) + .countThreshold(HistoryEvolution.higherThresholdReached(countThresholdChange, NotAlreadyReachedDuringGracePeriod)) + .build() + .get() + .generateReport()) + .isEqualTo("You receive this email because you recently exceeded a threshold related to the quotas of your email account.\n" + + "\n" + + "You currently occupy more than 80 % of the total message count allocated to you.\n" + + "You currently have 92 messages on a total of 100 allowed for you.\n" + + "\n" + + "You need to be aware that actions leading to exceeded quotas will be denied. This will result in a degraded service.\n" + + "To mitigate this issue you might reach your administrator in order to increase your configured quota. You might also delete some non important emails."); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/d11d5d51/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 7445fb7..fc32afa 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 @@ -77,6 +77,11 @@ public interface QuotaThresholdFixture { .used(QuotaCount.count(92)) .computedLimit(QuotaCount.count(100)) .build(); + + Quota<QuotaCount> _UNLIMITED = Quota.<QuotaCount>builder() + .used(QuotaCount.count(92)) + .computedLimit(QuotaCount.unlimited()) + .build(); } interface Sizes { Quota<QuotaSize> _30_PERCENT = Quota.<QuotaSize>builder() --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org