AAI-1523 Batch reformat aai-core
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / serialization / queryformats / QueryFormatTestHelper.java
index 609de5f..f05e36d 100644 (file)
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.aai.serialization.queryformats;
 
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.IoCore;
@@ -29,46 +37,38 @@ import org.onap.aai.db.props.AAIProperties;
 import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
 import org.onap.aai.serialization.queryformats.utils.UrlBuilder;
 
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
+public class QueryFormatTestHelper {
 
-import static org.mockito.Matchers.isA;
-import static org.mockito.Mockito.when;
+    public static final String testResources = "src/test/resources/org.onap.aai/serialization/queryformats/";
+    public static final String graphsonResources =
+            "src/test/resources/org.onap.aai/serialization/queryformats/graphson/";
 
-public class QueryFormatTestHelper {
+    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);
 
-       
-       public static final String testResources = "src/test/resources/org.onap.aai/serialization/queryformats/";
-       public static final String graphsonResources = "src/test/resources/org.onap.aai/serialization/queryformats/graphson/";
+        return graph;
+    }
 
-       
-       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 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);
+    }
 
-       }
-       
-       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);
-       }
-       
 }