2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.holmes.common.aai.entity;
18 import static org.hamcrest.CoreMatchers.equalTo;
19 import static org.junit.Assert.*;
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.onap.holmes.common.aai.entity.RelationshipList.RelatedToProperty;
26 import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
27 import org.onap.holmes.common.aai.entity.RelationshipList.RelationshipData;
29 public class RelationshipListTest {
31 private RelationshipList relationshipList;
35 relationshipList = new RelationshipList();
39 public void testRelationShip_getter_setter() {
40 List<RelatedToProperty> relatedToPropertyList = new ArrayList<>();
41 RelatedToProperty relatedToProperty = new RelatedToProperty();
42 String propertyKey = "properKey";
43 String propertyValue = "propertyValue";
44 relatedToProperty.setPropertyKey(propertyKey);
45 relatedToProperty.setPropertyValue(propertyValue);
46 relatedToPropertyList.add(relatedToProperty);
48 List<RelationshipData> relationshipDataList = new ArrayList<>();
49 RelationshipData relationshipData = new RelationshipData();
50 String relationshipKey = "relationshipKey";
51 String relationshipValue = "relationshipValue";
52 relationshipData.setRelationshipKey(relationshipKey);
53 relationshipData.setRelationshipValue(relationshipValue);
54 relationshipDataList.add(relationshipData);
56 List<Relationship> relationships = new ArrayList<>();
57 Relationship relationship = new Relationship();
58 String relatedLink = "relatedLink";
59 String relatedTo = "relatedTo";
60 relationship.setRelatedLink(relatedLink);
61 relationship.setRelatedTo(relatedTo);
62 relationship.setRelatedToPropertyList(relatedToPropertyList);
63 relationship.setRelationshipDataList(relationshipDataList);
64 relationships.add(relationship);
66 relationshipList.setRelationships(relationships);
67 assertThat(1, equalTo(relationshipList.getRelationships().size()));
68 assertThat(relatedLink,
69 equalTo(relationshipList.getRelationships().get(0).getRelatedLink()));
70 assertThat(relatedTo, equalTo(relationshipList.getRelationships().get(0).getRelatedTo()));
71 assertThat(1, equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList()
73 assertThat(propertyKey,
74 equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList().get(0)
76 assertThat(propertyValue,
77 equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList().get(0)
78 .getPropertyValue()));
79 assertThat(1, equalTo(relationshipList.getRelationships().get(0).getRelationshipDataList()
81 assertThat(relationshipKey,
82 equalTo(relationshipList.getRelationships().get(0).getRelationshipDataList().get(0)
83 .getRelationshipKey()));
84 assertThat(relationshipValue,
85 equalTo(relationshipList.getRelationships().get(0).getRelationshipDataList().get(0)
86 .getRelationshipValue()));