[prev in list] [next in list] [prev in thread] [next in thread] 

List:       james-dev
Subject:    [5/5] james-project git commit: JAMES-2344 merge QuotaImpl and Quota, it's part of the API
From:       rouazana () apache ! org
Date:       2018-02-27 13:27:45
Message-ID: 01cefa44cca04fcba190185624636367 () git ! apache ! org
[Download RAW message or body]

JAMES-2344 merge QuotaImpl and Quota, it's part of the API


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

Branch: refs/heads/master
Commit: fc5c1eaaf365ae0aaea560224dbdeb3d6b4e0f7c
Parents: c80590c
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Mon Feb 26 17:44:29 2018 +0100
Committer: Matthieu Baechler <matthieu@apache.org>
Committed: Tue Feb 27 09:59:59 2018 +0100

----------------------------------------------------------------------
 .../org/apache/james/mailbox/model/Quota.java   | 91 ++++++++++++-------
 .../apache/james/mailbox/model/QuotaTest.java   | 81 +++++++++++++++++
 .../mailbox/store/quota/NoQuotaManager.java     |  4 +-
 .../james/mailbox/store/quota/QuotaImpl.java    | 92 --------------------
 .../mailbox/store/quota/StoreQuotaManager.java  |  8 +-
 .../AbstractMessageIdManagerSideEffectTest.java | 11 ++-
 .../mailbox/store/quota/QuotaCheckerTest.java   | 21 ++---
 .../mailbox/store/quota/QuotaImplTest.java      | 81 -----------------
 .../store/quota/StoreQuotaManagerTest.java      | 12 +--
 .../imap/encode/QuotaResponseEncoderTest.java   |  6 +-
 .../imap/processor/GetQuotaProcessorTest.java   |  5 +-
 .../processor/GetQuotaRootProcessorTest.java    |  5 +-
 12 files changed, 177 insertions(+), 240 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/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 \
                5e303a3..da0ec14 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,47 +18,78 @@
  ****************************************************************/
 package org.apache.james.mailbox.model;
 
