e8aec8bf786c369667e98fb702d481033bf63765
[aai/traversal.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.openecomp.aai
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.openecomp.aai.rest.search;
22
23 import java.util.Map;
24
25 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
26 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
27 import org.apache.tinkerpop.gremlin.structure.T;
28 import org.apache.tinkerpop.gremlin.structure.Vertex;
29 import org.junit.Test;
30
31 import org.openecomp.aai.exceptions.AAIException;
32 import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
33
34 public class LocationNetTypeNetRolefromCloudRegionQueryTest extends QueryTest {
35         public LocationNetTypeNetRolefromCloudRegionQueryTest() 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                 
47                 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");
48                 Vertex complex = graph.addVertex(T.label, "complex", T.id, "1", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
49                 Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "2", "aai-node-type", "l3-network", "network-id", "network-id-1");
50                 
51                 
52                 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");
53                 Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "4", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
54                 Vertex l3network1 = graph.addVertex(T.label, "l3-network", T.id, "5", "aai-node-type", "l3-network", "network-id", "network-id-2");
55                 
56                 GraphTraversalSource g = graph.traversal();
57                 rules.addEdge(g, cloudregion,complex);
58                 rules.addEdge(g, complex,l3network);
59                 
60                 rules.addEdge(g, cloudregion1,complex1);
61                 rules.addEdge(g, complex1,l3network1);
62                 
63                 expectedResult.add(cloudregion);
64                 expectedResult.add(complex);
65                 expectedResult.add(l3network);
66                 
67         }
68
69         @Override
70         protected String getQueryName() {
71                 return  "locationNetTypeNetRole-fromCloudRegion";
72         }
73         @Override
74         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
75                 g.has("cloud-region-id", "cloud-region-id-1");
76                 
77         }
78         @Override
79         protected void addParam(Map<String, Object> params) {
80                 return;
81         }
82 }