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 bt...@apache.org on 2018/12/19 11:24:46 UTC

[05/10] james-project git commit: MAILBOX-363 MessageMoveEvent equals + hashCode

MAILBOX-363 MessageMoveEvent equals + hashCode


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

Branch: refs/heads/master
Commit: 8a91427cd33024aa619f2839ce78b985e5c6b9bd
Parents: a809504
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Dec 17 10:44:30 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Dec 19 18:06:37 2018 +0700

----------------------------------------------------------------------
 .../apache/james/mailbox/MessageMoveEvent.java  | 18 +++++++++++
 .../james/mailbox/model/MessageMoves.java       | 25 +++++++++++++++
 .../james/mailbox/MessageMoveEventTest.java     |  7 +++++
 .../james/mailbox/model/MessageMovesTest.java   | 32 ++++++++++++++++++++
 4 files changed, 82 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8a91427c/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java
index 226ae47..5122766 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java
@@ -19,6 +19,7 @@
 package org.apache.james.mailbox;
 
 import java.util.Collection;
+import java.util.Objects;
 
 import org.apache.james.core.User;
 import org.apache.james.mailbox.model.MailboxId;
@@ -114,4 +115,21 @@ public class MessageMoveEvent implements Event {
         return messageMoves.removedMailboxIds()
                 .contains(mailboxId);
     }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof MessageMoveEvent) {
+            MessageMoveEvent that = (MessageMoveEvent) o;
+
+            return Objects.equals(this.user, that.user)
+                && Objects.equals(this.messageMoves, that.messageMoves)
+                && Objects.equals(this.messageIds, that.messageIds);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(user, messageMoves, messageIds);
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/8a91427c/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
index 38e387a..a041a25 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageMoves.java
@@ -20,6 +20,7 @@ package org.apache.james.mailbox.model;
 
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Objects;
 import java.util.Set;
 
 import com.google.common.collect.ImmutableSet;
@@ -84,4 +85,28 @@ public class MessageMoves {
     public Set<MailboxId> removedMailboxIds() {
         return Sets.difference(previousMailboxIds, targetMailboxIds);
     }
+
+    public ImmutableSet<MailboxId> getPreviousMailboxIds() {
+        return previousMailboxIds;
+    }
+
+    public ImmutableSet<MailboxId> getTargetMailboxIds() {
+        return targetMailboxIds;
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof MessageMoves) {
+            MessageMoves that = (MessageMoves) o;
+
+            return Objects.equals(this.previousMailboxIds, that.previousMailboxIds)
+                && Objects.equals(this.targetMailboxIds, that.targetMailboxIds);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(previousMailboxIds, targetMailboxIds);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/8a91427c/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
index 1d217ee..db85d82 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
@@ -31,12 +31,19 @@ import org.assertj.core.api.JUnitSoftAssertions;
 import org.junit.Rule;
 import org.junit.Test;
 
+import nl.jqno.equalsverifier.EqualsVerifier;
+
 public class MessageMoveEventTest {
 
     @Rule
     public JUnitSoftAssertions softly = new JUnitSoftAssertions();
 
     @Test
+    public void shouldRespectBeanContract() {
+        EqualsVerifier.forClass(MessageMoveEvent.class).verify();
+    }
+
+    @Test
     public void builderShouldThrowWhenSessionIsNull() {
         assertThatThrownBy(() -> MessageMoveEvent.builder()
                 .build())

http://git-wip-us.apache.org/repos/asf/james-project/blob/8a91427c/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java
new file mode 100644
index 0000000..3a76147
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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 org.apache.james.mailbox.MessageMoveEvent;
+import org.junit.jupiter.api.Test;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+class MessageMovesTest {
+    @Test
+    void shouldRespectBeanContract() {
+        EqualsVerifier.forClass(MessageMoveEvent.class).verify();
+    }
+}
\ No newline at end of file


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