2 * ============LICENSE_START=======================================================
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
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=========================================================
21 package org.openecomp.aai.rest.search;
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.openecomp.aai.exceptions.AAIException;
31 import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
33 public class VnfsFromServiceInstanceTest extends QueryTest {
34 public VnfsFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException {
43 protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
46 //Set up the test graph
47 Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
48 Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
49 Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
50 Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "4", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "vnfname1", "vnf-type", "vnftype1");
51 Vertex serviceinstance2 = graph.addVertex(T.label, "service-instance", T.id, "5", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-2", "service-instance-name", "service-instance-name-2");
52 Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2", "vnf-name", "vnfname2", "vnf-type", "vnftype1");
54 GraphTraversalSource g = graph.traversal();
56 rules.addEdge(g, vnf1, serviceinstance);//true
57 rules.addEdge(g, vnf2, serviceinstance2);
59 rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
60 rules.addTreeEdge(g, serviceinstance2, servicesubscription);
61 rules.addTreeEdge(g, servicesubscription, customer);//true
63 expectedResult.add(vnf1);
67 protected String getQueryName() {
68 return "vnfs-fromServiceInstance";
71 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
72 g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
76 protected void addParam(Map<String, Object> params) {