summaryrefslogtreecommitdiffstats
path: root/context/context-management/src/main/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-10-03 15:22:53 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-10-03 15:23:07 +0100
commit16a8f59fed2e53b1bbedaf65a33165bb4d3225f8 (patch)
tree1b6088a4e93ba0ab7fee719c43e57add32afb358 /context/context-management/src/main/java
parentb4a5e9eaeed3b76db48e01875013d694014814bb (diff)
Add unit test for core events and context
This code is covered by feature testing but does not show up in Sonar. These unit tests give coverage on engine modules. Issue-ID: POLICY-1034 Change-Id: Ib7a288bcb9729ec88346cc8047e38f3a58f9a97c Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'context/context-management/src/main/java')
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java43
1 files changed, 42 insertions, 1 deletions
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java
index 6382992d9..221c1987a 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/impl/ContextAlbumImpl.java
@@ -47,7 +47,7 @@ import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public final class ContextAlbumImpl implements ContextAlbum {
+public final class ContextAlbumImpl implements ContextAlbum, Comparable<ContextAlbumImpl> {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ContextAlbumImpl.class);
@@ -502,4 +502,45 @@ public final class ContextAlbumImpl implements ContextAlbum {
// Clear the map
albumMap.clear();
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(ContextAlbumImpl otherContextAlbumImpl) {
+ return (equals(otherContextAlbumImpl) ? 0 : 1);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + albumDefinition.hashCode();
+ result = prime * result + albumMap.hashCode();
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof ContextAlbumImpl)) {
+ return false;
+ }
+ ContextAlbumImpl other = (ContextAlbumImpl) obj;
+ if (!albumDefinition.equals(other.albumDefinition)) {
+ return false;
+ }
+ return albumMap.equals(other.albumMap);
+ }
}