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 org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
23 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
24 import org.apache.tinkerpop.gremlin.structure.T;
25 import org.apache.tinkerpop.gremlin.structure.Vertex;
26 import org.junit.Test;
27 import org.onap.aai.exceptions.AAIException;
28 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
32 public class OwningEntityfromServiceInstance extends QueryTest {
33 public OwningEntityfromServiceInstance () throws AAIException, NoEdgeRuleFoundException {
43 protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
45 // Set up the test graph
46 Vertex service_instance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-1");
47 Vertex owning_entity = graph.addVertex(T.label, "owning-entity", T.id, "2", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-1", "owning-entity-name", "owning-entity-name1");
49 // adding extra vertices and edges which shouldn't be picked.
50 Vertex service_instance2 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "service-instance-2");
51 Vertex owning_entity2 = graph.addVertex(T.label, "owning-entity", T.id, "4", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-2", "owning-entity-name", "owning-entity-name2");
53 GraphTraversalSource g = graph.traversal();
54 rules.addEdge(g, owning_entity, service_instance);
55 rules.addEdge(g, owning_entity2, service_instance2);
57 expectedResult.add(owning_entity);
61 protected String getQueryName() {
62 return "owning-entity-fromService-instance";
66 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
67 g.has("service-instance-id", "service-instance-1");
71 protected void addParam(Map<String, Object> params) {