aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/test/java
diff options
context:
space:
mode:
authorMuller, Andrew (am8383) <am8383@us.att.com>2017-08-11 15:13:28 -0400
committerJames Forsyth <jf2512@att.com>2017-08-11 20:09:31 +0000
commitfd16c2550e347e5f8d7be11c12dae479e7947ed8 (patch)
tree9d18ce007cb65c714290c628da18e0999b7fdfea /aai-resources/src/test/java
parentb840faea026675dd1aa065d2cb8e025dce8d9068 (diff)
[AAI-154 Amsterdam] Check in titan refactor
Change-Id: I955ac630071680e690c523e005d289d8fc40ba6c Signed-off-by: Muller, Andrew (am8383) <am8383@us.att.com>
Diffstat (limited to 'aai-resources/src/test/java')
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/migration/VertexMergeTest.java12
-rw-r--r--aai-resources/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java75
2 files changed, 81 insertions, 6 deletions
diff --git a/aai-resources/src/test/java/org/openecomp/aai/migration/VertexMergeTest.java b/aai-resources/src/test/java/org/openecomp/aai/migration/VertexMergeTest.java
index 1b5b67b..5b71cf7 100644
--- a/aai-resources/src/test/java/org/openecomp/aai/migration/VertexMergeTest.java
+++ b/aai-resources/src/test/java/org/openecomp/aai/migration/VertexMergeTest.java
@@ -34,12 +34,12 @@ import java.util.Map;
import java.util.Set;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.dbmap.DBConnectionType;
import org.openecomp.aai.introspection.Loader;
@@ -51,12 +51,12 @@ import org.openecomp.aai.serialization.db.EdgeRules;
import org.openecomp.aai.serialization.engines.QueryStyle;
import org.openecomp.aai.serialization.engines.TitanDBEngine;
import org.openecomp.aai.serialization.engines.TransactionalGraphEngine;
-//import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
+import org.openecomp.aai.serialization.queryformats.QueryFormatTestHelper;
import org.openecomp.aai.util.AAIConstants;
+
import com.thinkaurelius.titan.core.Cardinality;
import com.thinkaurelius.titan.core.TitanFactory;
import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanTransaction;
import com.thinkaurelius.titan.core.schema.TitanManagement;
@Ignore
@@ -72,7 +72,7 @@ public class VertexMergeTest {
private static TitanGraph graph;
private static EdgeRules rules;
private static GraphTraversalSource g;
- private static TitanTransaction tx;
+ private static Graph tx;
@BeforeClass
public static void setUp() throws NoSuchFieldException, SecurityException, Exception {
graph = TitanFactory.build().set("storage.backend","inmemory").open();
@@ -80,7 +80,7 @@ public class VertexMergeTest {
g = tx.traversal();
System.setProperty("AJSC_HOME", ".");
System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
-// QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
+ QueryFormatTestHelper.setFinalStatic(AAIConstants.class.getField("AAI_HOME_ETC_OXM"), "src/test/resources/org/openecomp/aai/introspection/");
loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
dbEngine = new TitanDBEngine(
queryStyle,
@@ -166,7 +166,7 @@ public class VertexMergeTest {
}
@AfterClass
public static void cleanUp() {
- tx.rollback();
+ tx.tx().rollback();
graph.close();
}
diff --git a/aai-resources/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java b/aai-resources/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java
new file mode 100644
index 0000000..f9a511a
--- /dev/null
+++ b/aai-resources/src/test/java/org/openecomp/aai/serialization/queryformats/QueryFormatTestHelper.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.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.openecomp.aai.serialization.queryformats;
+
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.IoCore;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.openecomp.aai.serialization.queryformats.utils.UrlBuilder;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.when;
+
+public class QueryFormatTestHelper {
+
+
+ public static final String testResources = "src/test/resources/org/openecomp/aai/serialization/queryformats/";
+ public static final String graphsonResources = "src/test/resources/org/openecomp/aai/serialization/queryformats/graphson/";
+
+
+ public static void mockPathed(UrlBuilder mock) throws AAIFormatVertexException {
+ Answer<String> answer = new Answer<String>() {
+ public String answer(InvocationOnMock invocation) throws Throwable {
+ Vertex v = invocation.getArgumentAt(0, Vertex.class);
+
+ return v.<String>property(AAIProperties.AAI_URI).orElse("urimissing");
+ }
+ };
+ when(mock.pathed(isA(Vertex.class))).thenAnswer(answer);
+
+ }
+
+ public static Graph loadGraphson(String fileName) throws IOException {
+ final Graph graph = TinkerGraph.open();
+ graph.io(IoCore.graphson()).readGraph(QueryFormatTestHelper.graphsonResources + fileName);
+
+ return graph;
+ }
+
+ public static void setFinalStatic(Field field, Object newValue) throws Exception {
+ field.setAccessible(true);
+ // remove final modifier from field
+ Field modifiersField = Field.class.getDeclaredField("modifiers");
+ modifiersField.setAccessible(true);
+ modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
+ field.set(null, newValue);
+ }
+
+}