add unit test
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / aai / entity / RelationshipListTest.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.holmes.common.aai.entity;
17
18 import static org.hamcrest.CoreMatchers.equalTo;
19 import static org.junit.Assert.*;
20
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;
28
29 public class RelationshipListTest {
30
31     private RelationshipList relationshipList;
32
33     @Before
34     public void serUp() {
35         relationshipList = new RelationshipList();
36     }
37
38     @Test
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);
47
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);
55
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);
65
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()
72                 .size()));
73         assertThat(propertyKey,
74                 equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList().get(0)
75                         .getPropertyKey()));
76         assertThat(propertyValue,
77                 equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList().get(0)
78                         .getPropertyValue()));
79         assertThat(1, equalTo(relationshipList.getRelationships().get(0).getRelationshipDataList()
80                 .size()));
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()));
87     }
88 }