2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.appc.dg.aai.objects;
25 import java.util.HashMap;
27 import org.junit.Assert;
28 import org.junit.Before;
29 import org.junit.Test;
31 public class TestRelationship {
32 private Relationship relationship;
33 private Map<String,String> relationShipDataMap;
34 private Map<String,String> relatedProperties;
38 relationship=new Relationship();
39 relationShipDataMap = new HashMap<>();
40 relatedProperties = new HashMap<>();
44 public void testGetRelatedTo() {
45 relationship.setRelatedTo("relatedTo");
46 Assert.assertNotNull(relationship.getRelatedTo());
47 Assert.assertEquals("relatedTo", relationship.getRelatedTo());
51 public void testGetRelatedLink() {
52 relationship.setRelatedLink("relatedLink");
53 Assert.assertNotNull(relationship.getRelatedLink());
54 Assert.assertEquals("relatedLink", relationship.getRelatedLink());
58 public void testgetRelationShipDataMap_IsEmpty() {
59 Assert.assertTrue(relationship.getRelationShipDataMap().isEmpty());
63 public void testGetRelationShipDataMap_With_Data() {
64 relationShipDataMap.put("1", "A");
65 Assert.assertTrue(relationShipDataMap.containsKey("1"));
69 public void testGetRelationShipDataMap_WithValidKey() {
70 relationShipDataMap.put("2", "B");
71 Assert.assertEquals("B", relationShipDataMap.get("2"));
75 public void testgetRelationShipDataMap_WithInValidKey() {
76 Assert.assertEquals(null, relationShipDataMap.get("3"));
80 public void testGetRelationShipDataMap_Size() {
81 relationShipDataMap.put("3", "C");
82 relationShipDataMap.put("4", "D");
83 Assert.assertEquals(2, relationShipDataMap.size());
87 public void testGetRelatedProperties_IsEmpty() {
88 Assert.assertTrue(relationship.getRelatedProperties().isEmpty());
92 public void testGetRelatedProperties_With_Data() {
93 relatedProperties.put("1", "A");
94 Assert.assertTrue(relatedProperties.containsKey("1"));
98 public void testGetRelatedProperties_WithValidKey() {
99 relatedProperties.put("2", "B");
100 Assert.assertEquals("B",relatedProperties.get("2"));
104 public void testGetRelatedProperties_WithInValidKey() {
105 Assert.assertEquals(null,relatedProperties.get("3"));
109 public void testGetRelatedProperties_Size() {
110 relatedProperties.put("3", "C");
111 relatedProperties.put("4", "D");
112 Assert.assertEquals(2, relatedProperties.size());