Update the license for 2017-2018 license
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / SiteL3NetworkCloudRegionQueryTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 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 package org.onap.aai.rest.search;
21
22 import java.util.Map;
23
24 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
25 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
26 import org.apache.tinkerpop.gremlin.structure.T;
27 import org.apache.tinkerpop.gremlin.structure.Vertex;
28 import org.junit.Test;
29
30 import org.onap.aai.exceptions.AAIException;
31 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
32
33 public class SiteL3NetworkCloudRegionQueryTest extends QueryTest {
34
35         public SiteL3NetworkCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
36                 super();
37         }
38
39         @Test
40         public void run() {
41                 super.run();
42         }
43         
44         @Override
45         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
46                 Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
47                 Vertex network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network");
48                 Vertex region = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region");
49                 Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "clli2");
50                 Vertex network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network");
51                 Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "5", "aai-node-type", "cloud-region");
52                 Vertex network3 = graph.addVertex(T.label, "l3-network", T.id, "6", "aai-node-type", "l3-network");
53                 
54                 GraphTraversalSource g = graph.traversal();
55                 rules.addEdge(g, complex, network);
56                 rules.addEdge(g, region, network);
57                 rules.addEdge(g, complex, network3);
58                 rules.addEdge(g, complex2, network2);
59                 rules.addEdge(g, region2, network2);            
60                 
61                 expectedResult.add(complex);
62                 expectedResult.add(network);
63                 expectedResult.add(region);
64                 expectedResult.add(network3);
65                 
66         }
67
68         @Override
69         protected String getQueryName() {
70                 return "site-l3network-cloudRegion";
71         }
72
73         @Override
74         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
75                 g.has("physical-location-id", "clli");
76                 
77         }
78
79         @Override
80         protected void addParam(Map<String, Object> params) {
81                 return;
82         }
83
84 }