JAMES-2344 implement limitByScope quota information in backends

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

Branch: refs/heads/master
Commit: c45b0f3d7dc3744a3f2ac75cfb764aa47e6b5adc
Parents: fa0612a
Author: Matthieu Baechler <matth...@apache.org>
Authored: Fri Mar 9 10:42:34 2018 +0100
Committer: Matthieu Baechler <matth...@apache.org>
Committed: Tue Mar 13 16:10:28 2018 +0100

----------------------------------------------------------------------
 .../org/apache/james/mailbox/model/Quota.java   | 32 +++++++++-
 .../james/mailbox/quota/MaxQuotaManager.java    |  6 ++
 .../quota/CassandraPerUserMaxQuotaManager.java  | 23 +++++++
 .../jpa/quota/JPAPerUserMaxQuotaManager.java    | 24 +++++++
 .../quota/InMemoryPerUserMaxQuotaManager.java   | 23 +++++++
 .../store/quota/FixedMaxQuotaManager.java       | 18 ++++++
 .../mailbox/store/quota/NoMaxQuotaManager.java  | 14 ++++
 .../mailbox/store/quota/StoreQuotaManager.java  |  2 +
 .../store/quota/GenericMaxQuotaManagerTest.java | 67 ++++++++++++++++++++
 9 files changed, 206 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
----------------------------------------------------------------------
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
index 53c1dd7..dd82bd2 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/Quota.java
@@ -18,23 +18,33 @@
  ****************************************************************/
 package org.apache.james.mailbox.model;
 
