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