295194f73c6928aa3323b081e42691f40f723a7a
[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.onap.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 import org.onap.aai.exceptions.AAIException;
31 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
32
33 public class AvailabilityZoneAndComplexfromCloudRegionQueryTest extends QueryTest {
34         public AvailabilityZoneAndComplexfromCloudRegionQueryTest() throws AAIException, NoEdgeRuleFoundException {
35                 super();
36         }
37
38         @Test
39         public void run() {
40                 super.run();
41         }
42
43         @Override
44         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {    
45                 
46                 Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "0", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-1", "cloud-owner", "cloud-owner-1");
47                 Vertex availibityzone = graph.addVertex(T.label, "availability-zone", T.id, "1", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-1", "hypervisor-type", "hypervisortype-1");
48                 Vertex complex = graph.addVertex(T.label, "complex", T.id, "2", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1","country","country1");
49                 
50                 Vertex cloudregion1 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region-id-10", "cloud-owner", "cloud-owner-10");
51                 Vertex availibityzone1 = graph.addVertex(T.label, "availability-zone", T.id, "4", "aai-node-type", "availability-zone", "availability-zone-name", "az-name-10", "hypervisor-type", "hypervisortype-10");
52                 Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "physical-location-id-20","country","country20");
53         
54                 GraphTraversalSource g = graph.traversal();
55                 rules.addTreeEdge(g, cloudregion, availibityzone);
56                 rules.addEdge(g, cloudregion,complex);
57                 
58                 rules.addTreeEdge(g, cloudregion1, availibityzone1);
59                 rules.addEdge(g, cloudregion1,complex1);
60                 
61                 expectedResult.add(availibityzone);
62                 expectedResult.add(complex);
63         }
64
65         @Override
66         protected String getQueryName() {
67                 return  "availabilityZoneAndComplex-fromCloudRegion";
68         }
69         @Override
70         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
71                 g.has("aai-node-type","cloud-region").has("cloud-owner","cloud-owner-1").has("cloud-region-id","cloud-region-id-1");
72         }
73         @Override
74         protected void addParam(Map<String, Object> params) {
75                 return;
76         }
77 }