You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by rc...@apache.org on 2019/11/25 09:07:02 UTC

[james-project] 19/22: [Refactoring] Add tests for ModSeq, fix equals verifier checks

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 20eee480af272a003500248c74a58e187ad0557c
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Wed Nov 20 17:33:23 2019 +0100

    [Refactoring] Add tests for ModSeq, fix equals verifier checks
---
 .../main/java/org/apache/james/mailbox/ModSeq.java |  4 +-
 .../java/org/apache/james/mailbox/ModSeqTest.java  | 53 ++++++++++++++++++++++
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/ModSeq.java b/mailbox/api/src/main/java/org/apache/james/mailbox/ModSeq.java
index c4be664..22cfb62 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/ModSeq.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/ModSeq.java
@@ -59,12 +59,12 @@ public class ModSeq implements Comparable<ModSeq> {
     }
     
     @Override
-    public int hashCode() {
+    public final int hashCode() {
         return Objects.hashCode(modSeq);
     }
     
     @Override
-    public boolean equals(Object obj) {
+    public final boolean equals(Object obj) {
         if (obj instanceof ModSeq) {
             ModSeq other = (ModSeq) obj;
             return other.modSeq == this.modSeq;
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/ModSeqTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/ModSeqTest.java
new file mode 100644
index 0000000..2198df2
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/ModSeqTest.java
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class ModSeqTest {
+
+    @Test
+    void shouldRespectBeanContract() {
+        EqualsVerifier.forClass(ModSeq.class)
+            .verify();
+    }
+
+    @Test
+    void nextShouldThrowWhenMaxLong() {
+        assertThatThrownBy(() -> ModSeq.of(Long.MAX_VALUE).next())
+            .isInstanceOf(RuntimeException.class);
+    }
+
+    @Test
+    void isFirstShouldReturnTrueWhenFirst() {
+        assertThat(ModSeq.first().isFirst())
+            .isTrue();
+    }
+
+    @Test
+    void isFirstShouldReturnFalseWhenNotFirst() {
+        assertThat(ModSeq.of(42).isFirst())
+            .isFalse();
+    }
+}


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