You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/10/03 18:20:46 UTC

[01/26] tinkerpop git commit: CTR: Download Hadoop from Apache release archives, if the requested version is not available on the download mirrors. [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1784 4a421d4eb -> 8ed815cbf (forced update)


CTR: Download Hadoop from Apache release archives, if the requested version is not available on the download mirrors.


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

Branch: refs/heads/TINKERPOP-1784
Commit: 7b0bd95745aa6960fdbcafcd7e45cb2c1e499548
Parents: e509b6b
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Mon Oct 2 09:56:45 2017 -0700
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Mon Oct 2 09:56:45 2017 -0700

----------------------------------------------------------------------
 docker/hadoop/install.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7b0bd957/docker/hadoop/install.sh
----------------------------------------------------------------------
diff --git a/docker/hadoop/install.sh b/docker/hadoop/install.sh
index 29dd9e1..5b61519 100755
--- a/docker/hadoop/install.sh
+++ b/docker/hadoop/install.sh
@@ -24,9 +24,10 @@ HADOOP_BASENAME="hadoop-${HADOOP_VERSION}"
 
 APACHE_MIRROR=$(curl -s http://www.apache.org/dyn/closer.cgi | grep -o '<a href=".*"><strong>' | cut -f2 -d '"' | head -n1)
 HADOOP_DOWNLOAD_URL="${APACHE_MIRROR}hadoop/common/${HADOOP_BASENAME}/${HADOOP_BASENAME}.tar.gz"
+ALT_HADOOP_DOWNLOAD_URL="https://archive.apache.org/dist/hadoop/common/${HADOOP_BASENAME}/${HADOOP_BASENAME}.tar.gz"
 
 pushd /usr/local/lib > /dev/null
-curl ${HADOOP_DOWNLOAD_URL} | tar xz
+(curl -f ${HADOOP_DOWNLOAD_URL} || curl ${ALT_HADOOP_DOWNLOAD_URL}) | tar xz
 popd > /dev/null
 
 cat >> ~/.bashrc <<EOF


[11/26] tinkerpop git commit: TINKERPOP-1784 Provided translation for python specific syntax

Posted by sp...@apache.org.
TINKERPOP-1784 Provided translation for python specific syntax

Included a way to specify element identifiers in feature files.


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

Branch: refs/heads/TINKERPOP-1784
Commit: 6c60bd1a7cf52c353961ec4f3cfa3e52675cf1c5
Parents: 30422e7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 27 12:16:08 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py        | 17 +++++++++++++----
 gremlin-test/features/filter/Has.feature           | 13 +++++++++++++
 gremlin-test/features/map/Select.feature           |  2 +-
 3 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c60bd1a/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 8ef0f1b..989e781 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -25,6 +25,8 @@ from gremlin_python.process.traversal import P, Scope, Column
 from radish import given, when, then
 from hamcrest import *
 
+regex_as = re.compile(r"\.as\(")
+regex_in = re.compile(r"\.in\(")
 
 @given("the {graph_name:w} graph")
 def choose_graph(step, graph_name):
@@ -52,7 +54,7 @@ def translate_traversal(step):
     if hasattr(step.context, "traversal_params"):
         b.update(step.context.traversal_params)
 
-    step.context.traversal = eval(step.text, b)
+    step.context.traversal = eval(__translate(step.text), b)
 
 
 @when("iterated to list")
@@ -78,9 +80,11 @@ def __convert(val, ctx):
         for key, value in val.items():
             n[__convert(key, ctx)] = __convert(value, ctx)
         return n
-    elif isinstance(val, (str, unicode)) and re.match("d\[.*\]", val):
+    elif isinstance(val, (str, unicode)) and re.match("^d\[.*\]$", val):
         return long(val[2:-1])
-    elif isinstance(val, (str, unicode)) and re.match("v\[.*\]", val):
+    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]\.id$", val):
+        return ctx.lookup["modern"][val[2:-4]].id
+    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]$", val):
         return ctx.lookup["modern"][val[2:-1]]
     elif isinstance(val, unicode):
         return val.encode('utf-8')
@@ -141,4 +145,9 @@ def __unordered_assertion(step):
         else:
             raise ValueError("unknown type of " + line[0])
 
-    assert_that(len(results_to_test), is_(0))
\ No newline at end of file
+    assert_that(len(results_to_test), is_(0))
+
+
+def __translate(traversal):
+    replaced = regex_as.sub(".as_(", traversal)
+    return regex_in.sub(".in_(", replaced)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c60bd1a/gremlin-test/features/filter/Has.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Has.feature b/gremlin-test/features/filter/Has.feature
index 0bb82e0..4a2e085 100644
--- a/gremlin-test/features/filter/Has.feature
+++ b/gremlin-test/features/filter/Has.feature
@@ -28,3 +28,16 @@ Feature: Step - has()
       | vertex | josh   |
       | vertex | peter  |
 
+  Scenario: Use hasId() with P
+    Given the modern graph
+    And using the parameter v1 is "v[marko].id"
+    And the traversal of
+    """
+    g.V().in().hasId(P.neq(v1))
+    """
+    When iterated to list
+    Then the result should be unordered
+      | vertex | josh   |
+      | vertex | josh   |
+      | vertex | peter  |
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c60bd1a/gremlin-test/features/map/Select.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature
index e64417a..b2d208c 100644
--- a/gremlin-test/features/map/Select.feature
+++ b/gremlin-test/features/map/Select.feature
@@ -22,7 +22,7 @@ Feature: Step - select()
     And using the parameter v1 is "v[marko]"
     And the traversal of
       """
-      g.V(v1).as_("a").out("knows").as_("b").select("a", "b")
+      g.V(v1).as("a").out("knows").as("b").select("a", "b")
       """
     When iterated to list
     Then the result should be unordered


[06/26] tinkerpop git commit: TINKERPOP-1784 Categorize feature by step type

Posted by sp...@apache.org.
TINKERPOP-1784 Categorize feature by step type

This matches he pattern of the java test suite.


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

Branch: refs/heads/TINKERPOP-1784
Commit: aea5a63ff465882c213dd2641d01c1e4b8fe1ddb
Parents: 58a7743
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 20 13:39:00 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:51 2017 -0400

----------------------------------------------------------------------
 gremlin-test/features/Count.feature     | 54 ----------------------------
 gremlin-test/features/map/Count.feature | 54 ++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aea5a63f/gremlin-test/features/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/Count.feature b/gremlin-test/features/Count.feature
deleted file mode 100644
index 383eecf..0000000
--- a/gremlin-test/features/Count.feature
+++ /dev/null
@@ -1,54 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-Feature: Count Step
-
-  Scenario: Count all vertices
-    Given the modern graph
-    And the traversal of
-    """
-    g.V().count()
-    """
-    When iterating
-    Then the result should be 6
-
-  Scenario: Count vertices after traversing both() twice
-    Given the modern graph
-    And the traversal of
-    """
-    g.V().both().both().count()
-    """
-    When iterating
-    Then the result should be 30
-
-  Scenario: Count local
-    Given the modern graph
-    And the traversal of
-    """
-    g.V().fold().count(Scope.local)
-    """
-    When iterating
-    Then the result should be 6
-
-  Scenario: Count no vertices
-    Given the modern graph
-    And the traversal of
-    """
-    g.V().has("no").count()
-    """
-    When iterating
-    Then the result should be 0
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aea5a63f/gremlin-test/features/map/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Count.feature b/gremlin-test/features/map/Count.feature
new file mode 100644
index 0000000..383eecf
--- /dev/null
+++ b/gremlin-test/features/map/Count.feature
@@ -0,0 +1,54 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Count Step
+
+  Scenario: Count all vertices
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().count()
+    """
+    When iterating
+    Then the result should be 6
+
+  Scenario: Count vertices after traversing both() twice
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().both().both().count()
+    """
+    When iterating
+    Then the result should be 30
+
+  Scenario: Count local
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().fold().count(Scope.local)
+    """
+    When iterating
+    Then the result should be 6
+
+  Scenario: Count no vertices
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().has("no").count()
+    """
+    When iterating
+    Then the result should be 0
\ No newline at end of file


[23/26] tinkerpop git commit: TINKERPOP-1784 Added some more vertex features

Posted by sp...@apache.org.
TINKERPOP-1784 Added some more vertex features


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

Branch: refs/heads/TINKERPOP-1784
Commit: 6325c4a3d18ec0e1479d138af96c14bfbbd9b3a4
Parents: dd4ca8b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 29 13:26:27 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 gremlin-test/features/map/Vertex.feature | 105 ++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6325c4a3/gremlin-test/features/map/Vertex.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Vertex.feature b/gremlin-test/features/map/Vertex.feature
index 9aa506c..1905f3a 100644
--- a/gremlin-test/features/map/Vertex.feature
+++ b/gremlin-test/features/map/Vertex.feature
@@ -169,3 +169,108 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       | e[josh-created->lop] |
       | e[josh-created->ripple] |
       | e[marko-knows->josh] |
+
+  Scenario: g_VX1X_outE_inV
+    Given the modern graph
+    And using the parameter v1 is "v[marko]"
+    And the traversal of
+      """
+      g.V(v1).both()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |
+      | v[josh] |
+      | v[lop] |
+
+  Scenario: g_VX2X_inE_outV
+    Given the modern graph
+    And using the parameter v2 is "v[vadas]"
+    And the traversal of
+      """
+      g.V(v2).inE().outV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[marko] |
+
+  Scenario: g_V_outE_hasXweight_1X_outV
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().outE().has("weight",1.0).outV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[marko] |
+      | v[josh] |
+
+  Scenario: g_V_out_outE_inV_inE_inV_both_name
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().out().outE().inV().inE().inV().both().values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | marko |
+      | marko |
+      | marko |
+      | josh |
+      | josh |
+      | josh |
+      | josh |
+      | peter |
+      | peter |
+      | peter |
+
+  Scenario: g_VX1X_outEXknowsX_bothV_name
+    Given the modern graph
+    And using the parameter v1 is "v[marko]"
+    And the traversal of
+      """
+      g.V(v1).outE("knows").bothV().values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | marko |
+      | marko |
+      | josh |
+      | vadas |
+
+  Scenario: g_VX1X_outE_otherV
+    Given the modern graph
+    And using the parameter v1 is "v[marko]"
+    And the traversal of
+      """
+      g.V(v1).outE().otherV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |
+      | v[josh] |
+      | v[lop] |
+
+  Scenario: g_VX4X_bothE_otherV
+    Given the modern graph
+    And using the parameter v4 is "v[josh]"
+    And the traversal of
+      """
+      g.V(v4).bothE().otherV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[marko] |
+      | v[ripple] |
+      | v[lop] |
+
+  Scenario: g_VX4X_bothE_hasXweight_lt_1X_otherV
+    Given the modern graph
+    And using the parameter v4 is "v[josh]"
+    And the traversal of
+      """
+      g.V(v4).bothE().has("weight", P.lt(1.0)).otherV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[lop] |
\ No newline at end of file


[20/26] tinkerpop git commit: TINKERPOP-1784 Deleted some dead code

Posted by sp...@apache.org.
TINKERPOP-1784 Deleted some dead code


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

Branch: refs/heads/TINKERPOP-1784
Commit: 1926dc45089ba441940cc4117ae668a7b7cf69bc
Parents: 9a15c43
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 28 15:30:54 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py           | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1926dc45/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 2db5922..e3b82c3 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -76,12 +76,12 @@ def assert_result(step, characterized_as):
 
 
 def __convert(val, ctx):
-    if isinstance(val, dict):                                                    # convert dictionary keys/values
+    if isinstance(val, dict):                                         # convert dictionary keys/values
         n = {}
         for key, value in val.items():
             n[__convert(key, ctx)] = __convert(value, ctx)
         return n
-    elif isinstance(val, unicode):
+    elif isinstance(val, unicode):                                    # stupid unicode/string nonsense in py 2/x
         return __convert(val.encode('utf-8'), ctx)
     elif isinstance(val, str) and re.match("^l\[.*\]$", val):         # parse list
         return list(map((lambda x: __convert(x, ctx)), val[2:-1].split(",")))
@@ -100,16 +100,6 @@ def __convert(val, ctx):
     else:
         return val
 
-#
-# def __ordered_assertion(data, result, ctx):
-#     # results from traversal should have the same number of entries as the feature data table
-#     assert_that(len(result), equal_to(len(data)))
-#
-#     # assert the results in order they are expected in the data from the features file
-#     for ix, line in enumerate(data):
-#         assert_that(result[ix], equal_to(__convert(line[0], ctx)))
-#
-
 
 def __table_assertion(data, result, ctx, ordered):
     # results from traversal should have the same number of entries as the feature data table


[22/26] tinkerpop git commit: TINKERPOP-1784 Added some more vertex tests

Posted by sp...@apache.org.
TINKERPOP-1784 Added some more vertex tests


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

Branch: refs/heads/TINKERPOP-1784
Commit: 97f6ae6df229ebf325b15f732783cbb6df68498e
Parents: 9396092
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 28 10:29:47 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 gremlin-test/features/map/Vertex.feature | 70 +++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/97f6ae6d/gremlin-test/features/map/Vertex.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Vertex.feature b/gremlin-test/features/map/Vertex.feature
index fbd4168..5bed2a6 100644
--- a/gremlin-test/features/map/Vertex.feature
+++ b/gremlin-test/features/map/Vertex.feature
@@ -73,10 +73,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX2X_in
     Given the modern graph
-    And using the parameter v1 is "v[vadas]"
+    And using the parameter v2 is "v[vadas]"
     And the traversal of
       """
-      g.V(v1).in()
+      g.V(v2).in()
       """
     When iterated to list
     Then the result should be unordered
@@ -84,10 +84,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX4X_both
     Given the modern graph
-    And using the parameter v1 is "v[josh]"
+    And using the parameter v4 is "v[josh]"
     And the traversal of
       """
-      g.V(v1).both()
+      g.V(v4).both()
       """
     When iterated to list
     Then the result should be unordered
@@ -108,4 +108,64 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       | edge | marko-knows->vadas |
       | edge | peter-created->lop |
       | edge | josh-created->lop |
-      | edge | josh-created->ripple |
\ No newline at end of file
+      | edge | josh-created->ripple |
+
+  Scenario: g_EX11X
+    Given the modern graph
+    And using the parameter e11 is "e[josh-created->lop]"
+    And the traversal of
+    """
+      g.E(e11)
+      """
+    When iterated to list
+    Then the result should be unordered
+      | edge | josh-created->lop |
+
+  Scenario: g_VX1X_outE
+    Given the modern graph
+    And using the parameter v1 is "v[marko]"
+    And the traversal of
+    """
+      g.V(v1).outE()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | edge | marko-created->lop |
+      | edge | marko-knows->josh |
+      | edge | marko-knows->vadas |
+
+  Scenario: g_VX2X_outE
+    Given the modern graph
+    And using the parameter v2 is "v[vadas]"
+    And the traversal of
+    """
+      g.V(v2).inE()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | edge | marko-knows->vadas |
+
+  Scenario: g_VX4X_bothEXcreatedX
+    Given the modern graph
+    And using the parameter v4 is "v[josh]"
+    And the traversal of
+    """
+      g.V(v4).bothE("created")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | edge | josh-created->lop |
+      | edge | josh-created->ripple |
+
+  Scenario: g_VX4X_bothE
+    Given the modern graph
+    And using the parameter v4 is "v[josh]"
+    And the traversal of
+    """
+      g.V(v4).bothE()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | edge | josh-created->lop |
+      | edge | josh-created->ripple |
+      | edge | marko-knows->josh |


[17/26] tinkerpop git commit: TINKERPOP-1784 Included grateful graph and cached remotes/data

Posted by sp...@apache.org.
TINKERPOP-1784 Included grateful graph and cached remotes/data

Tests should be faster now that remotes and data are cached for the toy graphs.


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

Branch: refs/heads/TINKERPOP-1784
Commit: dd4ca8b2e0bbdc8ce3d8cc177f3bc18097c89be1
Parents: 21ccccd
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 29 11:54:33 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/terrain.py           | 66 +++++++++++++++-----
 1 file changed, 49 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dd4ca8b2/gremlin-python/src/main/jython/radish/terrain.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/terrain.py b/gremlin-python/src/main/jython/radish/terrain.py
index e88272b..5897852 100644
--- a/gremlin-python/src/main/jython/radish/terrain.py
+++ b/gremlin-python/src/main/jython/radish/terrain.py
@@ -21,7 +21,7 @@ import re
 from gremlin_python.structure.graph import Graph
 from gremlin_python.process.graph_traversal import __
 from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
-from radish import before, after
+from radish import before, after, world
 
 outV = __.outV
 label = __.label
