b88a878f899e52d099b04990bc3e7bec687d7edc
[appc.git] /
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 TestAAIQueryResult {
30     private AAIQueryResult aaiQueryResult;
31     private Map<String,String> additionProperties;
32
33     
34     @Before
35     public void setUp() {
36         aaiQueryResult=new AAIQueryResult();
37         additionProperties = new HashMap<>();
38     }
39
40     @Test
41     public void testGetRelationshipList() {
42         Assert.assertTrue(aaiQueryResult. getRelationshipList().isEmpty());
43     }
44
45     @Test
46     public void testGetRelationshipList_With_Data() {
47         Relationship r1=new Relationship();
48         r1.setRelatedLink("relatedLink");
49         r1.setRelatedTo("relatedTo");
50         r1.getRelatedProperties().put("1", "A");
51         r1.getRelationShipDataMap().put("B", "b");
52         aaiQueryResult.getRelationshipList().add(r1);
53         Assert.assertEquals(1,aaiQueryResult.getRelationshipList().size());
54     }
55
56     @Test
57     public void testGetAdditionProperties_IsEmpty() {
58         Assert.assertTrue(aaiQueryResult. getAdditionProperties().isEmpty());
59     }
60
61     @Test
62     public void testGetAdditionProperties_With_Data() {
63         additionProperties.put("1", "A");
64         Assert.assertTrue(additionProperties.containsKey("1"));
65     }
66
67     @Test
68     public void testGetAdditionProperties_WithValidKey() {
69         additionProperties.put("2", "B");
70         Assert.assertEquals("B",additionProperties.get("2"));
71     }
72
73     @Test
74     public void testGetAdditionProperties_WithInValidKey() {
75         Assert.assertEquals(null,additionProperties.get("3"));
76     }
77
78     @Test
79     public void testGetAdditionProperties_Size() {
80         additionProperties.put("3", "C");
81         additionProperties.put("4", "D");
82         Assert.assertEquals(2, additionProperties.size());
83     }
84 }