tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject tinkerpop git commit: TINKERPOP-1967 Rewrote connectedComponent() test to be more GLV friendly
Date Thu, 09 Aug 2018 15:26:33 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1967 cbae0a300 -> 2cc2aed50


TINKERPOP-1967 Rewrote connectedComponent() test to be more GLV friendly


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

Branch: refs/heads/TINKERPOP-1967
Commit: 2cc2aed50d95f0f943fb012b421d4bcd0761a24d
Parents: cbae0a3
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Aug 9 11:25:55 2018 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Aug 9 11:25:55 2018 -0400

----------------------------------------------------------------------
 .../step/map/ConnectedComponentTest.java        | 70 +++++++++-----------
 1 file changed, 30 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2cc2aed5/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConnectedComponentTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConnectedComponentTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConnectedComponentTest.java
index 3133382..a542bed 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConnectedComponentTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConnectedComponentTest.java
@@ -19,13 +19,15 @@
 package org.apache.tinkerpop.gremlin.process.traversal.step.map;
 
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
-import org.apache.tinkerpop.gremlin.process.computer.clustering.connected.ConnectedComponentVertexProgram;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ConnectedComponent;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
 
+import java.util.Map;
+
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.bothE;
 import static org.junit.Assert.assertEquals;