@@ -30,16 +30,38 @@ project = __.project
 tail = __.tail
 
 
-@before.each_scenario
-def prepare_traversal_source(scenario):
-    scenario.context.remote_conn = {}
-    scenario.context.lookup_v = {}
-    scenario.context.lookup_e = {}
+@before.all
+def prepare_static_traversal_source(features, marker):
+    # as the various traversal sources for testing do not change their data, there is no need to re-create remotes
+    # and client side lookup data over and over. it can be created once for all tests and be reused.
+    cache = {}
+    for graph_name in (("modern", "gmodern"), ("classic", "gclassic"), ("crew", "gcrew"), ("grateful", "ggrateful")):
+        cache[graph_name[0]] = {}
+        remote = __create_remote(graph_name[1])
+        cache[graph_name[0]]["remote_conn"] = __create_remote(graph_name[1])
+        cache[graph_name[0]]["lookup_v"] = __create_lookup_v(remote)
+        cache[graph_name[0]]["lookup_e"] = __create_lookup_e(remote)
+
+    # store the cache on the global context so that remotes can be shutdown cleanly at the end of the tests
+    world.cache = cache
+
+    # iterate each feature and apply the cached remotes/lookups to each scenario context so that they are
+    # accessible to the feature steps for test logic
+    for feature in features:
+        for scenario in feature.all_scenarios:
+            scenario.context.remote_conn = {}
+            scenario.context.lookup_v = {}
+            scenario.context.lookup_e = {}
 
-    __prepare(scenario, "modern", "gmodern")
-    __prepare(scenario, "classic", "gclassic")
-    __prepare(scenario, "crew", "gcrew")
+            for graph_name in ("modern", "classic", "crew", "grateful"):
+                scenario.context.remote_conn[graph_name] = cache[graph_name]["remote_conn"]
+                scenario.context.lookup_v[graph_name] = cache[graph_name]["lookup_v"]
+                scenario.context.lookup_e[graph_name] = cache[graph_name]["lookup_e"]
 
+
+@before.each_scenario
+def prepare_traversal_source(scenario):
+    # some tests create data - create a fresh remote to the empty graph and clear that graph prior to each test
     remote = DriverRemoteConnection('ws://localhost:45940/gremlin', "ggraph")
     scenario.context.remote_conn["empty"] = remote
     g = Graph().traversal().withRemote(remote)
@@ -48,18 +70,28 @@ def prepare_traversal_source(scenario):
 
 @after.each_scenario
 def close_traversal_source(scenario):
-    scenario.context.remote_conn["modern"].close()
-    scenario.context.remote_conn["classic"].close()
-    scenario.context.remote_conn["crew"].close()
+    scenario.context.remote_conn["empty"].close()
 
 
-def __prepare(scenario, graph_name, server_graph_name):
-    remote = DriverRemoteConnection('ws://localhost:45940/gremlin', server_graph_name)
-    scenario.context.remote_conn[graph_name] = remote
+@after.all
+def close_static_traversal_source(features, marker):
+    for key, value in world.cache.iteritems():
+        value["remote_conn"].close()
+
+
+def __create_remote(server_graph_name):
+    return DriverRemoteConnection('ws://localhost:45940/gremlin', server_graph_name)
+
+
+def __create_lookup_v(remote):
     g = Graph().traversal().withRemote(remote)
 
     # hold a map of name/vertex for use in asserting results
-    scenario.context.lookup_v[graph_name] = g.V().group().by('name').by(tail()).next()
+    return g.V().group().by('name').by(tail()).next()
+
+
+def __create_lookup_e(remote):
+    g = Graph().traversal().withRemote(remote)
 
     # hold a map of the "name"/edge for use in asserting results - "name" in this context is in the form of
     # outgoingV-label->incomingV
@@ -79,4 +111,4 @@ def __prepare(scenario, graph_name, server_graph_name):
         i = re.search("i=(.+?)[,\}]", key).group(1)
         edges[o + "-" + l + "->" + i] = value
 
-    scenario.context.lookup_e[graph_name] = edges
+    return edges


[07/26] tinkerpop git commit: TINKERPOP-1784 Use python eval() to setup test traversals

Posted by sp...@apache.org.
TINKERPOP-1784 Use python eval() to setup test traversals


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

Branch: refs/heads/TINKERPOP-1784
Commit: 58a77430474635ddc900b75cf35b1c16b1bca6cf
Parents: a4b552f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 20 13:32:54 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:51 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/count_features_step.py        | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/58a77430/gremlin-python/src/main/jython/radish/count_features_step.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/count_features_step.py b/gremlin-python/src/main/jython/radish/count_features_step.py
index 324c29c..ec04551 100644
--- a/gremlin-python/src/main/jython/radish/count_features_step.py
+++ b/gremlin-python/src/main/jython/radish/count_features_step.py
@@ -34,16 +34,7 @@ def choose_graph(step, graphName):
 @given("the traversal of")
 def translate_traversal(step):
     g = step.context.g
-    if step.text == "g.V().count()":
-        step.context.traversal = g.V().count()
-    elif step.text == "g.V().both().both().count()":
-        step.context.traversal = g.V().both().both().count()
-    elif step.text == "g.V().fold().count(Scope.local)":
-        step.context.traversal = g.V().fold().count(Scope.local)
-    elif step.text == "g.V().has(\"no\").count()":
-        step.context.traversal = g.V().has("no").count()
-    else:
-        raise ValueError("Gremlin translation to python not found - missing: " + step.text)
+    step.context.traversal = eval(step.text, {"g": g, "Scope": Scope})
 
 
 @when("iterating")


[21/26] tinkerpop git commit: TINKERPOP-1784 Added support for numeric keys in glv tests

Posted by sp...@apache.org.
TINKERPOP-1784 Added support for numeric keys in glv tests


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

Branch: refs/heads/TINKERPOP-1784
Commit: 3237fbe090cb93ccf3bc55d4c70cf35ea687f073
Parents: 959656f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 22 14:43:13 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 gremlin-python/src/main/jython/radish/feature_steps.py | 10 ++++++----
 gremlin-test/features/sideEffect/GroupCount.feature    | 10 ++++++++++
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3237fbe0/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 19da3ec..35103f3 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -25,8 +25,6 @@ from gremlin_python.process.traversal import P, Scope, Column
 from radish import given, when, then
 from hamcrest import *
 
-out = __.out
-
 
 @given("the {graph_name:w} graph")
 def choose_graph(step, graph_name):
@@ -40,7 +38,8 @@ def translate_traversal(step):
     step.context.traversal = eval(step.text, {"g": g,
                                               "Column": Column,
                                               "P": P,
-                                              "Scope": Scope})
+                                              "Scope": Scope,
+                                              "bothE": __.bothE})
 
 
 @when("iterated to list")
@@ -49,9 +48,12 @@ def iterate_the_traversal(step):
 
 
 def __convert(m, ctx):
+    # transform string map keys from the test spec to numbers when it encounters the appropriate patterns
     n = {}
     for key, value in m.items():
-        if isinstance(key, str) and re.match("v\[.*\]", key):
+        if re.match("d\[.*\]", key):
+            n[long(key[2:-1])] = value
+        elif re.match("v\[.*\]", key):
             n[ctx.lookup["modern"][key[2:-1]]] = value
         else:
             n[key] = value

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3237fbe0/gremlin-test/features/sideEffect/GroupCount.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/GroupCount.feature b/gremlin-test/features/sideEffect/GroupCount.feature
index d8d5b51..7b4a0a6 100644
--- a/gremlin-test/features/sideEffect/GroupCount.feature
+++ b/gremlin-test/features/sideEffect/GroupCount.feature
@@ -27,6 +27,16 @@ Feature: Step - groupCount()
     Then the result should be ordered
       | map | {"ripple": 1, "lop": 3} |
 
+  Scenario: Edge count distribution
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().groupCount().by(bothE().count())
+      """
+    When iterated to list
+    Then the result should be ordered
+      | map | {"d[1]": 3, "d[3]": 3} |
+
   Scenario: Group count vertices, cap to retrieve the map and unfold it to group count again
     Given the modern graph
     And the traversal of


[16/26] tinkerpop git commit: TINKERPOP-1784 Added edge assertion support

Posted by sp...@apache.org.
TINKERPOP-1784 Added edge assertion support


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

Branch: refs/heads/TINKERPOP-1784
Commit: 9396092c098b2f8485a86574d317ea761275017a
Parents: 5aa64a0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 27 16:18:14 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     |  28 +++--
 .../src/main/jython/radish/terrain.py           |  29 ++++-
 gremlin-test/features/map/Vertex.feature        | 111 +++++++++++++++++++
 3 files changed, 160 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9396092c/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 989e781..2154536 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -28,6 +28,7 @@ from hamcrest import *
 regex_as = re.compile(r"\.as\(")
 regex_in = re.compile(r"\.in\(")
 
+
 @given("the {graph_name:w} graph")
 def choose_graph(step, graph_name):
     # only have modern atm but graphName would be used to select the right one
@@ -75,17 +76,23 @@ def assert_result(step, characterized_as):
 
 
 def __convert(val, ctx):
-    if isinstance(val, dict):
+    if isinstance(val, dict):                                                    # convert dictionary keys/values
         n = {}
         for key, value in val.items():
             n[__convert(key, ctx)] = __convert(value, ctx)
         return n
-    elif isinstance(val, (str, unicode)) and re.match("^d\[.*\]$", val):
+    elif isinstance(val, (str, unicode)) and re.match("^l\[.*\]$", val):         # parse list
+        return list(map((lambda x: __convert(x, ctx)), val[2:-1].split(",")))
+    elif isinstance(val, (str, unicode)) and re.match("^d\[.*\]$", val):         # parse numeric
         return long(val[2:-1])
-    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]\.id$", val):
-        return ctx.lookup["modern"][val[2:-4]].id
-    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]$", val):
-        return ctx.lookup["modern"][val[2:-1]]
+    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]\.id$", val):     # parse vertex id
+        return ctx.lookup_v["modern"][val[2:-4]].id
+    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]$", val):         # parse vertex
+        return ctx.lookup_v["modern"][val[2:-1]]
+    elif isinstance(val, (str, unicode)) and re.match("^e\[.*\]\.id$", val):     # parse edge id
+        return ctx.lookup_e["modern"][val[2:-4]].id
+    elif isinstance(val, (str, unicode)) and re.match("^e\[.*\]$", val):         # parse edge
+        return ctx.lookup_e["modern"][val[2:-1]]
     elif isinstance(val, unicode):
         return val.encode('utf-8')
     else:
@@ -108,6 +115,8 @@ def __ordered_assertion(step):
             assert_that(str(step.context.result[ix]), equal_to(str(line[1])))
         elif line[0] == "vertex":
             assert_that(step.context.result[ix].label, equal_to(line[1]))
+        elif line[0] == "edge":
+            assert_that(step.context.result[ix].label, equal_to(line[1]))
         elif line[0] == "map":
             assert_that(__convert(step.context.result[ix], step.context), json.loads(line[1]))
         else:
@@ -135,9 +144,14 @@ def __unordered_assertion(step):
             results_to_test.remove(val)
         elif line[0] == "vertex":
             val = str(line[1])
-            v = step.context.lookup["modern"][val]
+            v = step.context.lookup_v["modern"][val]
             assert_that(v, is_in(results_to_test))
             results_to_test.remove(v)
+        elif line[0] == "edge":
+            val = str(line[1])
+            e = step.context.lookup_e["modern"][val]
+            assert_that(e, is_in(results_to_test))
+            results_to_test.remove(e)
         elif line[0] == "map":
             val = __convert(json.loads(line[1]), step.context)
             assert_that(val, is_in(results_to_test))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9396092c/gremlin-python/src/main/jython/radish/terrain.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/terrain.py b/gremlin-python/src/main/jython/radish/terrain.py
index 59ec8d0..303f64d 100644
--- a/gremlin-python/src/main/jython/radish/terrain.py
+++ b/gremlin-python/src/main/jython/radish/terrain.py
@@ -17,11 +17,18 @@ specific language governing permissions and limitations
 under the License.
 '''
 
+import re
 from gremlin_python.structure.graph import Graph
 from gremlin_python.process.graph_traversal import __
 from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
 from radish import before, after
 
+outV = __.outV
+label = __.label
+inV = __.inV
+project = __.project
+tail = __.tail
+
 
 @before.each_scenario
 def prepare_traversal_source(scenario):
@@ -30,7 +37,27 @@ def prepare_traversal_source(scenario):
     g = Graph().traversal().withRemote(remote)
 
     # hold a map of name/vertex for use in asserting results
-    scenario.context.lookup = {"modern": g.V().group().by('name').by(__.tail()).next()}
+    scenario.context.lookup_v = {"modern": g.V().group().by('name').by(tail()).next()}
+
+    # hold a map of the "name"/edge for use in asserting results - "name" in this context is in the form of
+    # outgoingV-label->incomingV
+    projection_of_edges = g.E().group().\
+        by(project("o", "l", "i").
+           by(outV().values("name")).
+           by(label()).
+           by(inV().values("name"))).\
+        by(tail()).next()
+    edges = {}
+
+    # in GraphSON 3.0 the "key" will be a dictionary and this can work more nicely - right now it's stuck as
+    # a string and has to be parsed
+    for key, value in projection_of_edges.items():
+        o = re.search("o=(.+?)[,\}]", key).group(1)
+        l = re.search("l=(.+?)[,\}]", key).group(1)
+        i = re.search("i=(.+?)[,\}]", key).group(1)
+        edges[o + "-" + l + "->" + i] = value
+
+    scenario.context.lookup_e = {"modern": edges}
 
 
 @after.each_scenario

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9396092c/gremlin-test/features/map/Vertex.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Vertex.feature b/gremlin-test/features/map/Vertex.feature
new file mode 100644
index 0000000..fbd4168
--- /dev/null
+++ b/gremlin-test/features/map/Vertex.feature
@@ -0,0 +1,111 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
+
+  Scenario: g_VXlistX1_2_3XX_name
+    Given the modern graph
+    And using the parameter vx is "l[v[marko],v[vadas],v[lop]]"
+    And the traversal of
+      """
+      g.V(vx).values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | string | marko |
+      | string | vadas |
+      | string | lop |
+
+  Scenario: g_VXlistXv1_v2_v3XX_name
+    Given the modern graph
+    And using the parameter vx is "l[v[marko].id,v[vadas].id,v[lop].id]"
+    And the traversal of
+      """
+      g.V(vx).values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | string | marko |
+      | string | vadas |
+      | string | lop |
+
+  Scenario: g_V
+    Given the modern graph
+    And the traversal of
+      """
+      g.V()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | vertex | marko |
+      | vertex | vadas |
+      | vertex | lop |
+      | vertex | josh |
+      | vertex | ripple |
+      | vertex | peter |
+
+  Scenario: g_VX1X_out
+    Given the modern graph
+    And using the parameter v1 is "v[marko]"
+    And the traversal of
+      """
+      g.V(v1).out()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | vertex | vadas |
+      | vertex | lop |
+      | vertex | josh |
+
+  Scenario: g_VX2X_in
+    Given the modern graph
+    And using the parameter v1 is "v[vadas]"
+    And the traversal of
+      """
+      g.V(v1).in()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | vertex | marko |
+
+  Scenario: g_VX4X_both
+    Given the modern graph
+    And using the parameter v1 is "v[josh]"
+    And the traversal of
+      """
+      g.V(v1).both()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | vertex | marko |
+      | vertex | lop |
+      | vertex | ripple |
+
+  Scenario: g_E
+    Given the modern graph
+    And the traversal of
+      """
+      g.E()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | edge | marko-created->lop |
+      | edge | marko-knows->josh |
+      | edge | marko-knows->vadas |
+      | edge | peter-created->lop |
+      | edge | josh-created->lop |
+      | edge | josh-created->ripple |
\ No newline at end of file


[13/26] tinkerpop git commit: TINKERPOP-1784 Added some basic support to convert vertex string to a vertex object

Posted by sp...@apache.org.
TINKERPOP-1784 Added some basic support to convert vertex string to a vertex object

This might be the pattern to use across the board. We'll see if there is a better idea floating about though so may not be final.


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

