2 * ============LICENSE_START=======================================================
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
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.rest.search;
24 import static org.junit.Assert.*;
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;
36 public class VserverFromVnfQueryTest extends QueryTest {
38 public VserverFromVnfQueryTest() throws AAIException, NoEdgeRuleFoundException {
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", "gvName", "vnf-type", "some-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 lint = graph.addVertex(T.id, "30", "aai-node-type", "l-interface", "interface-name", "lintName");
55 Vertex ipv4 = graph.addVertex(T.id, "40", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "0.0.0.0");
56 Vertex ipv6 = graph.addVertex(T.id, "50", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "0.0.0.0");
58 GraphTraversalSource g = graph.traversal();
59 rules.addEdge(g, gv, vnfc);
60 rules.addEdge(g, vserv, vnfc);
61 rules.addTreeEdge(g, vserv, lint);
62 rules.addTreeEdge(g, lint, ipv4);
63 rules.addTreeEdge(g, lint, ipv6);
65 expectedResult.add(vserv);
66 expectedResult.add(lint);
67 expectedResult.add(ipv4);
68 expectedResult.add(ipv6);
69 expectedResult.add(vnfc);
73 protected String getQueryName() {
74 return "vserver-fromVnf";
78 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
79 g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvId");
83 protected void addParam(Map<String, Object> params) {
84 params.put("nfcFunction", "correct-function");