-/**
- * A {@link Quota} restriction
- */
-public interface Quota {
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
 
-    /**
-     * Unlimited value
-     */
-    long UNLIMITED = -1;
+public class Quota {
 
-    /**
-     * Value not known
-     */
-    long UNKNOWN = Long.MIN_VALUE;
+    public static final long UNLIMITED = -1;
 
-    /**
-     * Return the maximum value for the {@link Quota}
-     *
-     * @return max
-     */
-    long getMax();
+    public static final long UNKNOWN = Long.MIN_VALUE;
 
-    /**
-     * Return the currently used for the {@link Quota}
-     *
-     * @return used
-     */
-    long getUsed();
+    private static final Quota UNLIMITED_QUOTA = new Quota(UNKNOWN, UNLIMITED);
 
-    /**
-     *  Adds the value to the quota.
-     */
-    void addValueToQuota(long value);
+    public static Quota unlimited() {
+        return UNLIMITED_QUOTA;
+    }
+
+    public static Quota quota(long used, long max) {
+        return new Quota(used, max);
+    }
+
+    private final long max;
+    private long used;
+
+    private Quota(long used, long max) {
+        this.used = used;
+        this.max = max;
+    }
+
+    public long getMax() {
+        return max;
+    }
+
+    public long getUsed() {
+        return used;
+    }
+
+    public void addValueToQuota(long value) {
+        used += value;
+    }
 
     /**
      * Tells us if the quota is reached
      *
      * @return True if the user over uses the resource of this quota
      */
-    boolean isOverQuota();
+    public boolean isOverQuota() {
+        return isOverQuotaWithAdditionalValue(0);
+    }
+
+    public boolean isOverQuotaWithAdditionalValue(long additionalValue) {
+        Preconditions.checkArgument(additionalValue >= 0);
+        return max != UNLIMITED
+            && used + additionalValue > max;
+    }
+
+    @Override
+    public String toString() {
+        return used + "/" + max;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o == null || ! (o instanceof  Quota)) {
+            return false;
+        }
+        Quota other = (Quota) o;
+        return used == other.getUsed()
+            && max == other.getMax();
+    }
 
-    boolean isOverQuotaWithAdditionalValue(long additionalValue);
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(used, max);
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java
                
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java \
b/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java new file \
mode 100644 index 0000000..143886d
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/QuotaTest.java
@@ -0,0 +1,81 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mailbox.model;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.mailbox.model.Quota;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class QuotaTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void unlimitedQuotaShouldNotBeOverQuota() {
+        assertThat(Quota.unlimited().isOverQuota()).isFalse();
+    }
+
+    @Test
+    public void isOverQuotaShouldReturnFalseWhenQuotaIsNotExceeded() {
+        assertThat(Quota.quota(36, 360).isOverQuota()).isFalse();
+    }
+
+    @Test
+    public void isOverQuotaShouldReturnFalseWhenMaxValueIsUnlimited() {
+        assertThat(Quota.quota(36, Quota.UNLIMITED).isOverQuota()).isFalse();
+    }
+
+    @Test
+    public void isOverQuotaShouldReturnFalseWhenUsedValueIsUnknown() {
+        assertThat(Quota.quota(Quota.UNKNOWN, 36).isOverQuota()).isFalse();
+    }
+
+    @Test
+    public void isOverQuotaShouldReturnTrueWhenQuotaIsExceeded() {
+        assertThat(Quota.quota(360, 36).isOverQuota()).isTrue();
+    }
+
+    @Test
+    public void isOverQuotaWithAdditionalValueShouldReturnTrueWhenOverLimit() {
+        assertThat(Quota.quota(36, 36).isOverQuotaWithAdditionalValue(1)).isTrue();
+    }
+
+    @Test
+    public void isOverQuotaWithAdditionalValueShouldReturnTrueWhenUnderLimit() {
+        assertThat(Quota.quota(34, 36).isOverQuotaWithAdditionalValue(1)).isFalse();
+    }
+
+    @Test
+    public void isOverQuotaWithAdditionalValueShouldReturnFalseWhenAtLimit() {
+        assertThat(Quota.quota(36, 36).isOverQuotaWithAdditionalValue(0)).isFalse();
+    }
+
+    @Test
+    public void isOverQuotaWithAdditionalValueShouldThrowOnNegativeValue() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        Quota.quota(25, 36).isOverQuotaWithAdditionalValue(-1);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
                
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java \
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
 index 64b58b2..bebc32c 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
                
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/NoQuotaManager.java
 @@ -31,11 +31,11 @@ public class NoQuotaManager implements QuotaManager {
 
     @Override
     public Quota getMessageQuota(QuotaRoot quotaRoot) throws MailboxException {
-        return QuotaImpl.unlimited();
+        return Quota.unlimited();
     }
 
     @Override
     public Quota getStorageQuota(QuotaRoot quotaRoot) throws MailboxException {
-        return QuotaImpl.unlimited();
+        return Quota.unlimited();
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaImpl.java
                
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaImpl.java \
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaImpl.java \
deleted file mode 100644 index 294de6e..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/QuotaImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.store.quota;
-
-import org.apache.james.mailbox.model.Quota;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
-
-public final class QuotaImpl implements Quota {
-
-    private static final Quota UNLIMITED_QUOTA = new QuotaImpl(UNKNOWN, UNLIMITED);
-
-    public static Quota unlimited() {
-        return UNLIMITED_QUOTA;
-    }
-
-    public static Quota quota(long used, long max) {
-        return new QuotaImpl(used, max);
-    }
-
-    private final long max;
-    private long used;
-
-    private QuotaImpl(long used, long max) {
-        this.used = used;
-        this.max = max;
-    }
-
-    @Override
-    public long getMax() {
-        return max;
-    }
-
-    @Override
-    public long getUsed() {
-        return used;
-    }
-
-    @Override
-    public void addValueToQuota(long value) {
-        used += value;
-    }
-
-    @Override
-    public boolean isOverQuota() {
-        return isOverQuotaWithAdditionalValue(0);
-    }
-
-    @Override
-    public String toString() {
-        return used + "/" + max;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (o == null || ! (o instanceof  Quota)) {
-            return false;
-        }
-        Quota other = (Quota) o;
-        return used == other.getUsed()
-            && max == other.getMax();
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hashCode(used, max);
-    }
-
-    @Override
-    public boolean isOverQuotaWithAdditionalValue(long additionalValue) {
-        Preconditions.checkArgument(additionalValue >= 0);
-        return max != UNLIMITED
-            && used + additionalValue > max;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/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 5c5cef4..59dc23e 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
 @@ -51,18 +51,18 @@ public class StoreQuotaManager implements QuotaManager {
     public Quota getMessageQuota(QuotaRoot quotaRoot) throws MailboxException {
         long maxValue = maxQuotaManager.getMaxMessage(quotaRoot);
         if (maxValue == Quota.UNLIMITED && !calculateWhenUnlimited) {
-            return QuotaImpl.quota(Quota.UNKNOWN, Quota.UNLIMITED);
+            return Quota.quota(Quota.UNKNOWN, Quota.UNLIMITED);
         }
-        return QuotaImpl.quota(currentQuotaManager.getCurrentMessageCount(quotaRoot), \
maxValue); +        return \
Quota.quota(currentQuotaManager.getCurrentMessageCount(quotaRoot), maxValue);  }
 
 
     public Quota getStorageQuota(QuotaRoot quotaRoot) throws MailboxException {
         long maxValue = maxQuotaManager.getMaxStorage(quotaRoot);
         if (maxValue == Quota.UNLIMITED && !calculateWhenUnlimited) {
-            return QuotaImpl.quota(Quota.UNKNOWN, Quota.UNLIMITED);
+            return Quota.quota(Quota.UNKNOWN, Quota.UNLIMITED);
         }
-        return QuotaImpl.quota(currentQuotaManager.getCurrentStorage(quotaRoot), \
maxValue); +        return \
Quota.quota(currentQuotaManager.getCurrentStorage(quotaRoot), maxValue);  }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/mailbox/store/src/t \
                est/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
                
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java \
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
 index c414601..629256f 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
                
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
 @@ -54,7 +54,6 @@ import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.apache.james.mailbox.store.quota.QuotaImpl;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -62,7 +61,7 @@ import org.junit.rules.ExpectedException;
 import com.google.common.collect.ImmutableList;
 
 public abstract class AbstractMessageIdManagerSideEffectTest {
-    private static final Quota OVER_QUOTA = QuotaImpl.quota(102, 100);
+    private static final Quota OVER_QUOTA = Quota.quota(102, 100);
     private static final MessageUid messageUid1 = MessageUid.of(111);
 
     public static final Flags FLAGS = new Flags();
@@ -163,9 +162,9 @@ public abstract class AbstractMessageIdManagerSideEffectTest {
     public void setInMailboxesShouldThrowExceptionWhenOverQuota() throws Exception {
         MessageId messageId = testingData.persist(mailbox1.getMailboxId(), \
messageUid1, FLAGS, session);  reset(dispatcher);
-        when(quotaManager.getStorageQuota(any(QuotaRoot.class))).thenReturn(QuotaImpl.unlimited());
 +        when(quotaManager.getStorageQuota(any(QuotaRoot.class))).thenReturn(Quota.unlimited());
                
         when(quotaManager.getMessageQuota(any(QuotaRoot.class))).thenReturn(OVER_QUOTA);
                
-        when(quotaManager.getStorageQuota(any(QuotaRoot.class))).thenReturn(QuotaImpl.unlimited());
 +        when(quotaManager.getStorageQuota(any(QuotaRoot.class))).thenReturn(Quota.unlimited());
  
         expectedException.expect(OverQuotaException.class);
 
@@ -307,8 +306,8 @@ public abstract class AbstractMessageIdManagerSideEffectTest {
     }
 
     private void givenUnlimitedQuota() throws MailboxException {
-        when(quotaManager.getMessageQuota(any(QuotaRoot.class))).thenReturn(QuotaImpl.unlimited());
                
-        when(quotaManager.getStorageQuota(any(QuotaRoot.class))).thenReturn(QuotaImpl.unlimited());
 +        when(quotaManager.getMessageQuota(any(QuotaRoot.class))).thenReturn(Quota.unlimited());
 +        when(quotaManager.getStorageQuota(any(QuotaRoot.class))).thenReturn(Quota.unlimited());
  }
 
     private SimpleMessageMetaData fromMessageResult(MessageId messageId, \
MessageResult messageResult) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
                
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java \
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
 index 7566e88..f7ff670 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
                
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaCheckerTest.java
 @@ -27,6 +27,7 @@ import static org.mockito.Mockito.when;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.OverQuotaException;
 import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
@@ -52,8 +53,8 @@ public class QuotaCheckerTest {
     @Test
     public void quotaCheckerShouldNotThrowOnRegularQuotas() throws MailboxException \
                {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
                
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, \
                100));
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, \
1000)); +        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(10, \
100)); +        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(100, \
                1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, \
mockedQuotaRootResolver, MAILBOX);  assertThat(quotaChecker.tryAddition(0, \
0)).isTrue();  }
@@ -61,8 +62,8 @@ public class QuotaCheckerTest {
     @Test
     public void quotaCheckerShouldNotThrowOnRegularModifiedQuotas() throws \
                MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
                
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, \
                100));
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, \
1000)); +        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(10, \
100)); +        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(100, \
                1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, \
mockedQuotaRootResolver, MAILBOX);  assertThat(quotaChecker.tryAddition(89, \
899)).isTrue();  }
@@ -70,8 +71,8 @@ public class QuotaCheckerTest {
     @Test
     public void quotaCheckerShouldNotThrowOnReachedMaximumQuotas() throws \
                MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
                
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, \
                100));
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, \
1000)); +        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(10, \
100)); +        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(100, \
                1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, \
mockedQuotaRootResolver, MAILBOX);  assertThat(quotaChecker.tryAddition(90, \
900)).isTrue();  }
@@ -79,8 +80,8 @@ public class QuotaCheckerTest {
     @Test
     public void quotaCheckerShouldThrowOnExceededMessages() throws MailboxException \
                {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
                
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, \
                100));
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, \
1000)); +        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(10, \
100)); +        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(100, \
                1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, \
mockedQuotaRootResolver, MAILBOX);  
         assertThatThrownBy(() -> quotaChecker.tryAddition(91, 899))
