summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-aai/src/test
diff options
context:
space:
mode:
authorshubhada <SV00449682@techmahindra.com>2018-03-19 13:30:42 +0530
committerTakamune Cho <tc012c@att.com>2018-03-19 13:13:09 +0000
commit3f0381ed1ab20dabd819a45bf69f8a07c1f65901 (patch)
tree2fb69390476ea978058f697b2928b78cefe60b19 /appc-dg/appc-dg-shared/appc-dg-aai/src/test
parenta559e6a4550f33397fce0429d71ad0d34f62593d (diff)
Unit test for:org/onap/appc/dg/aai/objects classes
Unit test Coverage for: 1.AAIQueryResult.java 2.Relationship.java Sonar-Link: https://sonar.onap.org/code?id=org.onap.appc%3Aappc&selected=org.onap.appc%3Aappc-dg-aai%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fdg%2Faai%2Fobjects Change-Id: Ia4bb63454b5150e99cc38b12f867450da7ceae54 Issue-ID: APPC-754 Signed-off-by: shubhada <SV00449682@techmahindra.com>
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-aai/src/test')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestAAIQueryResult.java84
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestRelationship.java112
2 files changed, 196 insertions, 0 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestAAIQueryResult.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestAAIQueryResult.java
new file mode 100644
index 000000000..b88a878f8
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestAAIQueryResult.java
@@ -0,0 +1,84 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed 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.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.dg.aai.objects;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestAAIQueryResult {
+ private AAIQueryResult aaiQueryResult;
+ private Map<String,String> additionProperties;
+
+
+ @Before
+ public void setUp() {
+ aaiQueryResult=new AAIQueryResult();
+ additionProperties = new HashMap<>();
+ }
+
+ @Test
+ public void testGetRelationshipList() {
+ Assert.assertTrue(aaiQueryResult. getRelationshipList().isEmpty());
+ }
+
+ @Test
+ public void testGetRelationshipList_With_Data() {
+ Relationship r1=new Relationship();
+ r1.setRelatedLink("relatedLink");
+ r1.setRelatedTo("relatedTo");
+ r1.getRelatedProperties().put("1", "A");
+ r1.getRelationShipDataMap().put("B", "b");
+ aaiQueryResult.getRelationshipList().add(r1);
+ Assert.assertEquals(1,aaiQueryResult.getRelationshipList().size());
+ }
+
+ @Test
+ public void testGetAdditionProperties_IsEmpty() {
+ Assert.assertTrue(aaiQueryResult. getAdditionProperties().isEmpty());
+ }
+
+ @Test
+ public void testGetAdditionProperties_With_Data() {
+ additionProperties.put("1", "A");
+ Assert.assertTrue(additionProperties.containsKey("1"));
+ }
+
+ @Test
+ public void testGetAdditionProperties_WithValidKey() {
+ additionProperties.put("2", "B");
+ Assert.assertEquals("B",additionProperties.get("2"));
+ }
+
+ @Test
+ public void testGetAdditionProperties_WithInValidKey() {
+ Assert.assertEquals(null,additionProperties.get("3"));
+ }
+
+ @Test
+ public void testGetAdditionProperties_Size() {
+ additionProperties.put("3", "C");
+ additionProperties.put("4", "D");
+ Assert.assertEquals(2, additionProperties.size());
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestRelationship.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestRelationship.java
new file mode 100644
index 000000000..f0b832a1f
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestRelationship.java
@@ -0,0 +1,112 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed 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.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.dg.aai.objects;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestRelationship {
+ private Relationship relationship;
+ private Map<String,String> relationShipDataMap;
+ private Map<String,String> relatedProperties;
+
+ @Before
+ public void setUp() {
+ relationship=new Relationship();
+ relationShipDataMap = new HashMap<>();
+ relatedProperties = new HashMap<>();
+ }
+
+ @Test
+ public void testGetRelatedTo() {
+ relationship.setRelatedTo("relatedTo");
+ Assert.assertNotNull(relationship.getRelatedTo());
+ Assert.assertEquals("relatedTo",relationship.getRelatedTo());
+ }
+
+ @Test
+ public void testGetRelatedLink() {
+ relationship.setRelatedLink("relatedLink");
+ Assert.assertNotNull(relationship.getRelatedLink());
+ Assert.assertEquals("relatedLink",relationship.getRelatedLink());
+ }
+
+ @Test
+ public void testgetRelationShipDataMap_IsEmpty() {
+ Assert.assertTrue(relationship.getRelationShipDataMap().isEmpty());
+ }
+
+ @Test
+ public void testGetRelationShipDataMap_With_Data() {
+ relationShipDataMap.put("1", "A");
+ Assert.assertTrue(relationShipDataMap.containsKey("1"));
+ }
+
+ @Test
+ public void testGetRelationShipDataMap_WithValidKey() {
+ relationShipDataMap.put("2", "B");
+ Assert.assertEquals("B",relationShipDataMap.get("2"));
+ }
+
+ @Test
+ public void testgetRelationShipDataMap_WithInValidKey() {
+ Assert.assertEquals(null,relationShipDataMap.get("3"));
+ }
+
+ @Test
+ public void testGetRelationShipDataMap_Size() {
+ relationShipDataMap.put("3", "C");
+ relationShipDataMap.put("4", "D");
+ Assert.assertEquals(2, relationShipDataMap.size());
+ }
+
+ @Test
+ public void testGetRelatedProperties_IsEmpty() {
+ Assert.assertTrue(relationship.getRelatedProperties().isEmpty());
+ }
+
+ @Test
+ public void testGetRelatedProperties_With_Data() {
+ relatedProperties.put("1", "A");
+ Assert.assertTrue(relatedProperties.containsKey("1"));
+ }
+
+ @Test
+ public void testGetRelatedProperties_WithValidKey() {
+ relatedProperties.put("2", "B");
+ Assert.assertEquals("B",relatedProperties.get("2"));
+ }
+
+ @Test
+ public void testGetRelatedProperties_WithInValidKey() {
+ Assert.assertEquals(null,relatedProperties.get("3"));
+ }
+
+ @Test
+ public void testGetRelatedProperties_Size() {
+ relatedProperties.put("3", "C");
+ relatedProperties.put("4", "D");
+ Assert.assertEquals(2, relatedProperties.size());
+ }
+}