Unit test for:org/onap/appc/dg/aai/objects classes 37/36437/2
authorshubhada <SV00449682@techmahindra.com>
Mon, 19 Mar 2018 08:00:42 +0000 (13:30 +0530)
committerTakamune Cho <tc012c@att.com>
Mon, 19 Mar 2018 13:13:09 +0000 (13:13 +0000)
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>
appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestAAIQueryResult.java [new file with mode: 0644]
appc-dg/appc-dg-shared/appc-dg-aai/src/test/java/org/onap/appc/dg/aai/objects/TestRelationship.java [new file with mode: 0644]

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 (file)
index 0000000..b88a878
--- /dev/null
@@ -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 (file)
index 0000000..f0b832a
--- /dev/null
@@ -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());
+    }
+}