f828558ff775381d79527f65e98f402e67cddeca
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / CloudRegionFromVnfTest.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 static org.junit.Assert.*;
25
26 import java.util.Map;
27
28 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
29 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
30 import org.apache.tinkerpop.gremlin.structure.T;
31 import org.apache.tinkerpop.gremlin.structure.Vertex;
32 import org.junit.Test;
33 import org.onap.aai.exceptions.AAIException;
34 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
35
36 public class CloudRegionFromVnfTest extends QueryTest {
37
38         public CloudRegionFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
39                 super();
40         }
41
42         @Test
43         public void run() {
44                 super.run();
45         }
46
47         @Override
48         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
49                 Vertex gv = graph.addVertex(T.id, "00", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "name", "vnf-type", "type");
50                 Vertex vnfc = graph.addVertex(T.id, "10", "aai-node-type", "vnfc", 
51                                 "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
52                 Vertex vserv = graph.addVertex(T.id, "20", "aai-node-type", "vserver",
53                                 "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
54                 Vertex cr = graph.addVertex(T.id, "30", "aai-node-type", "cloud-region", "cloud-owner", "some guy", "cloud-region-id", "crId");
55                 Vertex tenant = graph.addVertex(T.id, "40", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName");
56                 
57                 GraphTraversalSource g = graph.traversal();
58                 rules.addEdge(g, gv, vnfc);
59                 rules.addEdge(g, vnfc, vserv);
60                 rules.addTreeEdge(g, cr, tenant);
61                 rules.addTreeEdge(g, tenant, vserv);
62                 
63                 expectedResult.add(cr);
64                 expectedResult.add(tenant);
65                 expectedResult.add(vnfc);
66                 expectedResult.add(vserv);
67         }
68
69         @Override
70         protected String getQueryName() {
71                 return "cloud-region-fromVnf";
72         }
73
74         @Override
75         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
76                 g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvId");
77         }
78
79         @Override
80         protected void addParam(Map<String, Object> params) {
81                 // N/A for this query
82         }
83
84 }