8d11f693084b5188166874bbe650078c1a53fe71
[so.git] / common / src / test / java / org / onap / so / client / aai / entities / RelationshipsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
21 package org.onap.so.client.aai.entities;
22
23 import static org.junit.Assert.assertTrue;
24
25 import java.io.IOException;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import java.util.Arrays;
29 import java.util.List;
30
31 import org.junit.Test;
32 import org.onap.so.client.aai.AAIObjectType;
33 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
34 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
35
36 public class RelationshipsTest {
37
38         private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/";
39
40         @Test
41         public void run() throws IOException {
42                 final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "e2e-complex.json")));
43                 
44                 AAIResultWrapper wrapper = new AAIResultWrapper(content);
45                 Relationships relationships = wrapper.getRelationships().get();
46                 
47                 List<AAIResourceUri> test = relationships.getRelatedUris(AAIObjectType.VCE);
48                 
49                 System.out.println(test.get(0).build());
50                 List<AAIResourceUri> uris = Arrays.asList(
51                                 AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a9fec18e-1ea3-40e4-a6c0-a89b3de07053"),
52                                 AAIUriFactory.createResourceUri(AAIObjectType.VCE, "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9"),
53                                 AAIUriFactory.createResourceUri(AAIObjectType.VCE, "a2935fa9-b743-49f4-9813-a127f13c4e93"),
54                                 AAIUriFactory.createResourceUri(AAIObjectType.VCE, "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4"));
55                 
56                 
57                 assertTrue(uris.containsAll(test) && test.containsAll(uris));
58                 
59         }       
60
61 }