@@ -90,8 +91,8 @@ public class QuotaCheckerTest {
     @Test
     public void quotaCheckerShouldThrowOnExceededStorage() throws MailboxException {
         when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
                
-        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(10, \
                100));
-        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(QuotaImpl.quota(100, \
1000)); +        when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(10, \
100)); +        when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(Quota.quota(100, \
                1000));
         QuotaChecker quotaChecker = new QuotaChecker(mockedQuotaManager, \
mockedQuotaRootResolver, MAILBOX);  
         assertThatThrownBy(() -> quotaChecker.tryAddition(89, 901))

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaImplTest.java
                
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaImplTest.java \
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaImplTest.java \
deleted file mode 100644 index 3faca34..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/QuotaImplTest.java
                
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox.store.quota;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.james.mailbox.model.Quota;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-public class QuotaImplTest {
-
-    @Rule
-    public ExpectedException expectedException = ExpectedException.none();
-
-    @Test
-    public void unlimitedQuotaShouldNotBeOverQuota() {
-        assertThat(QuotaImpl.unlimited().isOverQuota()).isFalse();
-    }
-
-    @Test
-    public void isOverQuotaShouldReturnFalseWhenQuotaIsNotExceeded() {
-        assertThat(QuotaImpl.quota(36, 360).isOverQuota()).isFalse();
-    }
-
-    @Test
-    public void isOverQuotaShouldReturnFalseWhenMaxValueIsUnlimited() {
-        assertThat(QuotaImpl.quota(36, Quota.UNLIMITED).isOverQuota()).isFalse();
-    }
-
-    @Test
-    public void isOverQuotaShouldReturnFalseWhenUsedValueIsUnknown() {
-        assertThat(QuotaImpl.quota(Quota.UNKNOWN, 36).isOverQuota()).isFalse();
-    }
-
-    @Test
-    public void isOverQuotaShouldReturnTrueWhenQuotaIsExceeded() {
-        assertThat(QuotaImpl.quota(360, 36).isOverQuota()).isTrue();
-    }
-
-    @Test
-    public void isOverQuotaWithAdditionalValueShouldReturnTrueWhenOverLimit() {
-        assertThat(QuotaImpl.quota(36, \
                36).isOverQuotaWithAdditionalValue(1)).isTrue();
-    }
-
-    @Test
-    public void isOverQuotaWithAdditionalValueShouldReturnTrueWhenUnderLimit() {
-        assertThat(QuotaImpl.quota(34, \
                36).isOverQuotaWithAdditionalValue(1)).isFalse();
-    }
-
-    @Test
-    public void isOverQuotaWithAdditionalValueShouldReturnFalseWhenAtLimit() {
-        assertThat(QuotaImpl.quota(36, \
                36).isOverQuotaWithAdditionalValue(0)).isFalse();
-    }
-
-    @Test
-    public void isOverQuotaWithAdditionalValueShouldThrowOnNegativeValue() {
-        expectedException.expect(IllegalArgumentException.class);
-
-        QuotaImpl.quota(25, 36).isOverQuotaWithAdditionalValue(-1);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
                
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java \
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
 index 4b576f6..064be67 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
                
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/StoreQuotaManagerTest.java
 @@ -51,14 +51,14 @@ public class StoreQuotaManagerTest {
     public void getMessageQuotaShouldWorkWithNumericValues() throws Exception {
         when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).thenReturn(360L);
         when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).thenReturn(36L);
                
-        assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, \
360)); +        assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(Quota.quota(36, \
360));  }
 
     @Test
     public void getStorageQuotaShouldWorkWithNumericValues() throws Exception {
         when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).thenReturn(360L);
         when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).thenReturn(36L);
                
