2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.appc.dg.aai.objects;
22 import java.util.HashMap;
25 import org.junit.Assert;
26 import org.junit.Before;
27 import org.junit.Test;
29 public class TestRelationship {
30 private Relationship relationship;
31 private Map<String,String> relationShipDataMap;
32 private Map<String,String> relatedProperties;
36 relationship=new Relationship();
37 relationShipDataMap = new HashMap<>();
38 relatedProperties = new HashMap<>();
42 public void testGetRelatedTo() {
43 relationship.setRelatedTo("relatedTo");
44 Assert.assertNotNull(relationship.getRelatedTo());
45 Assert.assertEquals("relatedTo",relationship.getRelatedTo());
49 public void testGetRelatedLink() {
50 relationship.setRelatedLink("relatedLink");
51 Assert.assertNotNull(relationship.getRelatedLink());
52 Assert.assertEquals("relatedLink",relationship.getRelatedLink());
56 public void testgetRelationShipDataMap_IsEmpty() {
57 Assert.assertTrue(relationship.getRelationShipDataMap().isEmpty());
61 public void testGetRelationShipDataMap_With_Data() {
62 relationShipDataMap.put("1", "A");
63 Assert.assertTrue(relationShipDataMap.containsKey("1"));
67 public void testGetRelationShipDataMap_WithValidKey() {
68 relationShipDataMap.put("2", "B");
69 Assert.assertEquals("B",relationShipDataMap.get("2"));
73 public void testgetRelationShipDataMap_WithInValidKey() {
74 Assert.assertEquals(null,relationShipDataMap.get("3"));
78 public void testGetRelationShipDataMap_Size() {
79 relationShipDataMap.put("3", "C");
80 relationShipDataMap.put("4", "D");
81 Assert.assertEquals(2, relationShipDataMap.size());
85 public void testGetRelatedProperties_IsEmpty() {
86 Assert.assertTrue(relationship.getRelatedProperties().isEmpty());
90 public void testGetRelatedProperties_With_Data() {
91 relatedProperties.put("1", "A");
92 Assert.assertTrue(relatedProperties.containsKey("1"));
96 public void testGetRelatedProperties_WithValidKey() {
97 relatedProperties.put("2", "B");
98 Assert.assertEquals("B",relatedProperties.get("2"));
102 public void testGetRelatedProperties_WithInValidKey() {
103 Assert.assertEquals(null,relatedProperties.get("3"));
107 public void testGetRelatedProperties_Size() {
108 relatedProperties.put("3", "C");
109 relatedProperties.put("4", "D");
110 Assert.assertEquals(2, relatedProperties.size());