@@ -35,55 +37,43 @@ import static org.junit.Assert.assertEquals;
  */
 public abstract class ConnectedComponentTest extends AbstractGremlinProcessTest {
 
-    public abstract Traversal<Vertex, Vertex> get_g_V_connectedComponent();
+    public abstract Traversal<Vertex, Vertex> get_g_V_connectedComponent_hasXcomponentX();
 
-    public abstract Traversal<Vertex, Vertex> get_g_V_hasLabelXsoftwareX_connectedComponent();
+    public abstract Traversal<Vertex, Map<String,Object>> get_g_V_hasLabelXsoftwareX_connectedComponent_project_byXnameX_byXcomponentX();
 
-    public abstract Traversal<Vertex, Vertex> get_g_V_dedup_connectedComponent();
+    public abstract Traversal<Vertex, Vertex> get_g_V_dedup_connectedComponent_hasXcomponentX();
 
-    public abstract Traversal<Vertex, Vertex> get_g_V_connectedComponent_withXedges_bothEXknowsXX_withXpropertyName_clusterX();
+    public abstract Traversal<Vertex, Map<String,Object>> get_g_V_connectedComponent_withXedges_bothEXknowsXX_withXpropertyName_clusterX_project_byXnameX_byXclusterX();
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_connectedComponent() {
-        final Traversal<Vertex, Vertex> traversal = get_g_V_connectedComponent();
+    public void g_V_connectedComponent_hasXcomponentX() {
+        final Traversal<Vertex, Vertex> traversal = get_g_V_connectedComponent_hasXcomponentX();
         printTraversalForm(traversal);
-        int counter = 0;
-        while (traversal.hasNext()) {
-            final Vertex vertex = traversal.next();
-            counter++;
-            assertEquals("1", vertex.value(ConnectedComponentVertexProgram.COMPONENT));
-        }
-        assertEquals(6, counter);
+        assertEquals(6, IteratorUtils.count(traversal));
     }
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_dedup_connectedComponent() {
-        final Traversal<Vertex, Vertex> traversal = get_g_V_dedup_connectedComponent();
+    public void g_V_dedup_connectedComponent_hasXcomponentX() {
+        final Traversal<Vertex, Vertex> traversal = get_g_V_dedup_connectedComponent_hasXcomponentX();
         printTraversalForm(traversal);
-        int counter = 0;
-        while (traversal.hasNext()) {
-            final Vertex vertex = traversal.next();
-            counter++;
-            assertEquals("1", vertex.value(ConnectedComponentVertexProgram.COMPONENT));
-        }
-        assertEquals(6, counter);
+        assertEquals(6, IteratorUtils.count(traversal));
     }
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_hasLabelXsoftwareX_connectedComponent() {
-        final Traversal<Vertex, Vertex> traversal = get_g_V_hasLabelXsoftwareX_connectedComponent();
+    public void g_V_hasLabelXsoftwareX_connectedComponent_project_byXnameX_byXcomponentX()
{
+        final Traversal<Vertex, Map<String,Object>> traversal = get_g_V_hasLabelXsoftwareX_connectedComponent_project_byXnameX_byXcomponentX();
         printTraversalForm(traversal);
         int counter = 0;
         while (traversal.hasNext()) {
-            final Vertex vertex = traversal.next();
-            final String name = vertex.value("name");
+            final Map<String,Object> m = traversal.next();
+            final String name = m.get("name").toString();
             switch (name) {
                 case "lop":
                 case "ripple":
-                    assertEquals("1", vertex.value(ConnectedComponentVertexProgram.COMPONENT));
+                    assertEquals(convertToVertexId("marko").toString(), m.get("component"));
                     break;
             }
             counter++;
@@ -93,21 +83,21 @@ public abstract class ConnectedComponentTest extends AbstractGremlinProcessTest
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_connectedComponent_withXEDGES_bothEXknowsXX_withXPROPERTY_NAME_clusterX()
{
-        final Traversal<Vertex, Vertex> traversal = get_g_V_connectedComponent_withXedges_bothEXknowsXX_withXpropertyName_clusterX();
+    public void g_V_connectedComponent_withXEDGES_bothEXknowsXX_withXPROPERTY_NAME_clusterX_project_byXnameX_byXclusterX()
{
+        final Traversal<Vertex, Map<String,Object>> traversal = get_g_V_connectedComponent_withXedges_bothEXknowsXX_withXpropertyName_clusterX_project_byXnameX_byXclusterX();
         printTraversalForm(traversal);
         int counter = 0;
         while (traversal.hasNext()) {
-            final Vertex vertex = traversal.next();
-            final String name = vertex.value("name");
+            final Map<String,Object> m = traversal.next();
+            final String name = m.get("name").toString();
             switch (name) {
                 case "marko":
                 case "vadas":
                 case "josh":
-                    assertEquals("1", vertex.value("cluster"));
+                    assertEquals(convertToVertexId("marko").toString(), m.get("cluster"));
                     break;
                 case "peter":
-                    assertEquals("6", vertex.value("cluster"));
+                    assertEquals(convertToVertexId("peter").toString(), m.get("cluster"));
                     break;
             }
             counter++;
@@ -117,22 +107,22 @@ public abstract class ConnectedComponentTest extends AbstractGremlinProcessTest
 
     public static class Traversals extends ConnectedComponentTest {
         @Override
-        public Traversal<Vertex, Vertex> get_g_V_connectedComponent() {
+        public Traversal<Vertex, Vertex> get_g_V_connectedComponent_hasXcomponentX()
{
             return g.V().connectedComponent();
         }
 
         @Override
-        public Traversal<Vertex, Vertex> get_g_V_dedup_connectedComponent() {
+        public Traversal<Vertex, Vertex> get_g_V_dedup_connectedComponent_hasXcomponentX()
{
             return g.V().dedup().connectedComponent();
         }
 
         @Override
-        public Traversal<Vertex, Vertex> get_g_V_hasLabelXsoftwareX_connectedComponent()
{
-            return g.V().hasLabel("software").connectedComponent();
+        public Traversal<Vertex, Map<String,Object>> get_g_V_hasLabelXsoftwareX_connectedComponent_project_byXnameX_byXcomponentX()
{
+            return g.V().hasLabel("software").connectedComponent().project("name","component").by("name").by(ConnectedComponent.component);
         }
         @Override
-        public Traversal<Vertex, Vertex> get_g_V_connectedComponent_withXedges_bothEXknowsXX_withXpropertyName_clusterX()
{
-            return g.V().hasLabel("person").connectedComponent().with(ConnectedComponent.edges,
bothE("knows")).with(ConnectedComponent.propertyName, "cluster");
+        public Traversal<Vertex, Map<String,Object>> get_g_V_connectedComponent_withXedges_bothEXknowsXX_withXpropertyName_clusterX_project_byXnameX_byXclusterX()
{
+            return g.V().hasLabel("person").connectedComponent().with(ConnectedComponent.edges,
bothE("knows")).with(ConnectedComponent.propertyName, "cluster").project("name","cluster").by("name").by("cluster");
         }
     }
 }


Mime
View raw message