aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java')
-rw-r--r--aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java95
1 files changed, 95 insertions, 0 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
new file mode 100644
index 0000000..822643e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java
@@ -0,0 +1,95 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.dsl;
+
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.exceptions.AAIException;
+
+import static org.junit.Assert.assertEquals;
+
+//TODO: Change this to read queries and their builder equivalent from a file
+//TODO: Add queries run by SEs
+
+public class ProdDslTest extends AAISetup {
+ @Test
+ public void msoQueryTest1() throws AAIException {
+ String aaiQuery = "cloud-region('cloud-owner', 'value')('cloud-region-id', 'value') > vlan-tag*('vlan-id-outer', 'value')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','value')"
+ + ".getVerticesByProperty('cloud-region-id','value').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag')"
+ + ".getVerticesByProperty('vlan-id-outer','value').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void msoQueryTest2() throws AAIException {
+ String aaiQuery = "pserver('hostname', 'pserver-1') > p-interface > sriov-pf*('pf-pci-id', '0000:ee:00.0')";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','pserver-1')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'pserver','p-interface')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'p-interface','sriov-pf').getVerticesByProperty('pf-pci-id','0000:ee:00.0').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ @Test
+ public void msoQueryTest3() throws AAIException {
+ String aaiQuery = "l-interface ('interface-id', 'value') > sriov-vf > sriov-pf*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'l-interface').getVerticesByProperty('interface-id','value')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'l-interface','sriov-vf')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'sriov-vf','sriov-pf').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ //TODO : Get this from schema
+ @Test
+ public void msoQueryTest4() throws AAIException {
+ //String aaiQuery = "l-interface ('interface-id', 'value') > lag-interface('interface-name', 'bond1') > sriov-pf*";
+ String aaiQuery = "l-interface ('interface-id', 'value') > lag-interface('interface-name', 'bond1') > p-interface > sriov-pf*";
+
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'l-interface').getVerticesByProperty('interface-id','value')"
+ + ".createEdgeTraversal( 'l-interface','lag-interface').getVerticesByProperty('interface-name','bond1')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'lag-interface','p-interface').createEdgeTraversal(EdgeType.TREE, 'p-interface','sriov-pf').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+ //TODO : Get this from schema
+ @Test
+ public void msoQueryTest5() throws AAIException {
+ //String aaiQuery = "pserver ('hostname', 'value') > vserver ('vserver-name', 'value') > l-interface > vlan-tag*";
+ String aaiQuery = "pserver ('hostname', 'value') > vserver ('vserver-name', 'value') > l-interface > cp > vlan-tag*";
+ String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('hostname','value')"
+ + ".createEdgeTraversal(EdgeType.COUSIN, 'pserver','vserver').getVerticesByProperty('vserver-name','value')"
+ + ".createEdgeTraversal(EdgeType.TREE, 'vserver','l-interface').createEdgeTraversal(EdgeType.COUSIN, 'l-interface','cp').createEdgeTraversal(EdgeType.COUSIN, 'cp','vlan-tag').store('x').cap('x').unfold().dedup()";
+
+ String query = dslQueryProcessor.parseAaiQuery(aaiQuery);
+ assertEquals(dslQuery, query);
+ }
+
+} \ No newline at end of file