* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.parsers.query;
+import static org.junit.Assert.assertEquals;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+
+import javax.ws.rs.core.UriBuilder;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.exceptions.AAIException;
-
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-
-import javax.ws.rs.core.UriBuilder;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-
-import static org.junit.Assert.assertEquals;
+import org.onap.aai.setup.SchemaVersion;
@Ignore
public class UniqueURIQueryTest extends AAISetup {
-
private TransactionalGraphEngine dbEngine;
private SchemaVersion version;
private DynamicJAXBContext context = nodeIngestor.getContextForVersion(version);
public void parentQuery() throws UnsupportedEncodingException, AAIException {
version = new SchemaVersion("v10");
dbEngine = new JanusGraphDBEngine(QueryStyle.GREMLIN_UNIQUE,
- loaderFactory.createLoaderForVersion(ModelType.MOXY, version),
- false);
+ loaderFactory.createLoaderForVersion(ModelType.MOXY, version), false);
URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1").build();
String key = "complex/key1";
QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
*/
@Test
public void childQuery() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3").build();
+ URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3")
+ .build();
QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
String parentKey = "complex/key1";
String key = parentKey + "/ctag-pool/key2/key3";
GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", key);
- GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", parentKey);
+ GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", parentKey);
String parentResultType = "complex";
String resultType = "ctag-pool";
String containerType = "";
*/
@Test
public void namingExceptions() throws UnsupportedEncodingException, AAIException {
- URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655").build();
+ URI uri = UriBuilder.fromPath("network/vces/vce/key1/port-groups/port-group/key2/cvlan-tags/cvlan-tag/655")
+ .build();
QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
String parentKey = "vce/key1/port-group/key2";
String key = parentKey + "/cvlan-tag/655";
String parentKey = "vce/key1/port-group/key2";
URI uri = UriBuilder.fromPath(parentURI + "/cvlan-tags").build();
QueryParser query = dbEngine.getQueryBuilder().createQueryFromURI(uri);
- GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", parentKey).in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "cvlan-tag");
- GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key",parentKey);
+ GraphTraversal<Vertex, Vertex> expected = __.<Vertex>start().has("aai-unique-key", parentKey)
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "cvlan-tag");
+ GraphTraversal<Vertex, Vertex> parentExpected = __.<Vertex>start().has("aai-unique-key", parentKey);
String parentResultType = "port-group";
String resultType = "cvlan-tag";
String containerType = "cvlan-tags";
* @param resultType the result type
* @param containerType the container type
*/
- public void testSet(QueryParser query, GraphTraversal<Vertex, Vertex> expected, GraphTraversal<Vertex, Vertex> parentExpected, String parentResultType, String resultType, String containerType) {
- assertEquals(
- "gremlin query should be " + expected,
- expected,
- query.getQueryBuilder().getQuery());
- assertEquals(
- "parent gremlin query should be " + parentExpected,
- parentExpected,
+ public void testSet(QueryParser query, GraphTraversal<Vertex, Vertex> expected,
+ GraphTraversal<Vertex, Vertex> parentExpected, String parentResultType, String resultType,
+ String containerType) {
+ assertEquals("gremlin query should be " + expected, expected, query.getQueryBuilder().getQuery());
+ assertEquals("parent gremlin query should be " + parentExpected, parentExpected,
query.getQueryBuilder().getParentQuery().getQuery());
- assertEquals(
- "parent result type should be " + parentResultType,
- parentResultType,
- query.getParentResultType());
- assertEquals(
- "result type should be " + resultType,
- resultType,
- query.getResultType());
- assertEquals(
- "container type should be " + containerType,
- containerType,
- query.getContainerType());
+ assertEquals("parent result type should be " + parentResultType, parentResultType, query.getParentResultType());
+ assertEquals("result type should be " + resultType, resultType, query.getResultType());
+ assertEquals("container type should be " + containerType, containerType, query.getContainerType());
}
}