2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.aai.rest.search;
22 import static org.junit.Assert.*;
26 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
27 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
28 import org.apache.tinkerpop.gremlin.structure.T;
29 import org.apache.tinkerpop.gremlin.structure.Vertex;
30 import org.junit.Test;
31 import org.onap.aai.exceptions.AAIException;
32 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
34 public class CloudRegionFromVnfTest extends QueryTest {
36 public CloudRegionFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
46 protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
47 Vertex gv = graph.addVertex(T.id, "00", "aai-node-type", "generic-vnf", "vnf-id", "gvId", "vnf-name", "name", "vnf-type", "type");
48 Vertex vnfc = graph.addVertex(T.id, "10", "aai-node-type", "vnfc",
49 "vnfc-name", "vnfcName1", "nfc-naming-code", "blue", "nfc-function", "correct-function");
50 Vertex vserv = graph.addVertex(T.id, "20", "aai-node-type", "vserver",
51 "vserver-id", "vservId", "vserver-name", "vservName", "vserver-selflink", "me/self");
52 Vertex cr = graph.addVertex(T.id, "30", "aai-node-type", "cloud-region", "cloud-owner", "some guy", "cloud-region-id", "crId");
53 Vertex tenant = graph.addVertex(T.id, "40", "aai-node-type", "tenant", "tenant-id", "ten1", "tenant-name", "tenName");
55 GraphTraversalSource g = graph.traversal();
56 rules.addEdge(g, gv, vnfc);
57 rules.addEdge(g, vnfc, vserv);
58 rules.addTreeEdge(g, cr, tenant);
59 rules.addTreeEdge(g, tenant, vserv);
61 expectedResult.add(cr);
62 expectedResult.add(tenant);
63 expectedResult.add(vnfc);
64 expectedResult.add(vserv);
68 protected String getQueryName() {
69 return "cloud-region-fromVnf";
73 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
74 g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvId");
78 protected void addParam(Map<String, Object> params) {