+import java.util.Map;
+
 import org.apache.james.mailbox.quota.QuotaValue;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
 
 public class Quota<T extends QuotaValue<T>> {
 
+    public enum Scope {
+        Global,
+        User
+    }
+
     public static <T extends QuotaValue<T>> Builder<T> builder() {
         return new Builder<>();
     }
 
     public static class Builder<T extends QuotaValue<T>> {
 
+        private final ImmutableMap.Builder<Scope, T> limitsByScope;
         private T computedLimit;
         private T used;
 
         private Builder() {
+            limitsByScope = ImmutableMap.builder();
         }
 
         public Builder<T> computedLimit(T limit) {
@@ -47,20 +57,32 @@ public class Quota<T extends QuotaValue<T>> {
             return this;
         }
 
+        public Builder<T> limitsByScope(Map<Scope, T> limits) {
+            limitsByScope.putAll(limits);
+            return this;
+        }
+
+        public Builder<T> limitForScope(T limit, Scope scope) {
+            limitsByScope.put(scope, limit);
+            return this;
+        }
+
         public Quota<T> build() {
             Preconditions.checkState(used != null);
             Preconditions.checkState(computedLimit != null);
-            return new Quota<>(used, computedLimit);
+            return new Quota<>(used, computedLimit, limitsByScope.build());
         }
 
     }
 
     private final T limit;
+    private final ImmutableMap<Scope, T> limitByScope;
     private final T used;
 
-    private Quota(T used, T max) {
+    private Quota(T used, T max, ImmutableMap<Scope, T> limitByScope) {
         this.used = used;
         this.limit = max;
+        this.limitByScope = limitByScope;
     }
 
     public T getLimit() {
@@ -71,8 +93,12 @@ public class Quota<T extends QuotaValue<T>> {
         return used;
     }
 
+    public ImmutableMap<Scope, T> getLimitByScope() {
+        return limitByScope;
+    }
+
     public Quota<T> addValueToQuota(T value) {
-        return new Quota<>(used.add(value), limit);
+        return new Quota<>(used.add(value), limit, limitByScope);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
----------------------------------------------------------------------
diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
index 13d8ba2..81814cc 100644
--- 
a/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
+++ 
b/mailbox/api/src/main/java/org/apache/james/mailbox/quota/MaxQuotaManager.java
@@ -19,9 +19,11 @@
 
 package org.apache.james.mailbox.quota;
 
+import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 
 /**
@@ -115,4 +117,8 @@ public interface MaxQuotaManager {
      * @return maximum of allowed message count
      */
     Optional<QuotaCount> getMaxMessage(QuotaRoot quotaRoot) throws 
MailboxException;
+
+    Map<Quota.Scope, QuotaCount> listMaxMessagesDetails(QuotaRoot quotaRoot);
+
+    Map<Quota.Scope, QuotaSize> listMaxStorageDetails(QuotaRoot quotaRoot);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
----------------------------------------------------------------------
diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
index d73db1f..05147bd 100644
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
+++ 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/quota/CassandraPerUserMaxQuotaManager.java
@@ -19,16 +19,21 @@
 
 package org.apache.james.mailbox.cassandra.quota;
 
+import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Stream;
 
 import javax.inject.Inject;
 
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaSize;
 
 import com.github.fge.lambdas.Throwing;
+import com.github.steveash.guavate.Guavate;
 
 public class CassandraPerUserMaxQuotaManager implements MaxQuotaManager {
 
@@ -104,4 +109,22 @@ public class CassandraPerUserMaxQuotaManager implements 
MaxQuotaManager {
             .map(Optional::of)
             
.orElseGet(Throwing.supplier(this::getDefaultMaxMessage).sneakyThrow());
     }
+
+    @Override
+    public Map<Quota.Scope, QuotaCount> listMaxMessagesDetails(QuotaRoot 
quotaRoot) {
+        return Stream.of(
+                Pair.of(Quota.Scope.User, 
perUserQuota.getMaxMessage(quotaRoot)),
+                Pair.of(Quota.Scope.Global, 
defaultQuota.getDefaultMaxMessage()))
+            .filter(pair -> pair.getValue().isPresent())
+            .collect(Guavate.toImmutableMap(Pair::getKey, value -> 
value.getValue().get()));
+    }
+
+    @Override
+    public Map<Quota.Scope, QuotaSize> listMaxStorageDetails(QuotaRoot 
quotaRoot) {
+        return Stream.of(
+                Pair.of(Quota.Scope.User, 
perUserQuota.getMaxStorage(quotaRoot)),
+                Pair.of(Quota.Scope.Global, 
defaultQuota.getDefaultMaxStorage()))
+            .filter(pair -> pair.getValue().isPresent())
+            .collect(Guavate.toImmutableMap(Pair::getKey, value -> 
value.getValue().get()));
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
----------------------------------------------------------------------
diff --git 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
index a2ebbb7..ef509cb 100644
--- 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
+++ 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JPAPerUserMaxQuotaManager.java
@@ -19,15 +19,21 @@
 
 package org.apache.james.mailbox.jpa.quota;
 
+import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Stream;
 
 import javax.inject.Inject;
 
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaSize;
 
+import com.github.steveash.guavate.Guavate;
+
 public class JPAPerUserMaxQuotaManager implements MaxQuotaManager {
 
     private final JPAPerUserMaxQuotaDAO dao;
@@ -92,6 +98,24 @@ public class JPAPerUserMaxQuotaManager implements 
MaxQuotaManager {
     }
 
     @Override
+    public Map<Quota.Scope, QuotaCount> listMaxMessagesDetails(QuotaRoot 
quotaRoot) {
+        return Stream.of(
+            Pair.of(Quota.Scope.User, dao.getMaxMessage(quotaRoot)),
+            Pair.of(Quota.Scope.Global, dao.getDefaultMaxMessage()))
+        .filter(pair -> pair.getValue().isPresent())
+        .collect(Guavate.toImmutableMap(Pair::getKey, value -> 
value.getValue().get()));
+    }
+
+    @Override
+    public Map<Quota.Scope, QuotaSize> listMaxStorageDetails(QuotaRoot 
quotaRoot) {
+        return Stream.of(
+            Pair.of(Quota.Scope.User, dao.getMaxStorage(quotaRoot)),
+            Pair.of(Quota.Scope.Global, dao.getDefaultMaxStorage()))
+        .filter(pair -> pair.getValue().isPresent())
+        .collect(Guavate.toImmutableMap(Pair::getKey, value -> 
value.getValue().get()));
+    }
+
+    @Override
     public void removeMaxStorage(QuotaRoot quotaRoot) {
         dao.setMaxStorage(quotaRoot, Optional.empty());
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
----------------------------------------------------------------------
diff --git 
a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
 
b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
index 15cfe8a..aff15b9 100644
--- 
a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
+++ 
b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/quota/InMemoryPerUserMaxQuotaManager.java
@@ -21,13 +21,18 @@ package org.apache.james.mailbox.inmemory.quota;
 import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Stream;
 
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaSize;
 
+import com.github.steveash.guavate.Guavate;
+
 public class InMemoryPerUserMaxQuotaManager implements MaxQuotaManager {
 
     private Optional<QuotaCount> maxMessage = Optional.empty();
@@ -65,6 +70,24 @@ public class InMemoryPerUserMaxQuotaManager implements 
MaxQuotaManager {
     }
 
     @Override
+    public Map<Quota.Scope, QuotaCount> listMaxMessagesDetails(QuotaRoot 
quotaRoot) {
+        return Stream.of(
+                Pair.of(Quota.Scope.User, 
Optional.ofNullable(userMaxMessage.get(quotaRoot.getValue()))),
+                Pair.of(Quota.Scope.Global, maxMessage))
+            .filter(pair -> pair.getValue().isPresent())
+            .collect(Guavate.toImmutableMap(Pair::getKey, value -> 
value.getValue().get()));
+    }
+
+    @Override
+    public Map<Quota.Scope, QuotaSize> listMaxStorageDetails(QuotaRoot 
quotaRoot) {
+        return Stream.of(
+            Pair.of(Quota.Scope.User, 
Optional.ofNullable(userMaxStorage.get(quotaRoot.getValue()))),
+            Pair.of(Quota.Scope.Global, maxStorage))
+            .filter(pair -> pair.getValue().isPresent())
+            .collect(Guavate.toImmutableMap(Pair::getKey, value -> 
value.getValue().get()));
+    }
+
+    @Override
     public void setMaxStorage(QuotaRoot user, QuotaSize maxStorageQuota) {
         userMaxStorage.put(user.getValue(), maxStorageQuota);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
----------------------------------------------------------------------
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
index 9fb0f47..e4ada35 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/FixedMaxQuotaManager.java
@@ -1,14 +1,18 @@
 package org.apache.james.mailbox.store.quota;
 
+import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.UnsupportedOperationException;
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaSize;
 
+import com.google.common.collect.ImmutableMap;
+
 /**
  * {@link MaxQuotaManager} which use the same quota for all users.
  *
@@ -70,6 +74,20 @@ public class FixedMaxQuotaManager implements MaxQuotaManager 
{
     }
 
     @Override
+    public Map<Quota.Scope, QuotaCount> listMaxMessagesDetails(QuotaRoot 
quotaRoot) {
+        return maxMessage
+            .map(value -> ImmutableMap.of(Quota.Scope.Global, value))
+            .orElse(ImmutableMap.of());
+    }
+
+    @Override
+    public Map<Quota.Scope, QuotaSize> listMaxStorageDetails(QuotaRoot 
quotaRoot) {
+        return maxStorage
+            .map(value -> ImmutableMap.of(Quota.Scope.Global, value))
+            .orElse(ImmutableMap.of());
+    }
+
+    @Override
     public Optional<QuotaSize> getDefaultMaxStorage() {
         return maxStorage;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
----------------------------------------------------------------------
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
index 239439b..9e06bc3 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoMaxQuotaManager.java
@@ -19,14 +19,18 @@
 
 package org.apache.james.mailbox.store.quota;
 
+import java.util.Map;
 import java.util.Optional;
 
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaCount;
 import org.apache.james.mailbox.quota.QuotaSize;
 
+import com.google.common.collect.ImmutableMap;
+
 /**
  * A Max Quota Manager that simply throws exceptions
  *
@@ -85,6 +89,16 @@ public class NoMaxQuotaManager implements MaxQuotaManager {
     }
 
     @Override
+    public Map<Quota.Scope, QuotaCount> listMaxMessagesDetails(QuotaRoot 
quotaRoot) {
+        return ImmutableMap.of();
+    }
+
+    @Override
+    public Map<Quota.Scope, QuotaSize> listMaxStorageDetails(QuotaRoot 
quotaRoot) {
+        return ImmutableMap.of();
+    }
+
+    @Override
     public Optional<QuotaSize> getDefaultMaxStorage() {
         return Optional.empty();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
----------------------------------------------------------------------
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
index a5100c6..0799433 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/StoreQuotaManager.java
@@ -49,6 +49,7 @@ public class StoreQuotaManager implements QuotaManager {
         return Quota.<QuotaCount>builder()
             .used(currentQuotaManager.getCurrentMessageCount(quotaRoot))
             
.computedLimit(maxQuotaManager.getMaxMessage(quotaRoot).orElse(QuotaCount.unlimited()))
+            .limitsByScope(maxQuotaManager.listMaxMessagesDetails(quotaRoot))
             .build();
     }
 
@@ -57,6 +58,7 @@ public class StoreQuotaManager implements QuotaManager {
         return Quota.<QuotaSize>builder()
             .used(currentQuotaManager.getCurrentStorage(quotaRoot))
             
.computedLimit(maxQuotaManager.getMaxStorage(quotaRoot).orElse(QuotaSize.unlimited()))
+            .limitsByScope(maxQuotaManager.listMaxStorageDetails(quotaRoot))
             .build();
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/c45b0f3d/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
----------------------------------------------------------------------
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
index 99fe1b6..cef25e2 100644
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
+++ 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/GenericMaxQuotaManagerTest.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.store.quota;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaCount;
@@ -102,4 +103,70 @@ public abstract class GenericMaxQuotaManagerTest {
         maxQuotaManager.removeDefaultMaxMessage();
         assertThat(maxQuotaManager.getDefaultMaxMessage()).isEmpty();
     }
+
+    @Test
+    public void listMaxMessagesDetailsShouldReturnEmptyWhenNoQuotaDefined() {
+        
assertThat(maxQuotaManager.listMaxMessagesDetails(quotaRoot)).isEmpty();
+    }
+
+    @Test
+    public void listMaxStorageDetailsShouldReturnEmptyWhenNoQuotaDefined() {
+        assertThat(maxQuotaManager.listMaxStorageDetails(quotaRoot)).isEmpty();
+    }
+
+    @Test
+    public void listMaxMessagesDetailsShouldReturnGlobalValueWhenDefined() 
throws Exception {
+        maxQuotaManager.setDefaultMaxMessage(QuotaCount.count(123));
+        assertThat(maxQuotaManager.listMaxMessagesDetails(quotaRoot))
+            .hasSize(1)
+            .containsEntry(Quota.Scope.Global, QuotaCount.count(123));
+    }
+
+
+    @Test
+    public void listMaxMessagesDetailsShouldReturnUserValueWhenDefined() 
throws Exception {
+        maxQuotaManager.setMaxMessage(quotaRoot, QuotaCount.count(123));
+        assertThat(maxQuotaManager.listMaxMessagesDetails(quotaRoot))
+            .hasSize(1)
+            .containsEntry(Quota.Scope.User, QuotaCount.count(123));
+    }
+
+    @Test
+    public void listMaxMessagesDetailsShouldReturnBothValuesWhenDefined() 
throws Exception {
+        maxQuotaManager.setDefaultMaxMessage(QuotaCount.count(1234));
+        maxQuotaManager.setMaxMessage(quotaRoot, QuotaCount.count(123));
+        assertThat(maxQuotaManager.listMaxMessagesDetails(quotaRoot))
+            .hasSize(2)
+            .containsEntry(Quota.Scope.Global, QuotaCount.count(1234))
+            .containsEntry(Quota.Scope.User, QuotaCount.count(123));
+    }
+
+
+    @Test
+    public void listMaxStorageDetailsShouldReturnGlobalValueWhenDefined() 
throws Exception {
+        maxQuotaManager.setDefaultMaxStorage(QuotaSize.size(1111));
+        assertThat(maxQuotaManager.listMaxStorageDetails(quotaRoot))
+            .hasSize(1)
+            .containsEntry(Quota.Scope.Global, QuotaSize.size(1111));
+    }
+
+
+    @Test
+    public void listMaxStorageDetailsShouldReturnUserValueWhenDefined() throws 
Exception {
+        maxQuotaManager.setMaxStorage(quotaRoot, QuotaSize.size(2222));
+        assertThat(maxQuotaManager.listMaxStorageDetails(quotaRoot))
+            .hasSize(1)
+            .containsEntry(Quota.Scope.User, QuotaSize.size(2222));
+    }
+
+    @Test
+    public void listMaxStorageDetailsShouldReturnBothValuesWhenDefined() 
throws Exception {
+        maxQuotaManager.setDefaultMaxStorage(QuotaSize.size(3333));
+        maxQuotaManager.setMaxStorage(quotaRoot, QuotaSize.size(4444));
+        assertThat(maxQuotaManager.listMaxStorageDetails(quotaRoot))
+            .hasSize(2)
+            .containsEntry(Quota.Scope.Global, QuotaSize.size(3333))
+            .containsEntry(Quota.Scope.User, QuotaSize.size(4444));
+    }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to