Increase unit test coverage in appc-dg-aai project
[appc.git] / appc-dg / appc-dg-shared / appc-dg-aai / src / test / java / org / onap / appc / dg / aai / objects / TestRelationship.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : APPC
4 * ================================================================================
5 * Copyright 2018 TechMahindra
6 * ================================================================================
7 * Modifications Copyright (C) 2019 Ericsson
8 *=================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 *     http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
21 */
22
23 package org.onap.appc.dg.aai.objects;
24
25 import java.util.HashMap;
26 import java.util.Map;
27 import org.junit.Assert;
28 import org.junit.Before;
29 import org.junit.Test;
30
31 public class TestRelationship {
32     private Relationship relationship;
33     private Map<String,String> relationShipDataMap;
34     private Map<String,String> relatedProperties;
35
36     @Before
37     public void setUp() {
38         relationship=new Relationship();
39         relationShipDataMap = new HashMap<>();
40         relatedProperties = new HashMap<>();
41     }
42
43     @Test
44     public void testGetRelatedTo() {
45         relationship.setRelatedTo("relatedTo");
46         Assert.assertNotNull(relationship.getRelatedTo());
47         Assert.assertEquals("relatedTo", relationship.getRelatedTo());
48     }
49
50     @Test
51     public void testGetRelatedLink() {
52         relationship.setRelatedLink("relatedLink");
53         Assert.assertNotNull(relationship.getRelatedLink());
54         Assert.assertEquals("relatedLink", relationship.getRelatedLink());
55     }
56
57     @Test
58     public void testgetRelationShipDataMap_IsEmpty() {
59         Assert.assertTrue(relationship.getRelationShipDataMap().isEmpty());
60     }
61
62     @Test
63     public void testGetRelationShipDataMap_With_Data() {
64         relationShipDataMap.put("1", "A");
65         Assert.assertTrue(relationShipDataMap.containsKey("1"));
66     }
67
68     @Test
69     public void testGetRelationShipDataMap_WithValidKey() {
70         relationShipDataMap.put("2", "B");
71         Assert.assertEquals("B", relationShipDataMap.get("2"));
72     }
73
74     @Test
75     public void testgetRelationShipDataMap_WithInValidKey() {
76         Assert.assertEquals(null, relationShipDataMap.get("3"));
77     }
78
79     @Test
80     public void testGetRelationShipDataMap_Size() {
81         relationShipDataMap.put("3", "C");
82         relationShipDataMap.put("4", "D");
83         Assert.assertEquals(2, relationShipDataMap.size());
84     }
85
86     @Test
87     public void testGetRelatedProperties_IsEmpty() {
88         Assert.assertTrue(relationship.getRelatedProperties().isEmpty());
89     }
90
91     @Test
92     public void testGetRelatedProperties_With_Data() {
93         relatedProperties.put("1", "A");
94         Assert.assertTrue(relatedProperties.containsKey("1"));
95     }
96
97     @Test
98     public void testGetRelatedProperties_WithValidKey() {
99         relatedProperties.put("2", "B");
100         Assert.assertEquals("B",relatedProperties.get("2"));
101     }
102
103     @Test
104     public void testGetRelatedProperties_WithInValidKey() {
105         Assert.assertEquals(null,relatedProperties.get("3"));
106     }
107
108     @Test
109     public void testGetRelatedProperties_Size() {
110         relatedProperties.put("3", "C");
111         relatedProperties.put("4", "D");
112         Assert.assertEquals(2, relatedProperties.size());
113     }
114 }