More Unit tests
Change-Id: I32dd3851e490979621c4a5205c6e041dee900244
diff --git a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java
index 2de8947..b56d74b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/ecmap/EventuallyConsistentMapImpl.java
@@ -653,7 +653,7 @@
public void processItems(List<UpdateEntry<K, V>> items) {
Map<K, UpdateEntry<K, V>> map = Maps.newHashMap();
items.forEach(item -> map.compute(item.key(), (key, existing) ->
- existing == null || item.compareTo(existing) > 0 ? item : existing));
+ item.isNewerThan(existing) ? item : existing));
communicationExecutor.submit(() -> {
clusterCommunicator.unicast(ImmutableList.copyOf(map.values()),
updateMessageSubject,
diff --git a/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java b/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java
index 1a89c6b..bb69b47 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/ecmap/MapValue.java
@@ -83,10 +83,11 @@
return Objects.hashCode(timestamp, value);
}
+ @SuppressWarnings("unchecked")
@Override
public boolean equals(Object other) {
if (other instanceof MapValue) {
- MapValue<V> that = (MapValue) other;
+ MapValue<V> that = (MapValue<V>) other;
return Objects.equal(this.timestamp, that.timestamp) &&
Objects.equal(this.value, that.value);
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/ecmap/UpdateEntry.java b/core/store/dist/src/main/java/org/onosproject/store/ecmap/UpdateEntry.java
index 41eb3a2..fcf6198 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/ecmap/UpdateEntry.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/ecmap/UpdateEntry.java
@@ -22,7 +22,7 @@
/**
* Describes a single update event in an EventuallyConsistentMap.
*/
-final class UpdateEntry<K, V> implements Comparable<UpdateEntry<K, V>> {
+final class UpdateEntry<K, V> {
private final K key;
private final MapValue<V> value;
@@ -55,9 +55,13 @@
return value;
}
- @Override
- public int compareTo(UpdateEntry<K, V> o) {
- return this.value.timestamp().compareTo(o.value.timestamp());
+ /**
+ * Returns if this entry is newer than other entry.
+ * @param other other entry
+ * @return true if this entry is newer; false otherwise
+ */
+ public boolean isNewerThan(UpdateEntry<K, V> other) {
+ return other == null || value.isNewerThan(other.value);
}
@Override