TINKERPOP-1894 Fixed deserialization of P.not() for GraphSON 2.x

javascript and python GLVs seemed to respond well to this fix, but .NET did 
not. The related tests are still failing.


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

Branch: refs/heads/TINKERPOP-1535
Commit: 2350cbe04b5a4ed3fdca389b8a345017a4bc7d0a
Parents: aaf5146
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Mar 1 12:04:42 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Mar 1 12:06:43 2018 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                       |  1 +
 .../gremlin/structure/io/graphson/GraphSONTokens.java    |  1 +
 .../structure/io/graphson/TraversalSerializersV2d0.java  |  2 ++
 .../ser/GraphSONMessageSerializerGremlinV2d0Test.java    | 11 +++++++++++
 .../gremlin-javascript/test/cucumber/feature-steps.js    |  4 ----
 gremlin-python/src/main/jython/radish/feature_steps.py   |  5 -----
 6 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2350cbe0/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 92e1d9e..a24b1fb 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ 
image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Added `checkAdjacentVertices` option to `SubgraphStrategy`.
 * Modified `GremlinDslProcessor` so that it generated the 
`getAnonymousTraversalClass()` method to return the DSL version of `__`.
 * Added the "Kitchen Sink" test data set.
+* Fixed deserialization of `P.not()` for GraphSON.
 * Added `idleConnectionTimeout` and `keepAliveInterval` to Gremlin Server that 
enables a "ping" and auto-close for seemingly dead clients.
 * Fixed a bug in `NumberHelper` that led to wrong min/max results if numbers 
exceeded the Integer limits.
 * Delayed setting of the request identifier until `RequestMessage` 
construction by the builder.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2350cbe0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
index 9f0648a..7ec004a 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTokens.java
@@ -72,6 +72,7 @@ public final class GraphSONTokens {
     public static final String ARGUMENTS = "arguments";
     public static final String PREDICATE = "predicate";
     public static final String AND = "and";
+    public static final String NOT = "not";
     public static final String OR = "or";
     public static final String SOURCE = "source";
     public static final String STEP = "step";

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2350cbe0/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
index f399cfa..a696280 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV2d0.java
@@ -329,6 +329,8 @@ final class TraversalSerializersV2d0 {
 
             if (predicate.equals(GraphSONTokens.AND) || 
predicate.equals(GraphSONTokens.OR)) {
                 return predicate.equals(GraphSONTokens.AND) ? new 
AndP((List<P>) value) : new OrP((List<P>) value);
+            } else if (predicate.equals(GraphSONTokens.NOT) && value 
instanceof P) {
+                return P.not((P<?>) value);
             } else {
                 try {
                     if (value instanceof Collection) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2350cbe0/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV2d0Test.java
----------------------------------------------------------------------
diff --git 
a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV2d0Test.java
 
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV2d0Test.java
index 1f7efda..fb9bfe2 100644
--- 
a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV2d0Test.java
+++ 
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinV2d0Test.java
@@ -22,6 +22,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufAllocator;
 import io.netty.buffer.UnpooledByteBufAllocator;
 import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 import 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -329,6 +330,16 @@ public class GraphSONMessageSerializerGremlinV2d0Test {
         assertEquals(ResponseStatusCode.SUCCESS.getValue(), 
deserialized.getStatus().getCode().getValue());
         assertEquals("worked", deserialized.getStatus().getMessage());
     }
+
+    @Test
+    public void shouldDeserializeNotPredicate() throws Exception {
+        final String requestMessageWithP = 
"{\"requestId\":{\"@type\":\"g:UUID\",\"@value\":\"0397b9c0-ffab-470e-a6a8-644fc80c01d6\"},\"op\":\"bytecode\",\"processor\":\"traversal\",\"args\":{\"gremlin\":{\"@type\":\"g:Bytecode\",\"@value\":{\"step\":[[\"V\"],[\"hasLabel\",\"person\"],[\"has\",\"age\",{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"not\",\"value\":{\"@type\":\"g:P\",\"@value\":{\"predicate\":\"lte\",\"value\":{\"@type\":\"g:Int32\",\"@value\":10}}}}}]]}},\"aliases\":{\"g\":\"gmodern\"}}}";
+        final ByteBuf bb = allocator.buffer(requestMessageWithP.length());
+        bb.writeBytes(requestMessageWithP.getBytes());
+        final RequestMessage m = serializer.deserializeRequest(bb);
+        assertEquals("bytecode", m.getOp());
+        assertNotNull(m.getArgs());
+    }
     
     private void assertCommon(final ResponseMessage response) {
         assertEquals(requestId, response.getRequestId());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2350cbe0/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 2bb6ef0..c4eaebc 100644
--- 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -61,10 +61,6 @@ const ignoreReason = {
 const ignoredScenarios = {
   // An associative array containing the scenario name as key, for example:
   // 'g_V_branchXlabel_eq_person': new 
IgnoreError(ignoreReason.lambdaNotSupported),
-  
'g_V_hasLabelXpersonX_hasXage_notXlteX10X_andXnotXbetweenX11_20XXXX_andXltX29X_orXeqX35XXXX_name':
 new IgnoreError(ignoreReason.needsFurtherInvestigation),
-  'g_VX1X_out_aggregateXxX_out_whereXnotXwithinXaXXX': new 
IgnoreError(ignoreReason.needsFurtherInvestigation),
-  
'g_V_asXaX_out_asXbX_whereXandXasXaX_outXknowsX_asXbX__orXasXbX_outXcreatedX_hasXname_rippleX__asXbX_inXknowsX_count_isXnotXeqX0XXXXX_selectXa_bX':
 new IgnoreError(ignoreReason.needsFurtherInvestigation),
-  
'g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_bothXknowsX_bothXknowsX_asXdX_whereXc__notXeqXaX_orXeqXdXXXX_selectXa_b_c_dX':
 new IgnoreError(ignoreReason.needsFurtherInvestigation),
 };
 
 defineSupportCode(function(methods) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2350cbe0/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 3ba88a2..5cf9059 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -44,11 +44,6 @@ tail = __.tail
 
 ignores = [
     "g.V(v1Id).out().inject(v2).values(\"name\")",  # bug in attachment won't 
connect v2
-    # TINKERPOP-1859 - for the following...seems to be related to P.not 
processing
-    "g.V().hasLabel(\"person\").has(\"age\", 
P.not(P.lte(d10).and(P.not(P.between(d11, 
d20)))).and(P.lt(d29).or(P.eq(d35)))).values(\"name\")",
-    "g.V(v1Id).out().aggregate(\"x\").out().where(P.not(P.within(\"x\")))",
-    
"g.V().as(\"a\").out().as(\"b\").where(__.and(__.as(\"a\").out(\"knows\").as(\"b\"),
 __.or(__.as(\"b\").out(\"created\").has(\"name\", \"ripple\"), 
__.as(\"b\").in(\"knows\").count().is(P.not(P.eq(0)))))).select(\"a\", \"b\")",
-    
"g.V().as(\"a\").out(\"created\").as(\"b\").in(\"created\").as(\"c\").both(\"knows\").both(\"knows\").as(\"d\").where(\"c\",
 P.not(P.eq(\"a\").or(P.eq(\"d\")))).select(\"a\", \"b\", \"c\", \"d\")"
            ]
 
 

Reply via email to