Test bug fix and refactoring repeated code
authorGraff, Philip B <Philip.Graff@jhuapl.edu>
Sun, 14 Jan 2018 18:44:33 +0000 (13:44 -0500)
committerGraff, Philip B <Philip.Graff@jhuapl.edu>
Sun, 25 Feb 2018 15:44:53 +0000 (10:44 -0500)
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java

index 785f03d..da0e53f 100644 (file)
@@ -2689,12 +2689,8 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
 
     @Test
     public void testMessagePassingIn() throws Exception {
-        runTest(Direction.BOTH).forEachRemaining(v -> {
-            assertEquals(2, v.keys().size());
-            assertTrue(v.keys().contains(VertexProgramR.PROPERTY_IN));
-            assertTrue(v.keys().contains(VertexProgramR.PROPERTY_OUT));
-            assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_IN)));
-            assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_OUT)));
+        runTest(Direction.IN).forEachRemaining(v -> {
+            vertexPropertyChecks(v);
             final String in = v.value(VertexProgramR.PROPERTY_IN);
             if (in.equals("a"))
                 assertEquals("ab", v.value(VertexProgramR.PROPERTY_OUT).toString());
@@ -2709,11 +2705,7 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
     @Test
     public void testMessagePassingOut() throws Exception {
         runTest(Direction.OUT).forEachRemaining(v -> {
-            assertEquals(2, v.keys().size());
-            assertTrue(v.keys().contains(VertexProgramR.PROPERTY_IN));
-            assertTrue(v.keys().contains(VertexProgramR.PROPERTY_OUT));
-            assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_IN)));
-            assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_OUT)));
+            vertexPropertyChecks(v);
             final String in = v.value(VertexProgramR.PROPERTY_IN);
             if (in.equals("a"))
                 assertEquals("a", v.value(VertexProgramR.PROPERTY_OUT).toString());
@@ -2728,11 +2720,7 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
     @Test
     public void testMessagePassingBoth() throws Exception {
         runTest(Direction.BOTH).forEachRemaining(v -> {
-            assertEquals(2, v.keys().size());
-            assertTrue(v.keys().contains(VertexProgramR.PROPERTY_IN));
-            assertTrue(v.keys().contains(VertexProgramR.PROPERTY_OUT));
-            assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_IN)));
-            assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_OUT)));
+            vertexPropertyChecks(v);
             final String in = v.value(VertexProgramR.PROPERTY_IN);
             if (in.equals("a"))
                 assertEquals("aab", v.value(VertexProgramR.PROPERTY_OUT).toString());
@@ -2754,6 +2742,14 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
         return result.graph().traversal().V();
     }
 
+    private static void vertexPropertyChecks(Vertex v) {
+        assertEquals(2, v.keys().size());
+        assertTrue(v.keys().contains(VertexProgramR.PROPERTY_IN));
+        assertTrue(v.keys().contains(VertexProgramR.PROPERTY_OUT));
+        assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_IN)));
+        assertEquals(1, IteratorUtils.count(v.values(VertexProgramR.PROPERTY_OUT)));
+    }
+
     private static class VertexProgramR implements VertexProgram<String> {
         private static final String SIMPLE_VERTEX_PROGRAM_CFG_PREFIX = "gremlin.simpleVertexProgram";
         private static final String PROPERTY_OUT = "propertyout";