Branch: refs/heads/TINKERPOP-1784
Commit: 448d81e2db3058d6194975d1119c79745f737650
Parents: 9aa198b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 22 12:56:08 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 44 ++++++++------------
 .../features/sideEffect/GroupCount.feature      | 11 ++++-
 2 files changed, 27 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/448d81e2/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 069768d..f67a4c2 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -18,21 +18,25 @@ under the License.
 '''
 
 import json
-from gremlin_python.structure.graph import Graph, Vertex, Edge
+import re
+from gremlin_python.structure.graph import Graph
 from gremlin_python.process.graph_traversal import __
-from gremlin_python.process.traversal import P, Scope
-from radish import given, when, then, custom_type, register_custom_type, TypeBuilder
+from gremlin_python.process.traversal import P, Scope, Column
+from radish import given, when, then
 from hamcrest import *
 
 out = __.out
 
 
-@custom_type('words', r'\w+')
-def parse_word(text):
-    return str(text)
+def convert(m, ctx):
+    n = {}
+    for key, value in m.items():
+        if isinstance(key, str) and re.match("v\[.*\]", key):
+            n[ctx.lookup["modern"][key[2:-1]]] = value
+        else:
+            n[key] = value
 
-
-register_custom_type(WordList=TypeBuilder.with_many(parse_word, listsep=','))
+    return n
 
 
 @given("the {graph_name:w} graph")
@@ -45,6 +49,7 @@ def choose_graph(step, graph_name):
 def translate_traversal(step):
     g = step.context.g
     step.context.traversal = eval(step.text, {"g": g,
+                                              "Column": Column,
                                               "P": P,
                                               "Scope": Scope})
 
@@ -75,7 +80,7 @@ def assert_result(step, characterized_as):
             elif line[0] == "vertex":
                 assert_that(step.context.result[ix].label, equal_to(line[1]))
             elif line[0] == "map":
-                assert_that(step.context.result[ix], json.loads(line[1]))
+                assert_that(convert(step.context.result[ix], step.context), json.loads(line[1]))
             else:
                 raise ValueError("unknown type of " + line[0])
     elif characterized_as == "unordered":
@@ -86,6 +91,8 @@ def assert_result(step, characterized_as):
 
         results_to_test = list(step.context.result)
 
+        # finds a match in the results for each line of data to assert and then removes that item
+        # from the list - in the end there should be no items left over and each will have been asserted
         for line in data:
             if line[0] == "numeric":
                 val = long(line[1])
@@ -101,7 +108,7 @@ def assert_result(step, characterized_as):
                 assert_that(v, is_in(results_to_test))
                 results_to_test.remove(v)
             elif line[0] == "map":
-                val = json.load(line[1])
+                val = convert(json.load(line[1]), step.context)
                 assert_that(val, is_in(results_to_test))
                 results_to_test.remove(val)
             else:
@@ -111,20 +118,3 @@ def assert_result(step, characterized_as):
     else:
         raise ValueError("unknown data characterization of " + characterized_as)
 
-
-@then("the number of results should be {number:d}")
-def assert_number_of_results(step, number):
-    assert_that(len(step.context.result), equal_to(number))
-
-
-@then("the results should all be {element_type:w}")
-def assert_elements(step, element_type):
-    if element_type == "vertices":
-        t = Vertex
-    elif element_type == "edges":
-        t = Edge
-    else:
-        raise ValueError("unknown element type of " + element_type)
-
-    for r in step.context.result:
-        assert_that(r, instance_of(t))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/448d81e2/gremlin-test/features/sideEffect/GroupCount.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/GroupCount.feature b/gremlin-test/features/sideEffect/GroupCount.feature
index 1789b32..d8d5b51 100644
--- a/gremlin-test/features/sideEffect/GroupCount.feature
+++ b/gremlin-test/features/sideEffect/GroupCount.feature
@@ -17,7 +17,7 @@
 
 Feature: Step - groupCount()
 
-  Scenario: Use has() with P.gt()
+  Scenario: Group count vertices that have incoming created edges by their name
     Given the modern graph
     And the traversal of
       """
@@ -27,3 +27,12 @@ Feature: Step - groupCount()
     Then the result should be ordered
       | map | {"ripple": 1, "lop": 3} |
 
+  Scenario: Group count vertices, cap to retrieve the map and unfold it to group count again
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a")
+      """
+    When iterated to list
+    Then the result should be ordered
+      | map | {"v[marko]": 6, "v[vadas]": 2, "v[lop]": 6, "v[josh]": 6, "v[ripple]": 2, "v[peter]": 2} |
\ No newline at end of file


[14/26] tinkerpop git commit: TINKERPOP-1784 Minor refactoring of python gherkin steps

Posted by sp...@apache.org.
TINKERPOP-1784 Minor refactoring of python gherkin steps


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

Branch: refs/heads/TINKERPOP-1784
Commit: 959656f400b1963326f05de7d664568e2a7f4e9f
Parents: 448d81e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 22 13:49:50 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 130 ++++++++++---------
 1 file changed, 69 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/959656f4/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index f67a4c2..19da3ec 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -28,17 +28,6 @@ from hamcrest import *
 out = __.out
 
 
-def convert(m, ctx):
-    n = {}
-    for key, value in m.items():
-        if isinstance(key, str) and re.match("v\[.*\]", key):
-            n[ctx.lookup["modern"][key[2:-1]]] = value
-        else:
-            n[key] = value
-
-    return n
-
-
 @given("the {graph_name:w} graph")
 def choose_graph(step, graph_name):
     # only have modern atm but graphName would be used to select the right one
@@ -59,62 +48,81 @@ def iterate_the_traversal(step):
     step.context.result = step.context.traversal.toList()
 
 
+def __convert(m, ctx):
+    n = {}
+    for key, value in m.items():
+        if isinstance(key, str) and re.match("v\[.*\]", key):
+            n[ctx.lookup["modern"][key[2:-1]]] = value
+        else:
+            n[key] = value
+
+    return n
+
+
+def __ordered_assertion(step):
+    data = step.table
+
+    # results from traversal should have the same number of entries as the feature data table
+    assert_that(len(step.context.result), equal_to(len(data)))
+
+    # assert the results by type where the first column will hold the type and the second column
+    # the data to assert. the contents of the second column will be dependent on the type specified
+    # in the first column
+    for ix, line in enumerate(data):
+        if line[0] == "numeric":
+            assert_that(long(step.context.result[ix]), equal_to(long(line[1])))
+        elif line[0] == "string":
+            assert_that(str(step.context.result[ix]), equal_to(str(line[1])))
+        elif line[0] == "vertex":
+            assert_that(step.context.result[ix].label, equal_to(line[1]))
+        elif line[0] == "map":
+            assert_that(__convert(step.context.result[ix], step.context), json.loads(line[1]))
+        else:
+            raise ValueError("unknown type of " + line[0])
+
+
+def __unordered_assertion(step):
+    data = step.table
+
+    # results from traversal should have the same number of entries as the feature data table
+    assert_that(len(step.context.result), equal_to(len(data)))
+
+    results_to_test = list(step.context.result)
+
+    # finds a match in the results for each line of data to assert and then removes that item
+    # from the list - in the end there should be no items left over and each will have been asserted
+    for line in data:
+        if line[0] == "numeric":
+            val = long(line[1])
+            assert_that(val, is_in(list(map(long, results_to_test))))
+            results_to_test.remove(val)
+        elif line[0] == "string":
+            val = str(line[1])
+            assert_that(val, is_in(list(map(str, results_to_test))))
+            results_to_test.remove(val)
+        elif line[0] == "vertex":
+            val = str(line[1])
+            v = step.context.lookup["modern"][val]
+            assert_that(v, is_in(results_to_test))
+            results_to_test.remove(v)
+        elif line[0] == "map":
+            val = __convert(json.load(line[1]), step.context)
+            assert_that(val, is_in(results_to_test))
+            results_to_test.remove(val)
+        else:
+            raise ValueError("unknown type of " + line[0])
+
+    assert_that(len(results_to_test), is_(0))
+
+    
 @then("the result should be {characterized_as:w}")
 def assert_result(step, characterized_as):
     if characterized_as == "empty":
         assert_that(len(step.context.result), equal_to(0))
     elif characterized_as == "ordered":
-        data = step.table
-    
-        # results from traversal should have the same number of entries as the feature data table
-        assert_that(len(step.context.result), equal_to(len(data)))
-
-        # assert the results by type where the first column will hold the type and the second column
-        # the data to assert. the contents of the second column will be dependent on the type specified
-        # in the first column
-        for ix, line in enumerate(data):
-            if line[0] == "numeric":
-                assert_that(long(step.context.result[ix]), equal_to(long(line[1])))
-            elif line[0] == "string":
-                assert_that(str(step.context.result[ix]), equal_to(str(line[1])))
-            elif line[0] == "vertex":
-                assert_that(step.context.result[ix].label, equal_to(line[1]))
-            elif line[0] == "map":
-                assert_that(convert(step.context.result[ix], step.context), json.loads(line[1]))
-            else:
-                raise ValueError("unknown type of " + line[0])
+        __ordered_assertion(step)
     elif characterized_as == "unordered":
-        data = step.table
-
-        # results from traversal should have the same number of entries as the feature data table
-        assert_that(len(step.context.result), equal_to(len(data)))
-
-        results_to_test = list(step.context.result)
-
-        # finds a match in the results for each line of data to assert and then removes that item
-        # from the list - in the end there should be no items left over and each will have been asserted
-        for line in data:
-            if line[0] == "numeric":
-                val = long(line[1])
-                assert_that(val, is_in(list(map(long, results_to_test))))
-                results_to_test.remove(val)
-            elif line[0] == "string":
-                val = str(line[1])
-                assert_that(val, is_in(list(map(str, results_to_test))))
-                results_to_test.remove(val)
-            elif line[0] == "vertex":
-                val = str(line[1])
-                v = step.context.lookup["modern"][val]
-                assert_that(v, is_in(results_to_test))
-                results_to_test.remove(v)
-            elif line[0] == "map":
-                val = convert(json.load(line[1]), step.context)
-                assert_that(val, is_in(results_to_test))
-                results_to_test.remove(val)
-            else:
-                raise ValueError("unknown type of " + line[0])
-
-        assert_that(len(results_to_test), is_(0))
+        __unordered_assertion(step)
     else:
         raise ValueError("unknown data characterization of " + characterized_as)
 


[03/26] tinkerpop git commit: Remove an old test that is no longer relevant. CTR

Posted by sp...@apache.org.
Remove an old test that is no longer relevant. CTR


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

Branch: refs/heads/TINKERPOP-1784
Commit: 9f501cdbea72ef574764ed1027a83a85a959bc24
Parents: 5e39771
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Oct 3 13:33:03 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 13:35:02 2017 -0400

----------------------------------------------------------------------
 .../gremlin/process/traversal/step/sideEffect/GroupCountTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9f501cdb/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
index ec5b758..9bd515c 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
@@ -159,7 +159,7 @@ public abstract class GroupCountTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_filterXfalseX_groupCount() {
+    public void g_V_hasXnoX_groupCount() {
         final Traversal<Vertex, Map<Object, Long>> traversal = get_g_V_hasXnoX_groupCount();
         printTraversalForm(traversal);
         assertCommonC(traversal);


[18/26] tinkerpop git commit: TINKERPOP-1784 Changed assertion logic and table formats in feature files

Posted by sp...@apache.org.
TINKERPOP-1784 Changed assertion logic and table formats in feature files


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

Branch: refs/heads/TINKERPOP-1784
Commit: 01a6d777fa0823f7720ee94dd3fc77dd53566602
Parents: 97f6ae6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 28 14:54:40 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 61 +++++------------
 gremlin-test/features/filter/Coin.feature       | 12 ++--
 gremlin-test/features/filter/Has.feature        | 10 +--
 gremlin-test/features/map/Count.feature         | 10 +--
 gremlin-test/features/map/Select.feature        |  4 +-
 gremlin-test/features/map/Vertex.feature        | 70 ++++++++++----------
 .../features/sideEffect/GroupCount.feature      | 41 ++++++------
 7 files changed, 89 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 2154536..7a4a30a 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -81,22 +81,24 @@ def __convert(val, ctx):
         for key, value in val.items():
             n[__convert(key, ctx)] = __convert(value, ctx)
         return n
-    elif isinstance(val, (str, unicode)) and re.match("^l\[.*\]$", val):         # parse list
+    elif isinstance(val, unicode):
+        return __convert(val.encode('utf-8'), ctx)
+    elif isinstance(val, str) and re.match("^l\[.*\]$", val):         # parse list
         return list(map((lambda x: __convert(x, ctx)), val[2:-1].split(",")))
-    elif isinstance(val, (str, unicode)) and re.match("^d\[.*\]$", val):         # parse numeric
+    elif isinstance(val, str) and re.match("^d\[.*\]$", val):         # parse numeric
         return long(val[2:-1])
-    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]\.id$", val):     # parse vertex id
+    elif isinstance(val, str) and re.match("^v\[.*\]\.id$", val):     # parse vertex id
         return ctx.lookup_v["modern"][val[2:-4]].id
-    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]$", val):         # parse vertex
+    elif isinstance(val, str) and re.match("^v\[.*\]$", val):         # parse vertex
         return ctx.lookup_v["modern"][val[2:-1]]
-    elif isinstance(val, (str, unicode)) and re.match("^e\[.*\]\.id$", val):     # parse edge id
+    elif isinstance(val, str) and re.match("^e\[.*\]\.id$", val):     # parse edge id
         return ctx.lookup_e["modern"][val[2:-4]].id
-    elif isinstance(val, (str, unicode)) and re.match("^e\[.*\]$", val):         # parse edge
+    elif isinstance(val, str) and re.match("^e\[.*\]$", val):         # parse edge
         return ctx.lookup_e["modern"][val[2:-1]]
-    elif isinstance(val, unicode):
-        return val.encode('utf-8')
+    elif isinstance(val, str) and re.match("^m\[.*\]$", val):         # parse json as a map
+        return __convert(json.loads(val[2:-1]), ctx)
     else:
-        return str(val)
+        return val
 
 
 def __ordered_assertion(step):
@@ -109,19 +111,7 @@ def __ordered_assertion(step):
     # the data to assert. the contents of the second column will be dependent on the type specified
     # in the first column
     for ix, line in enumerate(data):
-        if line[0] == "numeric":
-            assert_that(long(step.context.result[ix]), equal_to(long(line[1])))
-        elif line[0] == "string":
-            assert_that(str(step.context.result[ix]), equal_to(str(line[1])))
-        elif line[0] == "vertex":
-            assert_that(step.context.result[ix].label, equal_to(line[1]))
-        elif line[0] == "edge":
-            assert_that(step.context.result[ix].label, equal_to(line[1]))
-        elif line[0] == "map":
-            assert_that(__convert(step.context.result[ix], step.context), json.loads(line[1]))
-        else:
-            raise ValueError("unknown type of " + line[0])
-
+        assert_that(step.context.result[ix], equal_to(__convert(line[0], step.context)))
 
 def __unordered_assertion(step):
     data = step.table
@@ -134,30 +124,9 @@ def __unordered_assertion(step):
     # finds a match in the results for each line of data to assert and then removes that item
     # from the list - in the end there should be no items left over and each will have been asserted
     for line in data:
-        if line[0] == "numeric":
-            val = long(line[1])
-            assert_that(val, is_in(list(map(long, results_to_test))))
-            results_to_test.remove(val)
-        elif line[0] == "string":
-            val = str(line[1])
-            assert_that(val, is_in(list(map(str, results_to_test))))
-            results_to_test.remove(val)
-        elif line[0] == "vertex":
-            val = str(line[1])
-            v = step.context.lookup_v["modern"][val]
-            assert_that(v, is_in(results_to_test))
-            results_to_test.remove(v)
-        elif line[0] == "edge":
-            val = str(line[1])
-            e = step.context.lookup_e["modern"][val]
-            assert_that(e, is_in(results_to_test))
-            results_to_test.remove(e)
-        elif line[0] == "map":
-            val = __convert(json.loads(line[1]), step.context)
-            assert_that(val, is_in(results_to_test))
-            results_to_test.remove(val)
-        else:
-            raise ValueError("unknown type of " + line[0])
+        val = __convert(line[0], step.context)
+        assert_that(val, is_in(results_to_test))
+        results_to_test.remove(val)
 
     assert_that(len(results_to_test), is_(0))
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/filter/Coin.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Coin.feature b/gremlin-test/features/filter/Coin.feature
index 802ebdc..d1acc46 100644
--- a/gremlin-test/features/filter/Coin.feature
+++ b/gremlin-test/features/filter/Coin.feature
@@ -25,12 +25,12 @@ Feature: Step - coin()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko  |
-      | vertex | vadas  |
-      | vertex | lop    |
-      | vertex | josh   |
-      | vertex | ripple |
-      | vertex | peter  |
+      | v[marko] |
+      | v[vadas] |
+      | v[lop] |
+      | v[josh] |
+      | v[ripple] |
+      | v[peter]  |
 
 
   Scenario: g_V_coinX0X

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/filter/Has.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Has.feature b/gremlin-test/features/filter/Has.feature
index 4a2e085..8ff3a2b 100644
--- a/gremlin-test/features/filter/Has.feature
+++ b/gremlin-test/features/filter/Has.feature
@@ -25,8 +25,8 @@ Feature: Step - has()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | josh   |
-      | vertex | peter  |
+      | v[josh] |
+      | v[peter] |
 
   Scenario: Use hasId() with P
     Given the modern graph
@@ -37,7 +37,7 @@ Feature: Step - has()
     """
     When iterated to list
     Then the result should be unordered
-      | vertex | josh   |
-      | vertex | josh   |
-      | vertex | peter  |
+      | v[josh] |
+      | v[josh] |
+      | v[peter] |
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/map/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Count.feature b/gremlin-test/features/map/Count.feature
index 1233ed3..b7f5c66 100644
--- a/gremlin-test/features/map/Count.feature
+++ b/gremlin-test/features/map/Count.feature
@@ -25,7 +25,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 6 |
+      | d[6] |
 
   Scenario: g_V_out_count
     Given the modern graph
@@ -35,7 +35,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 6 |
+      | d[6] |
 
   Scenario: g_V_both_both_count
     Given the modern graph
@@ -45,7 +45,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 30 |
+      | d[30] |
 
   Scenario: g_V_fold_countXlocalX
     Given the modern graph
@@ -55,7 +55,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 6 |
+      | d[6] |
 
   Scenario: g_V_hasXnoX_count
     Given the modern graph
@@ -65,4 +65,4 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 0 |
\ No newline at end of file
+      | d[0] |
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/map/Select.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature
index b2d208c..9166954 100644
--- a/gremlin-test/features/map/Select.feature
+++ b/gremlin-test/features/map/Select.feature
@@ -26,5 +26,5 @@ Feature: Step - select()
       """
     When iterated to list
     Then the result should be unordered
-      | map | {"a": "v[marko]", "b": "v[vadas]"} |
-      | map | {"a": "v[marko]", "b": "v[josh]"} |
\ No newline at end of file
+      | m[{"a": "v[marko]", "b": "v[vadas]"}] |
+      | m[{"a": "v[marko]", "b": "v[josh]"}] |
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/map/Vertex.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Vertex.feature b/gremlin-test/features/map/Vertex.feature
index 5bed2a6..9aa506c 100644
--- a/gremlin-test/features/map/Vertex.feature
+++ b/gremlin-test/features/map/Vertex.feature
@@ -26,9 +26,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | string | marko |
-      | string | vadas |
-      | string | lop |
+      | marko |
+      | vadas |
+      | lop |
 
   Scenario: g_VXlistXv1_v2_v3XX_name
     Given the modern graph
@@ -39,9 +39,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | string | marko |
-      | string | vadas |
-      | string | lop |
+      | marko |
+      | vadas |
+      | lop |
 
   Scenario: g_V
     Given the modern graph
@@ -51,12 +51,12 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko |
-      | vertex | vadas |
-      | vertex | lop |
-      | vertex | josh |
-      | vertex | ripple |
-      | vertex | peter |
+      | v[marko] |
+      | v[vadas] |
+      | v[lop] |
+      | v[josh] |
+      | v[ripple] |
+      | v[peter] |
 
   Scenario: g_VX1X_out
     Given the modern graph
@@ -67,9 +67,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | vadas |
-      | vertex | lop |
-      | vertex | josh |
+      | v[vadas] |
+      | v[lop] |
+      | v[josh] |
 
   Scenario: g_VX2X_in
     Given the modern graph
@@ -80,7 +80,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko |
+      | v[marko] |
 
   Scenario: g_VX4X_both
     Given the modern graph
@@ -91,9 +91,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko |
-      | vertex | lop |
-      | vertex | ripple |
+      | v[marko] |
+      | v[lop] |
+      | v[ripple] |
 
   Scenario: g_E
     Given the modern graph
@@ -103,12 +103,12 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | marko-created->lop |
-      | edge | marko-knows->josh |
-      | edge | marko-knows->vadas |
-      | edge | peter-created->lop |
-      | edge | josh-created->lop |
-      | edge | josh-created->ripple |
+      | e[marko-created->lop] |
+      | e[marko-knows->josh] |
+      | e[marko-knows->vadas] |
+      | e[peter-created->lop] |
+      | e[josh-created->lop] |
+      | e[josh-created->ripple] |
 
   Scenario: g_EX11X
     Given the modern graph
@@ -119,7 +119,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | josh-created->lop |
+      | e[josh-created->lop] |
 
   Scenario: g_VX1X_outE
     Given the modern graph
@@ -130,9 +130,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | marko-created->lop |
-      | edge | marko-knows->josh |
-      | edge | marko-knows->vadas |
+      | e[marko-created->lop] |
+      | e[marko-knows->josh] |
+      | e[marko-knows->vadas] |
 
   Scenario: g_VX2X_outE
     Given the modern graph
@@ -143,7 +143,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | marko-knows->vadas |
+      | e[marko-knows->vadas] |
 
   Scenario: g_VX4X_bothEXcreatedX
     Given the modern graph
@@ -154,8 +154,8 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | josh-created->lop |
-      | edge | josh-created->ripple |
+      | e[josh-created->lop] |
+      | e[josh-created->ripple] |
 
   Scenario: g_VX4X_bothE
     Given the modern graph
@@ -166,6 +166,6 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | josh-created->lop |
-      | edge | josh-created->ripple |
-      | edge | marko-knows->josh |
+      | e[josh-created->lop] |
+      | e[josh-created->ripple] |
+      | e[marko-knows->josh] |

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/sideEffect/GroupCount.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/GroupCount.feature b/gremlin-test/features/sideEffect/GroupCount.feature
index 7b4a0a6..bfb7363 100644
--- a/gremlin-test/features/sideEffect/GroupCount.feature
+++ b/gremlin-test/features/sideEffect/GroupCount.feature
@@ -25,24 +25,25 @@ Feature: Step - groupCount()
       """
     When iterated to list
     Then the result should be ordered
-      | map | {"ripple": 1, "lop": 3} |
+      | m[{"ripple": 1, "lop": 3}] |
 
-  Scenario: Edge count distribution
-    Given the modern graph
-    And the traversal of
-      """
-      g.V().groupCount().by(bothE().count())
-      """
-    When iterated to list
-    Then the result should be ordered
-      | map | {"d[1]": 3, "d[3]": 3} |
-
-  Scenario: Group count vertices, cap to retrieve the map and unfold it to group count again
-    Given the modern graph
-    And the traversal of
-      """
-      g.V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a")
-      """
-    When iterated to list
-    Then the result should be ordered
-      | map | {"v[marko]": 6, "v[vadas]": 2, "v[lop]": 6, "v[josh]": 6, "v[ripple]": 2, "v[peter]": 2} |
\ No newline at end of file
+# NOT SUPPORTED UNTIL GRAPHSON 3.X WHICH HAS SUPPORT FOR NON-STRING KEYS
+#  Scenario: Edge count distribution
+#    Given the modern graph
+#    And the traversal of
+#      """
+#      g.V().groupCount().by(bothE().count())
+#      """
+#    When iterated to list
+#    Then the result should be ordered
+#      | m[{"d[1]": 3, "d[3]": 3}] |
+#
+#  Scenario: Group count vertices, cap to retrieve the map and unfold it to group count again
+#    Given the modern graph
+#    And the traversal of
+#      """
+#      g.V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a")
+#      """
+#    When iterated to list
+#    Then the result should be ordered
+#      | m[{"v[marko]": 6, "v[vadas]": 2, "v[lop]": 6, "v[josh]": 6, "v[ripple]": 2, "v[peter]": 2}] |
\ No newline at end of file


[24/26] tinkerpop git commit: TINKERPOP-1784 Completed the VertexTest cases

Posted by sp...@apache.org.
TINKERPOP-1784 Completed the VertexTest cases


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

Branch: refs/heads/TINKERPOP-1784
Commit: 8ae2dd662e0feac0595a5fe0339e5aff6aad7e21
Parents: 6325c4a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 29 15:44:50 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     |  18 +-
 gremlin-test/features/map/Vertex.feature        | 226 ++++++++++++++++---
 .../gremlin/process/FeatureCoverageTest.java    |  93 ++++++++
 .../gremlin/structure/FeatureCoverageTest.java  |  92 --------
 4 files changed, 305 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ae2dd66/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index a298d6c..340f84a 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -21,7 +21,7 @@ import json
 import re
 from gremlin_python.structure.graph import Graph
 from gremlin_python.process.graph_traversal import __
-from gremlin_python.process.traversal import P, Scope, Column
+from gremlin_python.process.traversal import P, Scope, Column, Direction
 from radish import given, when, then
 from hamcrest import *
 
@@ -35,6 +35,12 @@ def choose_graph(step, graph_name):
     step.context.g = Graph().traversal().withRemote(step.context.remote_conn[graph_name])
 
 
+@given("an unsupported test")
+def unsupported_scenario(step):
+    # this is a do nothing step as the test can't be supported for whatever reason
+    return
+
+
 @given("using the parameter {param_name:w} is {param:QuotedString}")
 def add_parameter(step, param_name, param):
     if not hasattr(step.context, "traversal_params"):
@@ -48,6 +54,7 @@ def translate_traversal(step):
     g = step.context.g
     b = {"g": g,
          "Column": Column,
+         "Direction": Direction,
          "P": P,
          "Scope": Scope,
          "bothE": __.bothE}
@@ -75,6 +82,11 @@ def assert_result(step, characterized_as):
         raise ValueError("unknown data characterization of " + characterized_as)
 
 
+@then("nothing should happen")
+def nothing_happening(step):
+    return
+
+
 def __convert(val, ctx):
     if isinstance(val, dict):                                         # convert dictionary keys/values
         n = {}
@@ -89,10 +101,14 @@ def __convert(val, ctx):
         return long(val[2:-1])
     elif isinstance(val, str) and re.match("^v\[.*\]\.id$", val):     # parse vertex id
         return ctx.lookup_v["modern"][val[2:-4]].id
+    elif isinstance(val, str) and re.match("^v\[.*\]\.sid$", val):    # parse vertex id as string
+        return ctx.lookup_v["modern"][val[2:-5]].id
     elif isinstance(val, str) and re.match("^v\[.*\]$", val):         # parse vertex
         return ctx.lookup_v["modern"][val[2:-1]]
     elif isinstance(val, str) and re.match("^e\[.*\]\.id$", val):     # parse edge id
         return ctx.lookup_e["modern"][val[2:-4]].id
+    elif isinstance(val, str) and re.match("^e\[.*\]\.sid$", val):    # parse edge id as string
+        return ctx.lookup_e["modern"][val[2:-5]].id
     elif isinstance(val, str) and re.match("^e\[.*\]$", val):         # parse edge
         return ctx.lookup_e["modern"][val[2:-1]]
     elif isinstance(val, str) and re.match("^m\[.*\]$", val):         # parse json as a map

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ae2dd66/gremlin-test/features/map/Vertex.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Vertex.feature b/gremlin-test/features/map/Vertex.feature
index 1905f3a..37e398b 100644
--- a/gremlin-test/features/map/Vertex.feature
+++ b/gremlin-test/features/map/Vertex.feature
@@ -19,7 +19,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VXlistX1_2_3XX_name
     Given the modern graph
-    And using the parameter vx is "l[v[marko],v[vadas],v[lop]]"
+    And using the parameter vx is "l[v[marko].id,v[vadas].id,v[lop].id]"
     And the traversal of
       """
       g.V(vx).values("name")
@@ -32,7 +32,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VXlistXv1_v2_v3XX_name
     Given the modern graph
-    And using the parameter vx is "l[v[marko].id,v[vadas].id,v[lop].id]"
+    And using the parameter vx is "l[v[marko],v[vadas],v[lop]]"
     And the traversal of
       """
       g.V(vx).values("name")
@@ -60,10 +60,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX1X_out
     Given the modern graph
-    And using the parameter v1 is "v[marko]"
+    And using the parameter v1Id is "v[marko].id"
     And the traversal of
       """
-      g.V(v1).out()
+      g.V(v1Id).out()
       """
     When iterated to list
     Then the result should be unordered
@@ -73,10 +73,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX2X_in
     Given the modern graph
-    And using the parameter v2 is "v[vadas]"
+    And using the parameter v2Id is "v[vadas].id"
     And the traversal of
       """
-      g.V(v2).in()
+      g.V(v2Id).in()
       """
     When iterated to list
     Then the result should be unordered
@@ -84,10 +84,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX4X_both
     Given the modern graph
-    And using the parameter v4 is "v[josh]"
+    And using the parameter v4Id is "v[josh].id"
     And the traversal of
       """
-      g.V(v4).both()
+      g.V(v4Id).both()
       """
     When iterated to list
     Then the result should be unordered
@@ -112,10 +112,21 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_EX11X
     Given the modern graph
-    And using the parameter e11 is "e[josh-created->lop]"
+    And using the parameter e11Id is "e[josh-created->lop].id"
+    And the traversal of
+    """
+      g.E(e11Id)
+      """
+    When iterated to list
+    Then the result should be unordered
+      | e[josh-created->lop] |
+
+  Scenario: g_EX11AsStringX
+    Given the modern graph
+    And using the parameter e11Id is "e[josh-created->lop].sid"
     And the traversal of
     """
-      g.E(e11)
+      g.E(e11Id)
       """
     When iterated to list
     Then the result should be unordered
@@ -123,10 +134,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX1X_outE
     Given the modern graph
-    And using the parameter v1 is "v[marko]"
+    And using the parameter v1Id is "v[marko].id"
     And the traversal of
     """
-      g.V(v1).outE()
+      g.V(v1Id).outE()
       """
     When iterated to list
     Then the result should be unordered
@@ -136,10 +147,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX2X_outE
     Given the modern graph
-    And using the parameter v2 is "v[vadas]"
+    And using the parameter v2Id is "v[vadas].id"
     And the traversal of
     """
-      g.V(v2).inE()
+      g.V(v2Id).inE()
       """
     When iterated to list
     Then the result should be unordered
@@ -147,10 +158,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX4X_bothEXcreatedX
     Given the modern graph
-    And using the parameter v4 is "v[josh]"
+    And using the parameter v4Id is "v[josh].id"
     And the traversal of
     """
-      g.V(v4).bothE("created")
+      g.V(v4Id).bothE("created")
       """
     When iterated to list
     Then the result should be unordered
@@ -159,10 +170,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX4X_bothE
     Given the modern graph
-    And using the parameter v4 is "v[josh]"
+    And using the parameter v4Id is "v[josh].id"
     And the traversal of
     """
-      g.V(v4).bothE()
+      g.V(v4Id).bothE()
       """
     When iterated to list
     Then the result should be unordered
@@ -172,10 +183,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX1X_outE_inV
     Given the modern graph
-    And using the parameter v1 is "v[marko]"
+    And using the parameter v1Id is "v[marko].id"
     And the traversal of
       """
-      g.V(v1).both()
+      g.V(v1Id).both()
       """
     When iterated to list
     Then the result should be unordered
@@ -185,10 +196,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX2X_inE_outV
     Given the modern graph
-    And using the parameter v2 is "v[vadas]"
+    And using the parameter v2Id is "v[vadas].id"
     And the traversal of
       """
-      g.V(v2).inE().outV()
+      g.V(v2Id).inE().outV()
       """
     When iterated to list
     Then the result should be unordered
@@ -226,10 +237,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX1X_outEXknowsX_bothV_name
     Given the modern graph
-    And using the parameter v1 is "v[marko]"
+    And using the parameter v1Id is "v[marko].id"
     And the traversal of
       """
-      g.V(v1).outE("knows").bothV().values("name")
+      g.V(v1Id).outE("knows").bothV().values("name")
       """
     When iterated to list
     Then the result should be unordered
@@ -240,10 +251,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX1X_outE_otherV
     Given the modern graph
-    And using the parameter v1 is "v[marko]"
+    And using the parameter v1Id is "v[marko].id"
     And the traversal of
       """
-      g.V(v1).outE().otherV()
+      g.V(v1Id).outE().otherV()
       """
     When iterated to list
     Then the result should be unordered
@@ -253,10 +264,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX4X_bothE_otherV
     Given the modern graph
-    And using the parameter v4 is "v[josh]"
+    And using the parameter v4Id is "v[josh].id"
     And the traversal of
       """
-      g.V(v4).bothE().otherV()
+      g.V(v4Id).bothE().otherV()
       """
     When iterated to list
     Then the result should be unordered
@@ -266,11 +277,164 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX4X_bothE_hasXweight_lt_1X_otherV
     Given the modern graph
-    And using the parameter v4 is "v[josh]"
+    And using the parameter v4Id is "v[josh].id"
+    And the traversal of
+      """
+      g.V(v4Id).bothE().has("weight", P.lt(1.0)).otherV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[lop] |
+
+  Scenario: g_VX2X_inE
+    Given the modern graph
+    And using the parameter v2Id is "v[vadas].id"
+    And the traversal of
+    """
+      g.V(v2Id).bothE()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | e[marko-knows->vadas] |
+
+  Scenario: get_g_VX1X_outE_otherV
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).outE().otherV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |                               
+      | v[josh] |
+      | v[lop] |
+
+  Scenario: g_VX1X_outXknowsX
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).out("knows")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |
+      | v[josh] |
+
+  Scenario: g_VX1AsStringX_outXknowsX
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].sid"
     And the traversal of
       """
-      g.V(v4).bothE().has("weight", P.lt(1.0)).otherV()
+      g.V(v1Id).out("knows")
       """
     When iterated to list
     Then the result should be unordered
-      | v[lop] |
\ No newline at end of file
+      | v[vadas] |
+      | v[josh] |
+
+  Scenario: g_VX1X_outXknows_createdX
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).out("knows","created")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |
+      | v[josh] |
+      | v[lop] |
+
+  Scenario: g_VX1X_outEXknowsX_inV
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).outE("knows").inV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |
+      | v[josh] |
+
+  Scenario: g_VX1X_outEXknows_createdX_inV
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).outE("knows","created").inV()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |
+      | v[josh] |
+      | v[lop] |
+
+  Scenario: g_V_out_out
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().out().out()
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[ripple] |
+      | v[lop] |
+
+  Scenario: g_VX1X_out_out_out
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).out().out().out()
+      """
+    When iterated to list
+    Then the result should be empty
+
+  Scenario: g_VX1X_out_name
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).out().values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | vadas |
+      | josh |
+      | lop |
+
+  Scenario: g_VX1X_to_XOUT_knowsX
+    Given the modern graph
+    And using the parameter v1Id is "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).to(Direction.OUT, "knows")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | v[vadas] |
+      | v[josh] |
+
+  Scenario: g_VX1_2_3_4X_name
+    Given an unsupported test
+    Then nothing should happen
+
+  Scenario: g_V_hasLabelXpersonX_V_hasLabelXsoftwareX_name
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().hasLabel("person").V().hasLabel("software").values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | lop |
+      | lop |
+      | lop |
+      | lop |
+      | ripple |
+      | ripple |
+      | ripple |
+      | ripple |
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ae2dd66/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
new file mode 100644
index 0000000..d3212a4
--- /dev/null
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.tinkerpop.gremlin.process;
+
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class FeatureCoverageTest {
+
+    private static Pattern scenarioName = Pattern.compile("^\\s*Scenario:\\s*(.*)$");
+
+    @Test
+    public void shouldImplementAllProcessTestsAsFeatures() throws Exception {
+
+        // TEMPORARY while test framework is under development - all tests should ultimately be included
+        final List<Class<?>> temp = Arrays.asList(CoinTest.class, VertexTest.class);
+
+        final Field field = ProcessStandardSuite.class.getDeclaredField("testsToEnforce");
+        field.setAccessible(true);
+        final Class<?>[] testsToEnforce = (Class<?>[]) field.get(null);
+
+        final List<Class<?>> testClassesToEnforce = Stream.of(testsToEnforce).filter(temp::contains).collect(Collectors.toList());
+        for (Class<?> t : testClassesToEnforce) {
+            final String packge = t.getPackage().getName();
+            final String group = packge.substring(packge.lastIndexOf(".") + 1, packge.length());
+            final String featureFileName = "features" + File.separator +
+                                           group + File.separator +
+                                           t.getSimpleName().replace("Test", "") + ".feature";
+            final Set<String> testMethods = Stream.of(t.getDeclaredMethods())
+                    .filter(m -> m.isAnnotationPresent(Test.class))
+                    .map(Method::getName).collect(Collectors.toSet());
+
+            final File featureFile = new File(featureFileName);
+            assertThat(featureFile.exists(), is(true));
+            assertThat(featureFile.isFile(), is(true));
+
+            final Set<String> testsInFeatureFile = new HashSet<>();
+            final InputStream is = new FileInputStream(featureFile);
+            final BufferedReader buf = new BufferedReader(new InputStreamReader(is));
+            String line = buf.readLine();
+            while(line != null){
+                final Matcher matcher = scenarioName.matcher(line);
+                if (matcher.matches())
+                    testsInFeatureFile.add(matcher.group(1));
+                line = buf.readLine();
+            }
+
+            testMethods.removeAll(testsInFeatureFile);
+
+            assertEquals("All test methods are not implemented in the " + featureFileName + ": " + testMethods, testMethods.size(), 0);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ae2dd66/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java
deleted file mode 100644
index 791d44e..0000000
--- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-package org.apache.tinkerpop.gremlin.structure;
-
-import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class FeatureCoverageTest {
-
-    private static Pattern scenarioName = Pattern.compile("^\\s*Scenario:\\s*(.*)$");
-
-    @Test
-    public void shouldImplementAllProcessTestsAsFeatures() throws Exception {
-
-        // TEMPORARY while test framework is under development - all tests should ultimately be included
-        final List<Class<?>> temp = Arrays.asList(CoinTest.class);
-
-        final Field field = ProcessStandardSuite.class.getDeclaredField("testsToEnforce");
-        field.setAccessible(true);
-        final Class<?>[] testsToEnforce = (Class<?>[]) field.get(null);
-
-        final List<Class<?>> testClassesToEnforce = Stream.of(testsToEnforce).filter(temp::contains).collect(Collectors.toList());
-        for (Class<?> t : testClassesToEnforce) {
-            final String packge = t.getPackage().getName();
-            final String group = packge.substring(packge.lastIndexOf(".") + 1, packge.length());
-            final String featureFileName = "features" + File.separator +
-                                           group + File.separator +
-                                           t.getSimpleName().replace("Test", "") + ".feature";
-            final Set<String> testMethods = Stream.of(t.getDeclaredMethods())
-                    .filter(m -> m.isAnnotationPresent(Test.class))
-                    .map(Method::getName).collect(Collectors.toSet());
-
-            final File featureFile = new File(featureFileName);
-            assertThat(featureFile.exists(), is(true));
-            assertThat(featureFile.isFile(), is(true));
-
-            final Set<String> testsInFeatureFile = new HashSet<>();
-            final InputStream is = new FileInputStream(featureFile);
-            final BufferedReader buf = new BufferedReader(new InputStreamReader(is));
-            String line = buf.readLine();
-            while(line != null){
-                final Matcher matcher = scenarioName.matcher(line);
-                if (matcher.matches())
-                    testsInFeatureFile.add(matcher.group(1));
-                line = buf.readLine();
-            }
-
-            assertEquals("All test methods are not implemented in the " + featureFileName, testMethods, testsInFeatureFile);
-        }
-    }
-}


[10/26] tinkerpop git commit: TINKERPOP-1784 Added test for select in GLV tests

Posted by sp...@apache.org.
TINKERPOP-1784 Added test for select in GLV tests

Included infrastructure for validating maps and refactored other related code.


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

Branch: refs/heads/TINKERPOP-1784
Commit: 30422e7acea0d5171c8d533e8cd4987ee42de761
Parents: 3237fbe
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sat Sep 23 07:12:07 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 76 ++++++++++++--------
 gremlin-test/features/map/Select.feature        | 30 ++++++++
 2 files changed, 75 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30422e7a/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 35103f3..8ef0f1b 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -32,14 +32,27 @@ def choose_graph(step, graph_name):
     step.context.g = Graph().traversal().withRemote(step.context.remote_conn[graph_name])
 
 
+@given("using the parameter {param_name:w} is {param:QuotedString}")
+def add_parameter(step, param_name, param):
+    if not hasattr(step.context, "traversal_params"):
+        step.context.traversal_params = {}
+
+    step.context.traversal_params[param_name.encode('utf-8')] = __convert(param, step.context)
+
+
 @given("the traversal of")
 def translate_traversal(step):
     g = step.context.g
-    step.context.traversal = eval(step.text, {"g": g,
-                                              "Column": Column,
-                                              "P": P,
-                                              "Scope": Scope,
-                                              "bothE": __.bothE})
+    b = {"g": g,
+         "Column": Column,
+         "P": P,
+         "Scope": Scope,
+         "bothE": __.bothE}
+
+    if hasattr(step.context, "traversal_params"):
+        b.update(step.context.traversal_params)
+
+    step.context.traversal = eval(step.text, b)
 
 
 @when("iterated to list")
@@ -47,18 +60,32 @@ def iterate_the_traversal(step):
     step.context.result = step.context.traversal.toList()
 
 
-def __convert(m, ctx):
-    # transform string map keys from the test spec to numbers when it encounters the appropriate patterns
-    n = {}
-    for key, value in m.items():
-        if re.match("d\[.*\]", key):
-            n[long(key[2:-1])] = value
-        elif re.match("v\[.*\]", key):
-            n[ctx.lookup["modern"][key[2:-1]]] = value
-        else:
-            n[key] = value
+@then("the result should be {characterized_as:w}")
+def assert_result(step, characterized_as):
+    if characterized_as == "empty":
+        assert_that(len(step.context.result), equal_to(0))
+    elif characterized_as == "ordered":
+        __ordered_assertion(step)
+    elif characterized_as == "unordered":
+        __unordered_assertion(step)
+    else:
+        raise ValueError("unknown data characterization of " + characterized_as)
+
 
-    return n
+def __convert(val, ctx):
+    if isinstance(val, dict):
+        n = {}
+        for key, value in val.items():
+            n[__convert(key, ctx)] = __convert(value, ctx)
+        return n
+    elif isinstance(val, (str, unicode)) and re.match("d\[.*\]", val):
+        return long(val[2:-1])
+    elif isinstance(val, (str, unicode)) and re.match("v\[.*\]", val):
+        return ctx.lookup["modern"][val[2:-1]]
+    elif isinstance(val, unicode):
+        return val.encode('utf-8')
+    else:
+        return str(val)
 
 
 def __ordered_assertion(step):
@@ -108,23 +135,10 @@ def __unordered_assertion(step):
             assert_that(v, is_in(results_to_test))
             results_to_test.remove(v)
         elif line[0] == "map":
-            val = __convert(json.load(line[1]), step.context)
+            val = __convert(json.loads(line[1]), step.context)
             assert_that(val, is_in(results_to_test))
             results_to_test.remove(val)
         else:
             raise ValueError("unknown type of " + line[0])
 
-    assert_that(len(results_to_test), is_(0))
-
-    
-@then("the result should be {characterized_as:w}")
-def assert_result(step, characterized_as):
-    if characterized_as == "empty":
-        assert_that(len(step.context.result), equal_to(0))
-    elif characterized_as == "ordered":
-        __ordered_assertion(step)
-    elif characterized_as == "unordered":
-        __unordered_assertion(step)
-    else:
-        raise ValueError("unknown data characterization of " + characterized_as)
-
+    assert_that(len(results_to_test), is_(0))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30422e7a/gremlin-test/features/map/Select.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature
new file mode 100644
index 0000000..e64417a
--- /dev/null
+++ b/gremlin-test/features/map/Select.feature
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Step - select()
+
+  Scenario: Select vertices
+    Given the modern graph
+    And using the parameter v1 is "v[marko]"
+    And the traversal of
+      """
+      g.V(v1).as_("a").out("knows").as_("b").select("a", "b")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | map | {"a": "v[marko]", "b": "v[vadas]"} |
+      | map | {"a": "v[marko]", "b": "v[josh]"} |
\ No newline at end of file


[26/26] tinkerpop git commit: TINKERPOP-1784 Added another feature test for groupCount()

Posted by sp...@apache.org.
TINKERPOP-1784 Added another feature test for groupCount()


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

Branch: refs/heads/TINKERPOP-1784
Commit: 8ed815cbf85aa376f1dbfc45989af33485f95a6d
Parents: 8445f63
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Oct 3 13:06:19 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:20:28 2017 -0400

----------------------------------------------------------------------
 gremlin-test/features/sideEffect/GroupCount.feature       | 10 ++++++++++
 .../tinkerpop/gremlin/process/FeatureCoverageTest.java    |  2 ++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ed815cb/gremlin-test/features/sideEffect/GroupCount.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/GroupCount.feature b/gremlin-test/features/sideEffect/GroupCount.feature
index d68a964..3fb363e 100644
--- a/gremlin-test/features/sideEffect/GroupCount.feature
+++ b/gremlin-test/features/sideEffect/GroupCount.feature
@@ -27,6 +27,16 @@ Feature: Step - groupCount()
     Then the result should be ordered
       | m[{"ripple": 1, "lop": 3}] |
 
+  Scenario: g_V_outXcreatedX_name_groupCount
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().out("created").values("name").groupCount()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | m[{"ripple": 1, "lop": 3}] |
+
   Scenario: g_V_groupCount_byXbothE_countX
     Given an unsupported test
     Then nothing should happen because

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ed815cb/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
index 00975be..ce66889 100644
--- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.process;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest;
 import org.junit.Test;
 
 import java.io.BufferedReader;
@@ -57,6 +58,7 @@ public class FeatureCoverageTest {
         final List<Class<?>> temp = Arrays.asList(
                 CoinTest.class,
                 CountTest.class,
+                GroupCountTest.class,
                 VertexTest.class);
 
         final Field field = ProcessStandardSuite.class.getDeclaredField("testsToEnforce");


[08/26] tinkerpop git commit: TINKERPOP-1784 Initial implementation of a new language agnostic test suite

Posted by sp...@apache.org.
TINKERPOP-1784 Initial implementation of a new language agnostic test suite

Uses Gherkin to write test specifications that will be implemented by the various GLVs. Provided a basic implementation for gremlin-python.


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

Branch: refs/heads/TINKERPOP-1784
Commit: a4b552f0247f80f7cb518469ae595795203a82e3
Parents: 9f501cd
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 14 15:44:32 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:51 2017 -0400

----------------------------------------------------------------------
 gremlin-python/pom.xml                          | 19 +++++++
 .../main/jython/radish/count_features_step.py   | 59 ++++++++++++++++++++
 .../src/main/jython/radish/terrain.py           | 31 ++++++++++
 gremlin-python/src/main/jython/setup.py         |  3 +-
 gremlin-test/features/Count.feature             | 54 ++++++++++++++++++
 5 files changed, 165 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4b552f0/gremlin-python/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml
index 379a114..4ab5f37 100644
--- a/gremlin-python/pom.xml
+++ b/gremlin-python/pom.xml
@@ -341,6 +341,10 @@ limitations under the License.
                                               failonerror="true">
                                             <arg line="install wheel"/>
                                         </exec>
+                                        <exec dir="${project.build.directory}/python2" executable="env/bin/pip"
+                                              failonerror="true">
+                                            <arg line="install radish-bdd"/>
+                                        </exec>
                                         <exec dir="${project.build.directory}/python3" executable="virtualenv"
                                               failonerror="true">
                                             <arg line="--python=python3 env"/>
@@ -349,6 +353,10 @@ limitations under the License.
                                               failonerror="true">
                                             <arg line="install wheel"/>
                                         </exec>
+                                        <exec dir="${project.build.directory}/python3" executable="env/bin/pip"
+                                              failonerror="true">
+                                            <arg line="install radish-bdd"/>
+                                        </exec>
                                         <exec dir="${project.build.directory}/python-packaged" executable="virtualenv"
                                               failonerror="true">
                                             <arg line="--python=python3 env"/>
@@ -438,6 +446,17 @@ limitations under the License.
                                             <env key="PYTHONPATH" value=""/>
                                             <arg line="setup.py test"/>
                                         </exec>
+                                        <!-- radish seems to like all dependencies in place -->
+                                        <exec executable="env/bin/python" dir="${project.build.directory}/python2"
+                                              failonerror="true">
+                                            <env key="PYTHONPATH" value=""/>
+                                            <arg line="setup.py install"/>
+                                        </exec>
+                                        <exec executable="env/bin/radish" dir="${project.build.directory}/python2"
+                                              failonerror="true">
+                                            <env key="PYTHONPATH" value=""/>
+                                            <arg line="-b ${project.build.directory}/python2/radish ${project.basedir}/../gremlin-test/features/"/>
+                                        </exec>                                                                  
                                     </target>
                                 </configuration>
                             </execution>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4b552f0/gremlin-python/src/main/jython/radish/count_features_step.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/count_features_step.py b/gremlin-python/src/main/jython/radish/count_features_step.py
new file mode 100644
index 0000000..324c29c
--- /dev/null
+++ b/gremlin-python/src/main/jython/radish/count_features_step.py
@@ -0,0 +1,59 @@
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+'''
+
+from gremlin_python.structure.graph import Graph
+from gremlin_python.process.graph_traversal import __
+from gremlin_python.process.traversal import Scope
+from radish import before, given, when, then
+
+out = __.out
+
+
+@given("the {graphName:w} graph")
+def choose_graph(step, graphName):
+    # only have modern atm but graphName would be used to select the right one
+    step.context.g = Graph().traversal().withRemote(step.context.remote_conn_modern)
+
+
+@given("the traversal of")
+def translate_traversal(step):
+    g = step.context.g
+    if step.text == "g.V().count()":
+        step.context.traversal = g.V().count()
+    elif step.text == "g.V().both().both().count()":
+        step.context.traversal = g.V().both().both().count()
+    elif step.text == "g.V().fold().count(Scope.local)":
+        step.context.traversal = g.V().fold().count(Scope.local)
+    elif step.text == "g.V().has(\"no\").count()":
+        step.context.traversal = g.V().has("no").count()
+    else:
+        raise ValueError("Gremlin translation to python not found - missing: " + step.text)
+
+
+@when("iterating")
+def iterate_the_traversal(step):
+    step.context.result = step.context.traversal.toList()
+
+
+@then("the result should be {number:d}")
+def assert_single_result_of_number(step, number):
+    assert len(step.context.result) == 1
+    assert step.context.result[0] == number
+
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4b552f0/gremlin-python/src/main/jython/radish/terrain.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/terrain.py b/gremlin-python/src/main/jython/radish/terrain.py
new file mode 100644
index 0000000..389f39c
--- /dev/null
+++ b/gremlin-python/src/main/jython/radish/terrain.py
@@ -0,0 +1,31 @@
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+'''
+
+from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
+from radish import before, after
+
+
+@before.each_scenario
+def prepare_traversal_source(scenario):
+    scenario.context.remote_conn_modern = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+
+
+@after.each_scenario
+def close_traversal_source(scenario):
+    scenario.context.remote_conn_modern.close()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4b552f0/gremlin-python/src/main/jython/setup.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/setup.py b/gremlin-python/src/main/jython/setup.py
index e6ab493..fddd7c8 100644
--- a/gremlin-python/src/main/jython/setup.py
+++ b/gremlin-python/src/main/jython/setup.py
@@ -70,7 +70,8 @@ setup(
     ],
     tests_require=[
         'pytest',
-        'mock'
+        'mock',
+        'radish-bdd'
     ],
     install_requires=install_requires,
     classifiers=[

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a4b552f0/gremlin-test/features/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/Count.feature b/gremlin-test/features/Count.feature
new file mode 100644
index 0000000..383eecf
--- /dev/null
+++ b/gremlin-test/features/Count.feature
@@ -0,0 +1,54 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Count Step
+
+  Scenario: Count all vertices
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().count()
+    """
+    When iterating
+    Then the result should be 6
+
+  Scenario: Count vertices after traversing both() twice
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().both().both().count()
+    """
+    When iterating
+    Then the result should be 30
+
+  Scenario: Count local
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().fold().count(Scope.local)
+    """
+    When iterating
+    Then the result should be 6
+
+  Scenario: Count no vertices
+    Given the modern graph
+    And the traversal of
+    """
+    g.V().has("no").count()
+    """
+    When iterating
+    Then the result should be 0
\ No newline at end of file


[09/26] tinkerpop git commit: TINKERPOP-1784 Add support for the various toy graphs

Posted by sp...@apache.org.
TINKERPOP-1784 Add support for the various toy graphs


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

Branch: refs/heads/TINKERPOP-1784
Commit: 21ccccdceeb73d0a7d4c4f12adfc0b2d106552e6
Parents: 1926dc4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 29 10:29:38 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 gremlin-python/pom.xml                          |  6 ++-
 .../src/main/jython/radish/feature_steps.py     |  2 +-
 .../src/main/jython/radish/terrain.py           | 39 +++++++++++++------
 .../remote/gremlin-server-integration.yaml      |  7 +---
 .../server/gremlin-server-integration.yaml      |  7 +---
 .../server/gremlin-server-performance.yaml      |  7 +---
 .../src/test/scripts/generate-all.groovy        | 40 ++++++++++++++++++++
 .../src/test/scripts/test-server-start.groovy   | 24 ++++++++++--
 .../test/scripts/tinkergraph-empty.properties   | 20 ++++++++++
 9 files changed, 117 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-python/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml
index cabaec9..1833233 100644
--- a/gremlin-python/pom.xml
+++ b/gremlin-python/pom.xml
@@ -521,12 +521,16 @@ limitations under the License.
                                             <value>${skipTests}</value>
                                         </property>
                                         <property>
+                                            <name>python</name>
+                                            <value>true</value>
+                                        </property>
+                                        <property>
                                             <name>gremlinServerDir</name>
                                             <value>${gremlin.server.dir}</value>
                                         </property>
                                         <property>
                                             <name>settingsFile</name>
-                                            <value>${gremlin.server.dir}/conf/gremlin-server-modern-py.yaml</value>
+                                            <value>${gremlin.server.dir}/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml</value>
                                         </property>
                                         <property>
                                             <name>executionName</name>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index e3b82c3..a298d6c 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -40,7 +40,7 @@ def add_parameter(step, param_name, param):
     if not hasattr(step.context, "traversal_params"):
         step.context.traversal_params = {}
 
-    step.context.traversal_params[param_name.encode('utf-8')] = __convert(param, step.context)
+    step.context.traversal_params[param_name] = __convert(param, step.context)
 
 
 @given("the traversal of")

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-python/src/main/jython/radish/terrain.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/terrain.py b/gremlin-python/src/main/jython/radish/terrain.py
index 303f64d..e88272b 100644
--- a/gremlin-python/src/main/jython/radish/terrain.py
+++ b/gremlin-python/src/main/jython/radish/terrain.py
@@ -32,20 +32,42 @@ tail = __.tail
 
 @before.each_scenario
 def prepare_traversal_source(scenario):
-    remote = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
-    scenario.context.remote_conn = {"modern": remote}
+    scenario.context.remote_conn = {}
+    scenario.context.lookup_v = {}
+    scenario.context.lookup_e = {}
+
+    __prepare(scenario, "modern", "gmodern")
+    __prepare(scenario, "classic", "gclassic")
+    __prepare(scenario, "crew", "gcrew")
+
+    remote = DriverRemoteConnection('ws://localhost:45940/gremlin', "ggraph")
+    scenario.context.remote_conn["empty"] = remote
+    g = Graph().traversal().withRemote(remote)
+    g.V().drop().iterate()
+
+
+@after.each_scenario
+def close_traversal_source(scenario):
+    scenario.context.remote_conn["modern"].close()
+    scenario.context.remote_conn["classic"].close()
+    scenario.context.remote_conn["crew"].close()
+
+
+def __prepare(scenario, graph_name, server_graph_name):
+    remote = DriverRemoteConnection('ws://localhost:45940/gremlin', server_graph_name)
+    scenario.context.remote_conn[graph_name] = remote
     g = Graph().traversal().withRemote(remote)
 
     # hold a map of name/vertex for use in asserting results
-    scenario.context.lookup_v = {"modern": g.V().group().by('name').by(tail()).next()}
+    scenario.context.lookup_v[graph_name] = g.V().group().by('name').by(tail()).next()
 
     # hold a map of the "name"/edge for use in asserting results - "name" in this context is in the form of
     # outgoingV-label->incomingV
-    projection_of_edges = g.E().group().\
+    projection_of_edges = g.E().group(). \
         by(project("o", "l", "i").
            by(outV().values("name")).
            by(label()).
-           by(inV().values("name"))).\
+           by(inV().values("name"))). \
         by(tail()).next()
     edges = {}
 
@@ -57,9 +79,4 @@ def prepare_traversal_source(scenario):
         i = re.search("i=(.+?)[,\}]", key).group(1)
         edges[o + "-" + l + "->" + i] = value
 
-    scenario.context.lookup_e = {"modern": edges}
-
-
-@after.each_scenario
-def close_traversal_source(scenario):
-    scenario.context.remote_conn["modern"].close()
+    scenario.context.lookup_e[graph_name] = edges

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
index 96db32f..d1e7ba6 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
@@ -41,12 +41,7 @@ serializers:
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {
-  consoleReporter: {enabled: true, interval: 180000},
-  csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
-  jmxReporter: {enabled: true},
-  slf4jReporter: {enabled: true, interval: 180000},
-  gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
-  graphiteReporter: {enabled: false, interval: 180000}}
+  slf4jReporter: {enabled: true, interval: 180000}}
 strictTransactionManagement: false
 maxInitialLineLength: 4096
 maxHeaderSize: 8192

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
index 18ac22e..f80c38a 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
@@ -37,12 +37,7 @@ serializers:
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {
-  consoleReporter: {enabled: true, interval: 180000},
-  csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
-  jmxReporter: {enabled: true},
-  slf4jReporter: {enabled: true, interval: 180000},
-  gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
-  graphiteReporter: {enabled: false, interval: 180000}}
+  slf4jReporter: {enabled: true, interval: 180000}}
 strictTransactionManagement: false
 maxInitialLineLength: 4096
 maxHeaderSize: 8192

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
index 330a643..d30635d 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-performance.yaml
@@ -34,12 +34,7 @@ serializers:
 processors:
   - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
 metrics: {
-  consoleReporter: {enabled: true, interval: 180000},
-  csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
-  jmxReporter: {enabled: true},
-  slf4jReporter: {enabled: true, interval: 180000},
-  gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
-  graphiteReporter: {enabled: false, interval: 180000}}
+  slf4jReporter: {enabled: true, interval: 180000}}
 strictTransactionManagement: false
 maxInitialLineLength: 4096
 maxHeaderSize: 8192

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-server/src/test/scripts/generate-all.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/scripts/generate-all.groovy b/gremlin-server/src/test/scripts/generate-all.groovy
new file mode 100644
index 0000000..b6be405
--- /dev/null
+++ b/gremlin-server/src/test/scripts/generate-all.groovy
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+// an init script that returns a Map allows explicit setting of global bindings.
+def globals = [:]
+
+// Generates the modern graph into an "empty" TinkerGraph via LifeCycleHook.
+// Note that the name of the key in the "global" map is unimportant.
+globals << [hook : [
+  onStartUp: { ctx ->
+    TinkerFactory.generateClassic(classic)
+    TinkerFactory.generateModern(modern)
+    TinkerFactory.generateTheCrew(crew)
+    grateful.io(gryo()).readGraph('data/grateful-dead.kryo')
+  }
+] as LifeCycleHook]
+
+// add default TraversalSource instances for each graph instance
+globals << [gclassic : classic.traversal()]
+globals << [gmodern : modern.traversal()]
+globals << [gcrew : crew.traversal()]
+globals << [ggraph : graph.traversal()]
+globals << [g : modern.traversal()]
+globals << [ggrateful : grateful.traversal()]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-server/src/test/scripts/test-server-start.groovy
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/scripts/test-server-start.groovy b/gremlin-server/src/test/scripts/test-server-start.groovy
index 8ea08a9..d793d26 100644
--- a/gremlin-server/src/test/scripts/test-server-start.groovy
+++ b/gremlin-server/src/test/scripts/test-server-start.groovy
@@ -25,8 +25,16 @@ if (Boolean.parseBoolean(skipTests)) return
 
 log.info("Starting Gremlin Server instances for native testing of ${executionName}")
 def settings = Settings.read("${settingsFile}")
-settings.graphs.graph = gremlinServerDir + "/conf/tinkergraph-empty.properties"
-settings.scriptEngines["gremlin-groovy"].scripts = [gremlinServerDir + "/scripts/generate-modern.groovy"]
+settings.graphs.graph = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.classic = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.modern = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.crew = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.grateful = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.scriptEngines["gremlin-groovy"].scripts = [gremlinServerDir + "/src/test/scripts/generate-all.groovy"]
+if (Boolean.parseBoolean(python)) {
+    settings.scriptEngines["gremlin-python"] = new Settings.ScriptEngineSettings()
+    settings.scriptEngines["gremlin-jython"] = new Settings.ScriptEngineSettings()
+}
 settings.port = 45940
 
 def server = new GremlinServer(settings)
@@ -36,8 +44,16 @@ project.setContextValue("gremlin.server", server)
 log.info("Gremlin Server with no authentication started on port 45940")
 
 def settingsSecure = Settings.read("${settingsFile}")
-settingsSecure.graphs.graph = gremlinServerDir + "/conf/tinkergraph-empty.properties"
-settingsSecure.scriptEngines["gremlin-groovy"].scripts = [gremlinServerDir + "/scripts/generate-modern.groovy"]
+settings.graphs.graph = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.classic = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.modern = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.crew = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settings.graphs.grateful = gremlinServerDir + "/src/test/scripts/tinkergraph-empty.properties"
+settingsSecure.scriptEngines["gremlin-groovy"].scripts = [gremlinServerDir + "/src/test/scripts/generate-all.groovy"]
+if (Boolean.parseBoolean(python)) {
+    settingsSecure.scriptEngines["gremlin-python"] = new Settings.ScriptEngineSettings()
+    settingsSecure.scriptEngines["gremlin-jython"] = new Settings.ScriptEngineSettings()
+}
 settingsSecure.port = 45941
 settingsSecure.authentication.className = SimpleAuthenticator.class.name
 settingsSecure.authentication.config = [credentialsDb: gremlinServerDir + "/conf/tinkergraph-credentials.properties", credentialsDbLocation: gremlinServerDir + "/data/credentials.kryo"]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/21ccccdc/gremlin-server/src/test/scripts/tinkergraph-empty.properties
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/scripts/tinkergraph-empty.properties b/gremlin-server/src/test/scripts/tinkergraph-empty.properties
new file mode 100644
index 0000000..211b9e4
--- /dev/null
+++ b/gremlin-server/src/test/scripts/tinkergraph-empty.properties
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
+gremlin.tinkergraph.vertexIdManager=INTEGER
+gremlin.tinkergraph.edgeIdManager=INTEGER
+gremlin.tinkergraph.vertexPropertyIdManager=INTEGER
\ No newline at end of file


[04/26] tinkerpop git commit: TINKERPOP-1784 Expanded GLV test framework a bit further

Posted by sp...@apache.org.
TINKERPOP-1784 Expanded GLV test framework a bit further

Developed methods for vertices/maps and a way to assert unordered results.


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

Branch: refs/heads/TINKERPOP-1784
Commit: 9aa198b92dd929db9244c8094a564da2f6f8b5ac
Parents: cda7a5a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 22 10:52:20 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:51 2017 -0400

----------------------------------------------------------------------
 gremlin-python/pom.xml                          | 14 +---
 .../src/main/jython/radish/feature_steps.py     | 87 ++++++++++++++++----
 .../src/main/jython/radish/terrain.py           | 11 ++-
 gremlin-python/src/main/jython/setup.py         |  3 +-
 gremlin-test/features/filter/Coin.feature       | 43 ++++++++++
 gremlin-test/features/filter/Has.feature        | 30 +++++++
 gremlin-test/features/map/Coin.feature          | 42 ----------
 .../features/sideEffect/GroupCount.feature      | 29 +++++++
 .../step/sideEffect/GroupCountTest.java         |  2 +-
 9 files changed, 187 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-python/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml
index 4ab5f37..cabaec9 100644
--- a/gremlin-python/pom.xml
+++ b/gremlin-python/pom.xml
@@ -339,11 +339,7 @@ limitations under the License.
                                         </exec>
                                         <exec dir="${project.build.directory}/python2" executable="env/bin/pip"
                                               failonerror="true">
-                                            <arg line="install wheel"/>
-                                        </exec>
-                                        <exec dir="${project.build.directory}/python2" executable="env/bin/pip"
-                                              failonerror="true">
-                                            <arg line="install radish-bdd"/>
+                                            <arg line="install wheel radish-bdd PyHamcrest"/>
                                         </exec>
                                         <exec dir="${project.build.directory}/python3" executable="virtualenv"
                                               failonerror="true">
@@ -351,11 +347,7 @@ limitations under the License.
                                         </exec>
                                         <exec dir="${project.build.directory}/python3" executable="env/bin/pip"
                                               failonerror="true">
-                                            <arg line="install wheel"/>
-                                        </exec>
-                                        <exec dir="${project.build.directory}/python3" executable="env/bin/pip"
-                                              failonerror="true">
-                                            <arg line="install radish-bdd"/>
+                                            <arg line="install wheel radish-bdd PyHamcrest"/>
                                         </exec>
                                         <exec dir="${project.build.directory}/python-packaged" executable="virtualenv"
                                               failonerror="true">
@@ -455,7 +447,7 @@ limitations under the License.
                                         <exec executable="env/bin/radish" dir="${project.build.directory}/python2"
                                               failonerror="true">
                                             <env key="PYTHONPATH" value=""/>
-                                            <arg line="-b ${project.build.directory}/python2/radish ${project.basedir}/../gremlin-test/features/"/>
+                                            <arg line="-b ${project.build.directory}/python2/radish ${project.basedir}/../gremlin-test/features/"/> <!-- -no-line-jump -->
                                         </exec>                                                                  
                                     </target>
                                 </configuration>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 61297ff..069768d 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -17,24 +17,36 @@ specific language governing permissions and limitations
 under the License.
 '''
 
