tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [tinkerpop] 09/12: TINKERPOP-1959 Handled EnumValue serialization in script bindings
Date Mon, 08 Oct 2018 19:02:13 GMT
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-1959-tp33
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 22c8821c601dfb3fc18de028cc3612085e421c17
Author: Stephen Mallette <spmva@genoprime.com>
AuthorDate: Fri Oct 5 08:36:25 2018 -0400

    TINKERPOP-1959 Handled EnumValue serialization in script bindings
---
 .../gremlin-javascript/lib/driver/driver-remote-connection.js  |  7 ++++++-
 .../gremlin-javascript/test/integration/client-tests.js        | 10 ++--------
 .../javascript/gremlin-javascript/test/unit/graphson-test.js   |  4 ++++
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index d8bb8dc..5b84b04 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -24,6 +24,7 @@
 
 const WebSocket = require('ws');
 const util = require('util');
+const t = require('../process/traversal');
 const RemoteConnection = require('./remote-connection').RemoteConnection;
 const utils = require('../utils');
 const serializer = require('../structure/io/graph-serializer');
@@ -218,6 +219,10 @@ class DriverRemoteConnection extends RemoteConnection {
       return args.map(val => this._adaptArgs(val));
     }
 
+    if (args instanceof t.EnumValue) {
+       return this._writer.adaptObject(args);
+    }
+
     if (args instanceof Object) {
       let newObj = {};
       Object.keys(args).forEach((key) => {
@@ -225,7 +230,7 @@ class DriverRemoteConnection extends RemoteConnection {
       });
       return newObj;
     }
-    
+
     return this._writer.adaptObject(args);
   }
 
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
index 6fcb892..88d871a 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js
@@ -63,16 +63,10 @@ describe('Client', function () {
         });
     });
     it('should send and parse a script with non-native javascript bindings', function ()
{
-      /*return connection.submit('card.toString()', { card: t.cardinality.set })
+      return connection.submit('card.class.simpleName + ":" + card', { card: t.cardinality.set
} )
         .then(function (response) {
-          console.log(response);
           assert.ok(response);
-          assert.ok(response.traversers);
-        });*/
-      return connection.submit('g.addV().property(card, nm, val)', { card: t.cardinality.set,
nm: 'test', val: 12 } )
-        .then(function (response) {
-          assert.ok(response);
-          assert.ok(response.traversers);
+          assert.strictEqual(response.traversers[0], 'Cardinality:set');
         });
     });
   });
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
index 66a36c6..b23e542 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/graphson-test.js
@@ -151,6 +151,10 @@ describe('GraphSONWriter', function () {
     assert.strictEqual(writer.write(true), 'true');
     assert.strictEqual(writer.write(false), 'false');
   });
+  it('should write enum values', function () {
+    const writer = new GraphSONWriter();
+    assert.strictEqual(writer.write(t.cardinality.set), '{"@type":"g:Cardinality","@value":"set"}');
+  });
   it('should write P', function () {
     const writer = new GraphSONWriter();
     const expected = JSON.stringify({"@type":"g:P","@value":{"predicate":"and","value":[


Mime
View raw message