-        assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, \
360)); +        assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(Quota.quota(36, \
360));  }
 
     @Test
@@ -66,7 +66,7 @@ public class StoreQuotaManagerTest {
         testee.setCalculateWhenUnlimited(false);
         when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).thenReturn(Quota.UNLIMITED);
  
-        assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(Quota.UNKNOWN, \
Quota.UNLIMITED)); +        \
assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(Quota.quota(Quota.UNKNOWN, \
                Quota.UNLIMITED));
         verify(mockedCurrentQuotaManager, never()).getCurrentStorage(quotaRoot);
     }
 
@@ -75,7 +75,7 @@ public class StoreQuotaManagerTest {
         testee.setCalculateWhenUnlimited(false);
         when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).thenReturn(Quota.UNLIMITED);
  
-        assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(Quota.UNKNOWN, \
Quota.UNLIMITED)); +        \
assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(Quota.quota(Quota.UNKNOWN, \
                Quota.UNLIMITED));
         verify(mockedCurrentQuotaManager, \
never()).getCurrentMessageCount(quotaRoot);  }
 
@@ -85,7 +85,7 @@ public class StoreQuotaManagerTest {
         when(mockedMaxQuotaManager.getMaxStorage(quotaRoot)).thenReturn(Quota.UNLIMITED);
                
         when(mockedCurrentQuotaManager.getCurrentStorage(quotaRoot)).thenReturn(36L);
  
-        assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, \
Quota.UNLIMITED)); +        \
assertThat(testee.getStorageQuota(quotaRoot)).isEqualTo(Quota.quota(36, \
Quota.UNLIMITED));  }
 
     @Test