-from gremlin_python.structure.graph import Graph
+import json
+from gremlin_python.structure.graph import Graph, Vertex, Edge
 from gremlin_python.process.graph_traversal import __
-from gremlin_python.process.traversal import Scope
-from radish import before, given, when, then
+from gremlin_python.process.traversal import P, Scope
+from radish import given, when, then, custom_type, register_custom_type, TypeBuilder
+from hamcrest import *
 
 out = __.out
 
 
-@given("the {graphName:w} graph")
-def choose_graph(step, graphName):
+@custom_type('words', r'\w+')
+def parse_word(text):
+    return str(text)
+
+
+register_custom_type(WordList=TypeBuilder.with_many(parse_word, listsep=','))
+
+
+@given("the {graph_name:w} graph")
+def choose_graph(step, graph_name):
     # only have modern atm but graphName would be used to select the right one
-    step.context.g = Graph().traversal().withRemote(step.context.remote_conn_modern)
+    step.context.g = Graph().traversal().withRemote(step.context.remote_conn[graph_name])
 
 
 @given("the traversal of")
 def translate_traversal(step):
     g = step.context.g
-    step.context.traversal = eval(step.text, {"g": g, "Scope": Scope})
+    step.context.traversal = eval(step.text, {"g": g,
+                                              "P": P,
+                                              "Scope": Scope})
 
 
 @when("iterated to list")
