aboutsummaryrefslogtreecommitdiffstats
path: root/champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampObjectIndexTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampObjectIndexTest.java')
-rw-r--r--champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampObjectIndexTest.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampObjectIndexTest.java b/champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampObjectIndexTest.java
index d007ee4..a58cbc6 100644
--- a/champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampObjectIndexTest.java
+++ b/champ-lib/champ-core/src/test/java/org/onap/aai/champcore/core/ChampObjectIndexTest.java
@@ -20,18 +20,22 @@
*/
package org.onap.aai.champcore.core;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
import org.junit.Test;
import org.onap.aai.champcore.ChampAPI;
import org.onap.aai.champcore.ChampGraph;
import org.onap.aai.champcore.exceptions.ChampIndexNotExistsException;
+import org.onap.aai.champcore.model.ChampField;
+import org.onap.aai.champcore.model.ChampField.Type;
import org.onap.aai.champcore.model.ChampObjectIndex;
+import org.onap.aai.champcore.model.ChampObjectIndex.Builder;
public class ChampObjectIndexTest extends BaseChampAPITest {
@Test
@@ -130,4 +134,32 @@ public class ChampObjectIndexTest extends BaseChampAPITest {
assertTrue(objectIndex.getType().equals("foo"));
assertTrue(objectIndex.getField().getName().equals("name"));
}
+
+ @Test
+ public void verifyEqualsAndHashCodeMethods() {
+ ChampField champField1 = new ChampField.Builder("name").type(Type.STRING).build();
+ ChampField champField2 = new ChampField.Builder("differentName").type(Type.STRING).build();
+
+ ChampObjectIndex obj1 = new Builder("name", "type", champField1).build();
+ ChampObjectIndex obj2 = new Builder("name", "type", champField1).build();
+ ChampObjectIndex obj3 = new Builder("name", "type", champField1).build();
+ ChampObjectIndex obj4 = new Builder("name", "type", champField2).build();
+ ChampObjectIndex obj5 = new Builder("differentName", "type", champField1).build();
+
+ // if
+ assertEquals(obj1, obj2);
+ assertEquals(obj1.hashCode(), obj2.hashCode());
+ //and
+ assertEquals(obj1, obj3);
+ assertEquals(obj1.hashCode(), obj3.hashCode());
+ //then
+ assertEquals(obj2, obj3);
+ assertEquals(obj2.hashCode(), obj3.hashCode());
+
+ assertNotEquals(obj1, obj4);
+ assertNotEquals(obj1.hashCode(), obj4.hashCode());
+
+ assertNotEquals(obj1, obj5);
+ assertNotEquals(obj1.hashCode(), obj5.hashCode());
+ }
}