Test bug fix and refactoring repeated code

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5467a33f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5467a33f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5467a33f

Branch: refs/heads/TINKERPOP-1897
Commit: 5467a33f2e17ad22b736effebede124556f049ed
Parents: 153238b
Author: Graff, Philip B <philip.gr...@jhuapl.edu>
Authored: Sun Jan 14 13:44:33 2018 -0500
Committer: Graff, Philip B <philip.gr...@jhuapl.edu>
Committed: Sun Feb 25 10:44:53 2018 -0500

----------------------------------------------------------------------
 .../process/computer/GraphComputerTest.java     | 28 +++++++++-----------
 1 file changed, 12 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5467a33f/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
index 785f03d..da0e53f 100644
--- 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
+++ 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
@@ -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";

Reply via email to