@@ -45,33 +57,74 @@ def iterate_the_traversal(step):
 @then("the result should be {characterized_as:w}")
 def assert_result(step, characterized_as):
     if characterized_as == "empty":
-        assert len(step.context.result) == 0
+        assert_that(len(step.context.result), equal_to(0))
     elif characterized_as == "ordered":
         data = step.table
     
         # results from traversal should have the same number of entries as the feature data table
-        assert len(step.context.result) == len(data)
+        assert_that(len(step.context.result), equal_to(len(data)))
 
         # assert the results by type where the first column will hold the type and the second column
         # the data to assert. the contents of the second column will be dependent on the type specified
-        # in te first column
+        # in the first column
         for ix, line in enumerate(data):
             if line[0] == "numeric":
-                assert long(step.context.result[ix]) == long(line[1])
+                assert_that(long(step.context.result[ix]), equal_to(long(line[1])))
             elif line[0] == "string":
-                assert str(step.context.result[ix]) == str(line[1])
+                assert_that(str(step.context.result[ix]), equal_to(str(line[1])))
+            elif line[0] == "vertex":
+                assert_that(step.context.result[ix].label, equal_to(line[1]))
+            elif line[0] == "map":
+                assert_that(step.context.result[ix], json.loads(line[1]))
             else:
