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;
 
  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 VnfInstancesFromServiceInstancebyModelVersionTest extends QueryTest {
 
  35         public VnfInstancesFromServiceInstancebyModelVersionTest() throws AAIException, NoEdgeRuleFoundException {
 
  44         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
 
  47                 //Set up the test graph 
 
  48         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");
 
  49         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");
 
  50         Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
 
  52                 Vertex model1 = graph.addVertex(T.label, "model", T.id, "4", "aai-node-type", "model", "model-invariant-id", "modinvariant-id1", "model-type", "modtype");
 
  53                 Vertex modelver1 = graph.addVertex(T.label, "model-ver", T.id, "5", "aai-node-type", "model-ver", "model-version-id", "modver-id1", "model-name", "modname1", "model-version", "v1.0");
 
  54                 Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "vnfname1", "vnf-type", "vnftype1", "model-invariant-id-local", "modinvariant-id1", "model-version-id-local", "modver-id1");
 
  56 //              Vertex model2 = graph.addVertex(T.label, "model", T.id, "7", "aai-node-type", "model", "model-invariant-id", "modinvariant-id2", "model-type", "modtype");
 
  57 //              Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "8", "aai-node-type", "model-ver", "model-version-id", "modver-id2", "model-name", "modname2", "model-version", "v1.0");
 
  58                 Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2", "vnf-name", "vnfname2", "vnf-type", "vnftype2", "model-invariant-id-local", "modinvariant-id1", "model-version-id-local", "modver-id1");
 
  61                 GraphTraversalSource g = graph.traversal();
 
  62                 rules.addTreeEdge(g, model1, modelver1);//true
 
  63                 rules.addEdge(g, vnf1, serviceinstance);//true
 
  64                 rules.addEdge(g, vnf2, serviceinstance);//false
 
  65         rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
 
  66         rules.addTreeEdge(g, servicesubscription, customer);//true
 
  68                 expectedResult.add(vnf1);
 
  72         protected String getQueryName() {
 
  73                 return "vnf-instances-fromServiceInstancebyModelVersion";
 
  76         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
 
  77                 g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
 
  81         protected void addParam(Map<String, Object> params) {
 
  82                 params.put("vnfType", "vnftype1");
 
  83                 params.put("modelVersionId", "modver-id1");