Add unit tests for ClusterMetadataEvent
- add toString, equals, and hashCode to ClusterMetadataEvent
Change-Id: Idb1031c01cc6333be76851bb1b2ee196a8732d76
diff --git a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEvent.java b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEvent.java
index 665030e..75b488c 100644
--- a/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEvent.java
+++ b/core/api/src/main/java/org/onosproject/cluster/ClusterMetadataEvent.java
@@ -15,8 +15,11 @@
*/
package org.onosproject.cluster;
+import com.google.common.base.MoreObjects;
import org.onosproject.event.AbstractEvent;
+import java.util.Objects;
+
/**
* Describes a cluster metadata event.
*/
@@ -53,4 +56,32 @@
public ClusterMetadataEvent(Type type, ClusterMetadata metadata, long time) {
super(type, metadata, time);
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type(), subject(), time());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ClusterMetadataEvent) {
+ final ClusterMetadataEvent other = (ClusterMetadataEvent) obj;
+ return Objects.equals(this.type(), other.type()) &&
+ Objects.equals(this.subject(), other.subject()) &&
+ Objects.equals(this.time(), other.time());
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this.getClass())
+ .add("type", type())
+ .add("subject", subject())
+ .add("time", time())
+ .toString();
+ }
}