-                assert step.context.result[ix] == line[1]
+                raise ValueError("unknown type of " + line[0])
     elif characterized_as == "unordered":
         data = step.table
 
         # results from traversal should have the same number of entries as the feature data table
-        assert len(step.context.result) == len(data)
+        assert_that(len(step.context.result), equal_to(len(data)))
+
+        results_to_test = list(step.context.result)
+
+        for line in data:
+            if line[0] == "numeric":
+                val = long(line[1])
+                assert_that(val, is_in(list(map(long, results_to_test))))
+                results_to_test.remove(val)
+            elif line[0] == "string":
+                val = str(line[1])
+                assert_that(val, is_in(list(map(str, results_to_test))))
+                results_to_test.remove(val)
+            elif line[0] == "vertex":
+                val = str(line[1])
+                v = step.context.lookup["modern"][val]
+                assert_that(v, is_in(results_to_test))
+                results_to_test.remove(v)
+            elif line[0] == "map":
+                val = json.load(line[1])
+                assert_that(val, is_in(results_to_test))
+                results_to_test.remove(val)
+            else:
+                raise ValueError("unknown type of " + line[0])
+
+        assert_that(len(results_to_test), is_(0))
+    else:
+        raise ValueError("unknown data characterization of " + characterized_as)
 
 
+@then("the number of results should be {number:d}")
+def assert_number_of_results(step, number):
+    assert_that(len(step.context.result), equal_to(number))
 
-@then("the results should be empty")
-def assert_result(step):
-    assert len(step.context.result) == 0
 
+@then("the results should all be {element_type:w}")
+def assert_elements(step, element_type):
+    if element_type == "vertices":
+        t = Vertex
+    elif element_type == "edges":
+        t = Edge
+    else:
+        raise ValueError("unknown element type of " + element_type)
 
+    for r in step.context.result:
+        assert_that(r, instance_of(t))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-python/src/main/jython/radish/terrain.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/terrain.py b/gremlin-python/src/main/jython/radish/terrain.py
index 389f39c..59ec8d0 100644
--- a/gremlin-python/src/main/jython/radish/terrain.py
+++ b/gremlin-python/src/main/jython/radish/terrain.py
@@ -17,15 +17,22 @@ specific language governing permissions and limitations
 under the License.
 '''
 
+from gremlin_python.structure.graph import Graph
+from gremlin_python.process.graph_traversal import __
 from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
 from radish import before, after
 
 
 @before.each_scenario
 def prepare_traversal_source(scenario):
-    scenario.context.remote_conn_modern = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+    remote = DriverRemoteConnection('ws://localhost:45940/gremlin', 'g')
+    scenario.context.remote_conn = {"modern": remote}
+    g = Graph().traversal().withRemote(remote)
+
+    # hold a map of name/vertex for use in asserting results
+    scenario.context.lookup = {"modern": g.V().group().by('name').by(__.tail()).next()}
 
 
 @after.each_scenario
 def close_traversal_source(scenario):
-    scenario.context.remote_conn_modern.close()
+    scenario.context.remote_conn["modern"].close()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-python/src/main/jython/setup.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/setup.py b/gremlin-python/src/main/jython/setup.py
index fddd7c8..4498e5b 100644
--- a/gremlin-python/src/main/jython/setup.py
+++ b/gremlin-python/src/main/jython/setup.py
@@ -71,7 +71,8 @@ setup(
     tests_require=[
         'pytest',
         'mock',
-        'radish-bdd'
+        'radish-bdd',
+        'PyHamcrest'
     ],
     install_requires=install_requires,
     classifiers=[

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-test/features/filter/Coin.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Coin.feature b/gremlin-test/features/filter/Coin.feature
new file mode 100644
index 0000000..1b88f58
--- /dev/null
+++ b/gremlin-test/features/filter/Coin.feature
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Step - coin()
+
+  Scenario: Use coin at 1.0
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().coin(1.0)
+      """
+    When iterated to list
+    Then the result should be unordered
+      | vertex | marko  |
+      | vertex | vadas  |
+      | vertex | lop    |
+      | vertex | josh   |
+      | vertex | ripple |
+      | vertex | peter  |
+
+
+  Scenario: Use coin at 0.0
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().coin(0.0)
+      """
+    When iterated to list
+    Then the result should be empty
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-test/features/filter/Has.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Has.feature b/gremlin-test/features/filter/Has.feature
new file mode 100644
index 0000000..0bb82e0
--- /dev/null
+++ b/gremlin-test/features/filter/Has.feature
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Step - has()
+
+  Scenario: Use has() with P.gt()
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().has("age", P.gt(30))
+      """
+    When iterated to list
+    Then the result should be unordered
+      | vertex | josh   |
+      | vertex | peter  |
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-test/features/map/Coin.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Coin.feature b/gremlin-test/features/map/Coin.feature
deleted file mode 100644
index b21bd70..0000000
--- a/gremlin-test/features/map/Coin.feature
+++ /dev/null
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-Feature: Step - coin()
-
-  Scenario: Use coin at 1.0
-    Given the modern graph
-    And the traversal of
-      """
-      g.V().coin(1.0)
-      """
-    When iterated to list
-    Then the result should be unordered as
-      | vertex | person   |
-      | vertex | person   |
-      | vertex | person   |
-      | vertex | person   |
-      | vertex | software |
-      | vertex | software |
-
-  Scenario: Use coin at 0.0
-    Given the modern graph
-    And the traversal of
-      """
-      g.V().coin(0.0)
-      """
-    When iterated to list
-    Then the result should be empty
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-test/features/sideEffect/GroupCount.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/GroupCount.feature b/gremlin-test/features/sideEffect/GroupCount.feature
new file mode 100644
index 0000000..1789b32
--- /dev/null
+++ b/gremlin-test/features/sideEffect/GroupCount.feature
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Step - groupCount()
+
+  Scenario: Use has() with P.gt()
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().out("created").groupCount().by("name")
+      """
+    When iterated to list
+    Then the result should be ordered
+      | map | {"ripple": 1, "lop": 3} |
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9aa198b9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
index 9bd515c..34011ac 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupCountTest.java
@@ -94,7 +94,7 @@ public abstract class GroupCountTest extends AbstractGremlinProcessTest {
         checkSideEffects(traversal.asAdmin().getSideEffects(), "a", HashMap.class);
     }
 
-    private static void assertCommonA(Traversal<Vertex, Map<String, Long>> traversal) {
+    private static void assertCommonA(final Traversal<Vertex, Map<String, Long>> traversal) {
         final Map<String, Long> map = traversal.next();
         assertEquals(map.size(), 2);
         assertEquals(Long.valueOf(3l), map.get("lop"));


[19/26] tinkerpop git commit: TINKERPOP-1784 Added do nothings for unsupported tests

Posted by sp...@apache.org.
TINKERPOP-1784 Added do nothings for unsupported tests


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

Branch: refs/heads/TINKERPOP-1784
Commit: 0b2fe19e98ba1e491615e8d17e2c887e25666018
Parents: 8ae2dd6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun Oct 1 07:28:31 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     |  2 +-
 gremlin-test/features/map/Vertex.feature        |  5 ++-
 .../features/sideEffect/GroupCount.feature      | 39 +++++++++-----------
 3 files changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0b2fe19e/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 340f84a..5b11ca1 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -82,7 +82,7 @@ def assert_result(step, characterized_as):
         raise ValueError("unknown data characterization of " + characterized_as)
 
 
-@then("nothing should happen")
+@then("nothing should happen because")
 def nothing_happening(step):
     return
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0b2fe19e/gremlin-test/features/map/Vertex.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Vertex.feature b/gremlin-test/features/map/Vertex.feature
index 37e398b..1c9849e 100644
--- a/gremlin-test/features/map/Vertex.feature
+++ b/gremlin-test/features/map/Vertex.feature
@@ -420,7 +420,10 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
 
   Scenario: g_VX1_2_3_4X_name
     Given an unsupported test
-    Then nothing should happen
+    Then nothing should happen because
+      """
+      the test manipulates a static dataset which is not supported by the language of the feature files"
+      """
 
   Scenario: g_V_hasLabelXpersonX_V_hasLabelXsoftwareX_name
     Given the modern graph

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0b2fe19e/gremlin-test/features/sideEffect/GroupCount.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/GroupCount.feature b/gremlin-test/features/sideEffect/GroupCount.feature
index bfb7363..d68a964 100644
--- a/gremlin-test/features/sideEffect/GroupCount.feature
+++ b/gremlin-test/features/sideEffect/GroupCount.feature
@@ -17,7 +17,7 @@
 
 Feature: Step - groupCount()
 
-  Scenario: Group count vertices that have incoming created edges by their name
+  Scenario: g_V_outXcreatedX_groupCount_byXnameX
     Given the modern graph
     And the traversal of
       """
@@ -27,23 +27,20 @@ Feature: Step - groupCount()
     Then the result should be ordered
       | m[{"ripple": 1, "lop": 3}] |
 
-# NOT SUPPORTED UNTIL GRAPHSON 3.X WHICH HAS SUPPORT FOR NON-STRING KEYS
-#  Scenario: Edge count distribution
-#    Given the modern graph
-#    And the traversal of
-#      """
-#      g.V().groupCount().by(bothE().count())
-#      """
-#    When iterated to list
-#    Then the result should be ordered
-#      | m[{"d[1]": 3, "d[3]": 3}] |
-#
-#  Scenario: Group count vertices, cap to retrieve the map and unfold it to group count again
-#    Given the modern graph
-#    And the traversal of
-#      """
-#      g.V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a")
-#      """
-#    When iterated to list
-#    Then the result should be ordered
-#      | m[{"v[marko]": 6, "v[vadas]": 2, "v[lop]": 6, "v[josh]": 6, "v[ripple]": 2, "v[peter]": 2}] |
\ No newline at end of file
+  Scenario: g_V_groupCount_byXbothE_countX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      The result returned is not supported under GraphSON 2.x and therefore cannot be properly asserted. More
+      specifically it has vertex keys which basically get toString()'d under GraphSON 2.x. This test can be supported
+      with GraphSON 3.x.
+      """
+
+  Scenario: g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX
+    Given an unsupported test
+    Then nothing should happen because
+      """
+      The result returned is not supported under GraphSON 2.x and therefore cannot be properly asserted. More
+      specifically it has vertex keys which basically get toString()'d under GraphSON 2.x. This test can be supported
+      with GraphSON 3.x.
+      """
\ No newline at end of file


[05/26] tinkerpop git commit: TINKERPOP-1784 Added coin() gherkin tests and refactored python

Posted by sp...@apache.org.
TINKERPOP-1784 Added coin() gherkin tests and refactored python


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

Branch: refs/heads/TINKERPOP-1784
Commit: cda7a5a3418d34f0f193c0eb5f69dbedd7182fdf
Parents: aea5a63
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 20 18:38:49 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:51 2017 -0400

----------------------------------------------------------------------
 .../main/jython/radish/count_features_step.py   | 50 -------------
 .../src/main/jython/radish/feature_steps.py     | 77 ++++++++++++++++++++
 gremlin-test/features/map/Coin.feature          | 42 +++++++++++
 gremlin-test/features/map/Count.feature         | 46 ++++++------
 4 files changed, 144 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cda7a5a3/gremlin-python/src/main/jython/radish/count_features_step.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/count_features_step.py b/gremlin-python/src/main/jython/radish/count_features_step.py
deleted file mode 100644
index ec04551..0000000
--- a/gremlin-python/src/main/jython/radish/count_features_step.py
+++ /dev/null
@@ -1,50 +0,0 @@
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you 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.
-'''
-
-from gremlin_python.structure.graph import Graph
-from gremlin_python.process.graph_traversal import __
-from gremlin_python.process.traversal import Scope
-from radish import before, given, when, then
-
-out = __.out
-
-
-@given("the {graphName:w} graph")
-def choose_graph(step, graphName):
-    # only have modern atm but graphName would be used to select the right one
-    step.context.g = Graph().traversal().withRemote(step.context.remote_conn_modern)
-
-
-@given("the traversal of")
-def translate_traversal(step):
-    g = step.context.g
-    step.context.traversal = eval(step.text, {"g": g, "Scope": Scope})
-
-
-@when("iterating")
-def iterate_the_traversal(step):
-    step.context.result = step.context.traversal.toList()
-
-
-@then("the result should be {number:d}")
-def assert_single_result_of_number(step, number):
-    assert len(step.context.result) == 1
-    assert step.context.result[0] == number
-
-

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cda7a5a3/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
new file mode 100644
index 0000000..61297ff
--- /dev/null
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -0,0 +1,77 @@
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+'''
+
+from gremlin_python.structure.graph import Graph
+from gremlin_python.process.graph_traversal import __
+from gremlin_python.process.traversal import Scope
+from radish import before, given, when, then
+
+out = __.out
+
+
+@given("the {graphName:w} graph")
+def choose_graph(step, graphName):
+    # only have modern atm but graphName would be used to select the right one
+    step.context.g = Graph().traversal().withRemote(step.context.remote_conn_modern)
+
+
+@given("the traversal of")
+def translate_traversal(step):
+    g = step.context.g
+    step.context.traversal = eval(step.text, {"g": g, "Scope": Scope})
+
+
+@when("iterated to list")
+def iterate_the_traversal(step):
+    step.context.result = step.context.traversal.toList()
+
+
+@then("the result should be {characterized_as:w}")
+def assert_result(step, characterized_as):
+    if characterized_as == "empty":
+        assert len(step.context.result) == 0
+    elif characterized_as == "ordered":
+        data = step.table
+    
+        # results from traversal should have the same number of entries as the feature data table
+        assert len(step.context.result) == len(data)
+
+        # assert the results by type where the first column will hold the type and the second column
+        # the data to assert. the contents of the second column will be dependent on the type specified
+        # in te first column
+        for ix, line in enumerate(data):
+            if line[0] == "numeric":
+                assert long(step.context.result[ix]) == long(line[1])
+            elif line[0] == "string":
+                assert str(step.context.result[ix]) == str(line[1])
+            else:
+                assert step.context.result[ix] == line[1]
+    elif characterized_as == "unordered":
+        data = step.table
+
+        # results from traversal should have the same number of entries as the feature data table
+        assert len(step.context.result) == len(data)
+
+
+
+@then("the results should be empty")
+def assert_result(step):
+    assert len(step.context.result) == 0
+
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cda7a5a3/gremlin-test/features/map/Coin.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Coin.feature b/gremlin-test/features/map/Coin.feature
new file mode 100644
index 0000000..b21bd70
--- /dev/null
+++ b/gremlin-test/features/map/Coin.feature
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+Feature: Step - coin()
+
+  Scenario: Use coin at 1.0
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().coin(1.0)
+      """
+    When iterated to list
+    Then the result should be unordered as
+      | vertex | person   |
+      | vertex | person   |
+      | vertex | person   |
+      | vertex | person   |
+      | vertex | software |
+      | vertex | software |
+
+  Scenario: Use coin at 0.0
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().coin(0.0)
+      """
+    When iterated to list
+    Then the result should be empty
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cda7a5a3/gremlin-test/features/map/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Count.feature b/gremlin-test/features/map/Count.feature
index 383eecf..316976e 100644
--- a/gremlin-test/features/map/Count.feature
+++ b/gremlin-test/features/map/Count.feature
@@ -15,40 +15,44 @@
 # specific language governing permissions and limitations
 # under the License.
 
-Feature: Count Step
+Feature: Step - count()
 
   Scenario: Count all vertices
     Given the modern graph
     And the traversal of
-    """
-    g.V().count()
-    """
-    When iterating
-    Then the result should be 6
+      """
+      g.V().count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | numeric | 6 |
 
   Scenario: Count vertices after traversing both() twice
     Given the modern graph
     And the traversal of
-    """
-    g.V().both().both().count()
-    """
-    When iterating
-    Then the result should be 30
+      """
+      g.V().both().both().count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | numeric | 30 |
 
   Scenario: Count local
     Given the modern graph
     And the traversal of
-    """
-    g.V().fold().count(Scope.local)
-    """
-    When iterating
-    Then the result should be 6
+      """
+      g.V().fold().count(Scope.local)
+      """
+    When iterated to list
+    Then the result should be ordered
+      | numeric | 6 |
 
   Scenario: Count no vertices
     Given the modern graph
     And the traversal of
-    """
-    g.V().has("no").count()
-    """
-    When iterating
-    Then the result should be 0
\ No newline at end of file
+      """
+      g.V().has("no").count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | numeric | 0 |
\ No newline at end of file


[02/26] tinkerpop git commit: Update links to all docs pages in Docker build and emulate the published directory structure. This way the docs are easier to navigate in local builds.

Posted by sp...@apache.org.
Update links to all docs pages in Docker build and emulate the published directory structure. This way the docs are easier to navigate in local builds.


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

Branch: refs/heads/TINKERPOP-1784
Commit: 5e3977184523e005ac60e3dcaac199f3d63335fd
Parents: 7b0bd95
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Fri Sep 29 10:14:46 2017 -0700
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Mon Oct 2 09:58:59 2017 -0700

----------------------------------------------------------------------
 docker/scripts/build.sh | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5e397718/docker/scripts/build.sh
----------------------------------------------------------------------
diff --git a/docker/scripts/build.sh b/docker/scripts/build.sh
index bc22de9..5ef74fc 100755
--- a/docker/scripts/build.sh
+++ b/docker/scripts/build.sh
@@ -96,8 +96,14 @@ if [ ! -z "${BUILD_USER_DOCS}" ]; then
   mkdir -p ~/.groovy
   cp docker/resources/groovy/grapeConfig.xml ~/.groovy/
   rm -rf /tmp/neo4j
+  grep -l 'http://tinkerpop.apache.org/docs/x.y.z' $(find docs/src -name "*.asciidoc" | grep -v '^.docs/src/upgrade/') | xargs sed -i 's@http://tinkerpop.apache.org/docs/x.y.z@/docs/x.y.z@g'
   bin/process-docs.sh || exit 1
 
+  # emulate published directory structure
+  VERSION=$(cat pom.xml | grep -A1 '<artifactId>tinkerpop</artifactId>' | grep '<version>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}')
+  mkdir target/docs/htmlsingle/docs
+  ln -s .. target/docs/htmlsingle/docs/${VERSION}
+
   # start a simple HTTP server
   IP=$(ifconfig | grep -o 'inet addr:[0-9.]*' | cut -f2 -d ':' | head -n1)
   cd target/docs/htmlsingle/


[15/26] tinkerpop git commit: TINKERPOP-1784 Added test to enforce implementation of process tests as features

Posted by sp...@apache.org.
TINKERPOP-1784 Added test to enforce implementation of process tests as features


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

Branch: refs/heads/TINKERPOP-1784
Commit: 5aa64a0518d6c35563fdc3302f783885bf860a8a
Parents: 6c60bd1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 27 13:26:17 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 gremlin-test/features/filter/Coin.feature       |  4 +-
 gremlin-test/features/map/Count.feature         | 18 +++-
 .../gremlin/structure/FeatureCoverageTest.java  | 92 ++++++++++++++++++++
 3 files changed, 108 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5aa64a05/gremlin-test/features/filter/Coin.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Coin.feature b/gremlin-test/features/filter/Coin.feature
index 1b88f58..802ebdc 100644
--- a/gremlin-test/features/filter/Coin.feature
+++ b/gremlin-test/features/filter/Coin.feature
@@ -17,7 +17,7 @@
 
 Feature: Step - coin()
 
-  Scenario: Use coin at 1.0
+  Scenario: g_V_coinX1X
     Given the modern graph
     And the traversal of
       """
@@ -33,7 +33,7 @@ Feature: Step - coin()
       | vertex | peter  |
 
 
-  Scenario: Use coin at 0.0
+  Scenario: g_V_coinX0X
     Given the modern graph
     And the traversal of
       """

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5aa64a05/gremlin-test/features/map/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Count.feature b/gremlin-test/features/map/Count.feature
index 316976e..1233ed3 100644
--- a/gremlin-test/features/map/Count.feature
+++ b/gremlin-test/features/map/Count.feature
@@ -17,7 +17,7 @@
 
 Feature: Step - count()
 
-  Scenario: Count all vertices
+  Scenario: g_V_count
     Given the modern graph
     And the traversal of
       """
@@ -27,7 +27,17 @@ Feature: Step - count()
     Then the result should be ordered
       | numeric | 6 |
 
-  Scenario: Count vertices after traversing both() twice
+  Scenario: g_V_out_count
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().out().count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | numeric | 6 |
+
+  Scenario: g_V_both_both_count
     Given the modern graph
     And the traversal of
       """
@@ -37,7 +47,7 @@ Feature: Step - count()
     Then the result should be ordered
       | numeric | 30 |
 
-  Scenario: Count local
+  Scenario: g_V_fold_countXlocalX
     Given the modern graph
     And the traversal of
       """
@@ -47,7 +57,7 @@ Feature: Step - count()
     Then the result should be ordered
       | numeric | 6 |
 
-  Scenario: Count no vertices
+  Scenario: g_V_hasXnoX_count
     Given the modern graph
     And the traversal of
       """

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5aa64a05/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java
new file mode 100644
index 0000000..791d44e
--- /dev/null
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/structure/FeatureCoverageTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.tinkerpop.gremlin.structure;
+
+import org.apache.tinkerpop.gremlin.process.ProcessStandardSuite;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class FeatureCoverageTest {
+
+    private static Pattern scenarioName = Pattern.compile("^\\s*Scenario:\\s*(.*)$");
+
+    @Test
+    public void shouldImplementAllProcessTestsAsFeatures() throws Exception {
+
+        // TEMPORARY while test framework is under development - all tests should ultimately be included
+        final List<Class<?>> temp = Arrays.asList(CoinTest.class);
+
+        final Field field = ProcessStandardSuite.class.getDeclaredField("testsToEnforce");
+        field.setAccessible(true);
+        final Class<?>[] testsToEnforce = (Class<?>[]) field.get(null);
+
+        final List<Class<?>> testClassesToEnforce = Stream.of(testsToEnforce).filter(temp::contains).collect(Collectors.toList());
+        for (Class<?> t : testClassesToEnforce) {
+            final String packge = t.getPackage().getName();
+            final String group = packge.substring(packge.lastIndexOf(".") + 1, packge.length());
+            final String featureFileName = "features" + File.separator +
+                                           group + File.separator +
+                                           t.getSimpleName().replace("Test", "") + ".feature";
+            final Set<String> testMethods = Stream.of(t.getDeclaredMethods())
+                    .filter(m -> m.isAnnotationPresent(Test.class))
+                    .map(Method::getName).collect(Collectors.toSet());
+
+            final File featureFile = new File(featureFileName);
+            assertThat(featureFile.exists(), is(true));
+            assertThat(featureFile.isFile(), is(true));
+
+            final Set<String> testsInFeatureFile = new HashSet<>();
+            final InputStream is = new FileInputStream(featureFile);
+            final BufferedReader buf = new BufferedReader(new InputStreamReader(is));
+            String line = buf.readLine();
+            while(line != null){
+                final Matcher matcher = scenarioName.matcher(line);
+                if (matcher.matches())
+                    testsInFeatureFile.add(matcher.group(1));
+                line = buf.readLine();
+            }
+
+            assertEquals("All test methods are not implemented in the " + featureFileName, testMethods, testsInFeatureFile);
+        }
+    }
+}


[12/26] tinkerpop git commit: TINKERPOP-1784 Refactored the assertion logic for ordered/unordered

Posted by sp...@apache.org.
TINKERPOP-1784 Refactored the assertion logic for ordered/unordered


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

Branch: refs/heads/TINKERPOP-1784
Commit: 9a15c432e9498d01043e0d5fbfe3418dfcd625c1
Parents: 01a6d77
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 28 15:17:14 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 41 ++++++++++----------
 1 file changed, 20 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9a15c432/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 7a4a30a..2db5922 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -68,9 +68,9 @@ def assert_result(step, characterized_as):
     if characterized_as == "empty":
         assert_that(len(step.context.result), equal_to(0))
     elif characterized_as == "ordered":
-        __ordered_assertion(step)
+        __table_assertion(step.table, step.context.result, step.context, True)
     elif characterized_as == "unordered":
-        __unordered_assertion(step)
+        __table_assertion(step.table, step.context.result, step.context, False)
     else:
         raise ValueError("unknown data characterization of " + characterized_as)
 
@@ -100,32 +100,31 @@ def __convert(val, ctx):
     else:
         return val
 
+#
+# def __ordered_assertion(data, result, ctx):
+#     # results from traversal should have the same number of entries as the feature data table
+#     assert_that(len(result), equal_to(len(data)))
+#
+#     # assert the results in order they are expected in the data from the features file
+#     for ix, line in enumerate(data):
+#         assert_that(result[ix], equal_to(__convert(line[0], ctx)))
+#
 
-def __ordered_assertion(step):
-    data = step.table
 
+def __table_assertion(data, result, ctx, ordered):
     # results from traversal should have the same number of entries as the feature data table
-    assert_that(len(step.context.result), equal_to(len(data)))
+    assert_that(len(result), equal_to(len(data)))
 
-    # assert the results by type where the first column will hold the type and the second column
-    # the data to assert. the contents of the second column will be dependent on the type specified
-    # in the first column
-    for ix, line in enumerate(data):
-        assert_that(step.context.result[ix], equal_to(__convert(line[0], step.context)))
-
-def __unordered_assertion(step):
-    data = step.table
-
-    # results from traversal should have the same number of entries as the feature data table
-    assert_that(len(step.context.result), equal_to(len(data)))
-
-    results_to_test = list(step.context.result)
+    results_to_test = list(result)
 
     # finds a match in the results for each line of data to assert and then removes that item
     # from the list - in the end there should be no items left over and each will have been asserted
-    for line in data:
-        val = __convert(line[0], step.context)
-        assert_that(val, is_in(results_to_test))
+    for ix, line in enumerate(data):
+        val = __convert(line[0], ctx)
+        if ordered:
+            assert_that(results_to_test[ix], equal_to(val))
+        else:
+            assert_that(val, is_in(results_to_test))
         results_to_test.remove(val)
 
     assert_that(len(results_to_test), is_(0))


[25/26] tinkerpop git commit: TINKERPOP-1784 Get all count() tests working

Posted by sp...@apache.org.
TINKERPOP-1784 Get all count() tests working

Needed to add support for cleaning up traversal strings to more properly handle reserved python words.


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

Branch: refs/heads/TINKERPOP-1784
Commit: 8445f630dd60b5c3cd67b0136fa22a8d73336ddc
Parents: 0b2fe19
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Oct 2 14:59:59 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:20:24 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 15 ++++---
 gremlin-test/features/map/Count.feature         | 45 +++++++++++++++++++-
 .../gremlin/process/FeatureCoverageTest.java    |  6 ++-
 3 files changed, 59 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8445f630/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 5b11ca1..11cc86e 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -25,8 +25,9 @@ from gremlin_python.process.traversal import P, Scope, Column, Direction
 from radish import given, when, then
 from hamcrest import *
 
-regex_as = re.compile(r"\.as\(")
-regex_in = re.compile(r"\.in\(")
+regex_as = re.compile(r"([(.])as\(")
+regex_in = re.compile(r"([(.])in\(")
+regex_is = re.compile(r"([(.])is\(")
 
 
 @given("the {graph_name:w} graph")
@@ -57,11 +58,14 @@ def translate_traversal(step):
          "Direction": Direction,
          "P": P,
          "Scope": Scope,
-         "bothE": __.bothE}
+         "bothE": __.bothE,
+         "in_": __.in_,
+         "out": __.out}
 
     if hasattr(step.context, "traversal_params"):
         b.update(step.context.traversal_params)
 
+    print __translate(step.text)
     step.context.traversal = eval(__translate(step.text), b)
 
 
@@ -137,5 +141,6 @@ def __table_assertion(data, result, ctx, ordered):
 
 
 def __translate(traversal):
-    replaced = regex_as.sub(".as_(", traversal)
-    return regex_in.sub(".in_(", replaced)
+    replaced = regex_as.sub(r"\1as_(", traversal)
+    replaced = regex_is.sub(r"\1is_(", replaced)
+    return regex_in.sub(r"\1in_(", replaced)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8445f630/gremlin-test/features/map/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Count.feature b/gremlin-test/features/map/Count.feature
index b7f5c66..5faa975 100644
--- a/gremlin-test/features/map/Count.feature
+++ b/gremlin-test/features/map/Count.feature
@@ -65,4 +65,47 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | d[0] |
\ No newline at end of file
+      | d[0] |
+
+  Scenario: g_V_whereXinXkknowsX_outXcreatedX_count_is_0XX_name
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().where(in("knows").out("created").count().is(0)).values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | marko |
+      | lop  |
+      | ripple |
+      | peter |
+
+  Scenario: g_V_repeatXoutX_timesX8X_count
+    Given the grateful graph
+    And the traversal of
+      """
+      g.V().repeat(out()).times(8).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | d[2505037961767380] |
+
+  Scenario: g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count
+    Given the grateful graph
+    And the traversal of
+      """
+      g.V().repeat(out()).times(5).as("a").out("writtenBy").as("b").select("a", "b").count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | d[24309134024] |
+
+  Scenario: g_V_repeatXoutX_timesX3X_count
+    Given the grateful graph
+    And the traversal of
+      """
+      g.V().repeat(out()).times(3).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | d[14465066] |

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8445f630/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
index d3212a4..00975be 100644
--- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.process;
 
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
 import org.junit.Test;
 
@@ -53,7 +54,10 @@ public class FeatureCoverageTest {
     public void shouldImplementAllProcessTestsAsFeatures() throws Exception {
 
         // TEMPORARY while test framework is under development - all tests should ultimately be included
-        final List<Class<?>> temp = Arrays.asList(CoinTest.class, VertexTest.class);
+        final List<Class<?>> temp = Arrays.asList(
+                CoinTest.class,
+                CountTest.class,
+                VertexTest.class);
 
         final Field field = ProcessStandardSuite.class.getDeclaredField("testsToEnforce");
         field.setAccessible(true);