@@ -94,7 +94,7 @@ public class StoreQuotaManagerTest {
         when(mockedMaxQuotaManager.getMaxMessage(quotaRoot)).thenReturn(Quota.UNLIMITED);
                
         when(mockedCurrentQuotaManager.getCurrentMessageCount(quotaRoot)).thenReturn(36L);
  
-        assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(QuotaImpl.quota(36, \
Quota.UNLIMITED)); +        \
assertThat(testee.getMessageQuota(quotaRoot)).isEqualTo(Quota.quota(36, \
Quota.UNLIMITED));  }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
                
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java \
b/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
 index 8bd49e9..4bfdf5e 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
                
+++ b/protocols/imap/src/test/java/org/apache/james/imap/encode/QuotaResponseEncoderTest.java
 @@ -25,7 +25,7 @@ import org.apache.james.imap.encode.base.ByteImapResponseWriter;
 import org.apache.james.imap.encode.base.EndImapEncoder;
 import org.apache.james.imap.encode.base.ImapResponseComposerImpl;
 import org.apache.james.imap.message.response.QuotaResponse;
-import org.apache.james.mailbox.store.quota.QuotaImpl;
+import org.apache.james.mailbox.model.Quota;
 import org.junit.Test;
 
 /**
@@ -35,7 +35,7 @@ public class QuotaResponseEncoderTest {
 
     @Test
     public void quotaMessageResponseShouldBeWellFormatted() throws Exception {
-        QuotaResponse response = new QuotaResponse("MESSAGE", "root", \
QuotaImpl.quota(231, 1024)); +        QuotaResponse response = new \
                QuotaResponse("MESSAGE", "root", Quota.quota(231, 1024));
         ByteImapResponseWriter byteImapResponseWriter = new \
                ByteImapResponseWriter();
         ImapResponseComposer composer = new \
                ImapResponseComposerImpl(byteImapResponseWriter, 1024);
         QuotaResponseEncoder encoder = new QuotaResponseEncoder(new \
EndImapEncoder()); @@ -46,7 +46,7 @@ public class QuotaResponseEncoderTest {
 
     @Test
     public void quotaStorageResponseShouldBeWellFormatted() throws Exception {
-        QuotaResponse response = new QuotaResponse("STORAGE", "root", \
QuotaImpl.quota(231 * 1024, 1024 * 1024)); +        QuotaResponse response = new \
                QuotaResponse("STORAGE", "root", Quota.quota(231 * 1024, 1024 * \
                1024));
         ByteImapResponseWriter byteImapResponseWriter = new \
                ByteImapResponseWriter();
         ImapResponseComposer composer = new \
                ImapResponseComposerImpl(byteImapResponseWriter, 1024);
         QuotaResponseEncoder encoder = new QuotaResponseEncoder(new \
EndImapEncoder());

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
                
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java \
b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
 index e78f679..7984cf4 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
                
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java
 @@ -45,7 +45,6 @@ import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.quota.QuotaImpl;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.junit.Before;
 import org.junit.Test;
@@ -57,8 +56,8 @@ public class GetQuotaProcessorTest {
 
     private static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("plop");
     public static final MailboxPath MAILBOX_PATH = new MailboxPath("namespace", \
                "plop", "INBOX");
-    public static final Quota MESSAGE_QUOTA = QuotaImpl.quota(24, 1589);
-    public static final Quota STORAGE_QUOTA = QuotaImpl.quota(240, 15890);
+    public static final Quota MESSAGE_QUOTA = Quota.quota(24, 1589);
+    public static final Quota STORAGE_QUOTA = Quota.quota(240, 15890);
 
     private GetQuotaProcessor testee;
     private ImapSession mockedImapSession;

http://git-wip-us.apache.org/repos/asf/james-project/blob/fc5c1eaa/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
                
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java \
b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
 index c435874..93b378f 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
                
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java
 @@ -39,7 +39,6 @@ import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.QuotaManager;
 import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.quota.QuotaImpl;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -51,8 +50,8 @@ public class GetQuotaRootProcessorTest {
 
     private static final QuotaRoot QUOTA_ROOT = QuotaRoot.quotaRoot("plop");
     public static final MailboxPath MAILBOX_PATH = MailboxPath.forUser("plop", \
                "INBOX");
-    public static final Quota MESSAGE_QUOTA = QuotaImpl.quota(24, 1589);
-    public static final Quota STORAGE_QUOTA = QuotaImpl.quota(240, 15890);
+    public static final Quota MESSAGE_QUOTA = Quota.quota(24, 1589);
+    public static final Quota STORAGE_QUOTA = Quota.quota(240, 15890);
 
     private GetQuotaRootProcessor testee;
     private Mockery mockery;


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic