Update the license for 2017-2018 license
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / SitesByCountryFilterCloudRegionIdQueryTest.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 import java.util.Map;
22
23 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
24 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
25 import org.apache.tinkerpop.gremlin.structure.T;
26 import org.apache.tinkerpop.gremlin.structure.Vertex;
27 import org.junit.Test;
28
29 import org.onap.aai.exceptions.AAIException;
30 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
31
32 public class SitesByCountryFilterCloudRegionIdQueryTest extends QueryTest {
33
34         
35         public SitesByCountryFilterCloudRegionIdQueryTest() 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                 //Set up the test graph
48                 Vertex complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli-100", "country", "countrycode-100");
49                 Vertex l3network = graph.addVertex(T.label, "l3-network", T.id, "1", "aai-node-type", "l3-network", "network-id", "networkId-100", "network-name", "networkName-100",
50                                 "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
51                 Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "2", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-100", "cloud-region-id", "cloudRegionId-100");
52                 Vertex cloudregion2 = graph.addVertex(T.label, "cloud-region", T.id, "3", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner-200", "cloud-region-id", "cloudRegionId-200");
53                 Vertex l3network2 = graph.addVertex(T.label, "l3-network", T.id, "4", "aai-node-type", "l3-network", "network-id", "networkId-200", "network-name", "networkName-200",
54                                 "is-bound-to-vpn", "false", "is-provider-network", "false", "is-shared-network", "false", "is-external-network", "false");
55                 Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "5", "aai-node-type", "complex", "physical-location-id", "clli-200", "country", "countrycode-100");
56
57
58         
59                 GraphTraversalSource g = graph.traversal();
60                 rules.addEdge(g, complex, l3network);
61                 rules.addEdge(g, cloudregion, l3network);
62                 rules.addEdge(g, complex2, l3network2);
63                 rules.addEdge(g, cloudregion2, l3network2);
64                 
65                 expectedResult.add(complex);
66                 
67
68         }
69
70         @Override
71         protected String getQueryName() {
72                 return "sites-byCountryFilterCloudRegionId";
73         }
74
75         @Override
76         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
77                 g.has("aai-node-type", "complex").has("country", "countrycode-100");
78         }
79
80         @Override
81         protected void addParam(Map<String, Object> params) {
82                 params.put("cloudRegionId", "cloudRegionId-100");
83                 
84         }
85 }