Update traversal from AJSC 2 to Spring Boot
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / LocationNetTypeNetRolefromCloudRegionQueryTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.rest.search;
23
24 import java.util.Map;
25
26 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
27 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
28 import org.apache.tinkerpop.gremlin.structure.T;
29 import org.apache.tinkerpop.gremlin.structure.Vertex;
30 import org.junit.Test;
31
32 import org.onap.aai.exceptions.AAIException;
33 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
34
35 public class LocationNetTypeNetRolefromCloudRegionQueryTest extends QueryTest {
36         public LocationNetTypeNetRolefromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
37                 super();
38         }
39
40         @Test
41         public void run() {
42                 super.run();
43         }
44
45         @Override
46         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {    
47                 
48                 Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-region-owner", "cloud-owner-name-1");
49                 Vertex complex = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
50                 Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "2", "aai-node-type", "l3-network", "network-id", "network-id-1");
51                 
52                 
53                 Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-2", "cloud-region-owner", "cloud-owner-name-2");
54                 Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "4", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
55                 Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "5", "aai-node-type", "l3-network", "network-id", "network-id-2");
56                 
57                 GraphTraversalSource g = graph.traversal();
58                 rules.addEdge(g, cloudregion,complex);
59                 rules.addEdge(g, complex,l3network);
60                 
61                 rules.addEdge(g, cloudregion1,complex1);
62                 rules.addEdge(g, complex1,l3network1);
63                 
64                 expectedResult.add(cloudregion);
65                 expectedResult.add(complex);
66                 expectedResult.add(l3network);
67                 
68         }
69
70         @Override
71         protected String getQueryName() {
72                 return  "locationNetTypeNetRole-fromCloudRegion";
73         }
74         @Override
75         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
76                 g.has("cloud-region-id", "cloud-region-id-1");
77                 
78         }
79         @Override
80         protected void addParam(Map<String, Object> params) {
81                 return;
82         }
83 }