diff options
author | Venkata Harish K Kajur <vk250x@att.com> | 2017-12-08 17:10:09 -0500 |
---|---|---|
committer | Venkata Harish K Kajur <vk250x@att.com> | 2017-12-08 17:10:14 -0500 |
commit | a488f5dcc1f85d7d7995bca55ab6b02316512707 (patch) | |
tree | 4c1afe04deb9f3266345a951c30aaf10e5593181 /aai-traversal | |
parent | 091505655f376b1ccfdf26d785b612da12d661e3 (diff) |
Add the service model custom query
Issue-ID: AAI-557
Change-Id: Ibe6ab6a565d0db65edd29e110ad1283c1af4e3f0
Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-traversal')
-rw-r--r-- | aai-traversal/bundleconfig-local/etc/query/stored-queries.properties | 11 | ||||
-rw-r--r-- | aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java | 76 |
2 files changed, 86 insertions, 1 deletions
diff --git a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties index 6a7c344..0ea6ab6 100644 --- a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties +++ b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties @@ -406,4 +406,13 @@ queryvnfFromModelbyRegion=builder.createEdgeTraversal(EdgeType.COUSIN, 'service- .createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region')\ .getVerticesByProperty('cloud-region-id', cloudRegionId)\ ).store('x')\ - .cap('x').unfold().dedup()
\ No newline at end of file + .cap('x').unfold().dedup() + +serviceModels-byDistributionStatus=builder.where(\ + builder.newInstance().createEdgeTraversal(EdgeType.TREE,'model', 'model-ver')\ + .getVerticesByProperty('distribution-status', distributionStatus)\ + ).store('x')\ + .createEdgeTraversal(EdgeType.TREE,'model', 'model-ver')\ + .getVerticesByProperty('distribution-status', distributionStatus)\ + .store('x').cap('x').unfold().dedup() + diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java new file mode 100644 index 0000000..abf9139 --- /dev/null +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.rest.search; + +import java.util.Map; + +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.T; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Test; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; + +public class ServiceModelsByDistributionStatusTest extends QueryTest { + public ServiceModelsByDistributionStatusTest() throws AAIException, NoEdgeRuleFoundException { + super(); + } + + @Test + public void run() { + super.run(); + } + @Override + protected void createGraph() throws AAIException, NoEdgeRuleFoundException { + //Set up the test graph + Vertex model1 = graph.addVertex(T.label, "model", T.id, "1", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-1", "model-type", "resource"); + Vertex modelver1 = graph.addVertex(T.label, "model-ver", T.id, "2", "aai-node-type", "model-ver", "model-version-id", "model-version-id-1","model-name","model-name1", "model-version","model-version-1", "distribution-status", "distribution-status1"); + Vertex modelver11 = graph.addVertex(T.label, "model-ver", T.id, "21", "aai-node-type", "model-ver", "model-version-id", "model-version-id-11","model-name","model-name11", "model-version","model-version-1", "distribution-status", "distribution-status2"); + + Vertex model2 = graph.addVertex(T.label, "model", T.id, "3", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-2", "model-type", "resource"); + Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-1", "distribution-status", "distribution-status2"); + GraphTraversalSource g = graph.traversal(); + + rules.addTreeEdge(g, modelver1, model1); + rules.addTreeEdge(g, modelver11, model1); + rules.addTreeEdge(g, modelver2, model1); + + expectedResult.add(model1); + expectedResult.add(modelver11); + expectedResult.add(modelver2); + + } + @Override + protected String getQueryName() { + return "serviceModels-byDistributionStatus"; + } + @Override + protected void addStartNode(GraphTraversal<Vertex, Vertex> g) { + g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1"); + } + + @Override + protected void addParam(Map<String, Object> params) { + params.put("distributionStatus", "distribution-status2"); + return; + } +} |