tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jorg...@apache.org
Subject [26/44] tinkerpop git commit: Traversal iterate() method
Date Fri, 19 Jan 2018 08:31:00 GMT
Traversal iterate() method


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

Branch: refs/heads/TINKERPOP-1489
Commit: 219ead0ebe728a5694a857da2f221f7e3f3e6237
Parents: 53a7f27
Author: Jorge Bay Gondra <jorgebaygondra@gmail.com>
Authored: Mon Nov 27 12:22:08 2017 +0100
Committer: Jorge Bay Gondra <jorgebaygondra@gmail.com>
Committed: Fri Jan 19 09:30:16 2018 +0100

----------------------------------------------------------------------
 gremlin-javascript/glv/TraversalSource.template | 12 +++++++++++
 .../gremlin-javascript/lib/process/traversal.js | 12 +++++++++++
 .../javascript/gremlin-javascript/package.json  |  2 +-
 .../test/unit/traversal-test.js                 | 21 ++++++++++++++++++--
 4 files changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/glv/TraversalSource.template
----------------------------------------------------------------------
diff --git a/gremlin-javascript/glv/TraversalSource.template b/gremlin-javascript/glv/TraversalSource.template
index f75765f..0d45e90 100644
--- a/gremlin-javascript/glv/TraversalSource.template
+++ b/gremlin-javascript/glv/TraversalSource.template
@@ -58,6 +58,18 @@ Traversal.prototype.toList = function () {
 };
 
 /**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+Traversal.prototype.iterate = function () {
+  return this._applyStrategies().then(() => {
+    let it;
+    while ((it = this._getNext()) && !it.done) {
+    }
+  });
+};
+
+/**
  * Async iterator method implementation.
  * Returns a promise containing an iterator item.
  * @returns {Promise.<{value, done}>}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
index ebf8755..d887fe0 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/traversal.js
@@ -58,6 +58,18 @@ Traversal.prototype.toList = function () {
 };
 
 /**
+ * Iterates all Traverser instances in the traversal.
+ * @returns {Promise}
+ */
+Traversal.prototype.iterate = function () {
+  return this._applyStrategies().then(() => {
+    let it;
+    while ((it = this._getNext()) && !it.done) {
+    }
+  });
+};
+
+/**
  * Async iterator method implementation.
  * Returns a promise containing an iterator item.
  * @returns {Promise.<{value, done}>}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
index aae9eb9..7c4a3d6 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/package.json
@@ -30,7 +30,7 @@
   },
   "scripts": {
     "test": "./node_modules/.bin/mocha test/unit test/integration -t 5000",
-    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/",
+    "features": "./node_modules/.bin/cucumber.js --require test/cucumber ../../../../../gremlin-test/features/map/AddVertex.feature",
     "unit-test": "./node_modules/.bin/mocha test/unit"
   },
   "engines": {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/219ead0e/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
index 635c7e8..2be504b 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js
@@ -32,7 +32,6 @@ const TraversalStrategies = require('../../lib/process/traversal-strategy').Trav
 describe('Traversal', function () {
 
   describe('#getByteCode()', function () {
-
     it('should add steps for with a string parameter', function () {
       var g = new graph.Graph().traversal();
       var bytecode = g.V().out('created').getBytecode();
@@ -61,7 +60,6 @@ describe('Traversal', function () {
   });
 
   describe('#next()', function () {
-
     it('should apply the strategies and return a Promise with the iterator item', function
() {
       var strategyMock = {
         apply: function (traversal) {
@@ -175,4 +173,23 @@ describe('Traversal', function () {
         });
     });
   });
+
+  describe('#iterate()', function () {
+    it('should apply the strategies and return a Promise', function () {
+      let applied = false;
+      const strategyMock = {
+        apply: function (traversal) {
+          applied = true;
+          traversal.traversers = [ new t.Traverser('a', 1), new t.Traverser('b', 1) ];
+          return utils.resolvedPromise();
+        }
+      };
+      const strategies = new TraversalStrategies();
+      strategies.addStrategy(strategyMock);
+      const traversal = new t.Traversal(null, strategies, null);
+      return traversal.iterate().then(() => {
+        assert.strictEqual(applied, true);
+      });
+    });
+  });
 });
\ No newline at end of file


Mime
View raw message