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 2020/06/09 13:38:51 UTC

[tinkerpop] branch master updated: Replaced deprecated cucumber code

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/master by this push:
     new ea0191e  Replaced deprecated cucumber code
     new 74fc50c  Merge branch '3.4-dev'
ea0191e is described below

commit ea0191e46a13847f8472fb173f4b1c13627a2e56
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Tue Jun 9 09:26:41 2020 -0400

    Replaced deprecated cucumber code
    
    Doing so cleared up build warnings. CTR
---
 .../test/cucumber/feature-steps.js                 | 180 ++++++++++-----------
 .../gremlin-javascript/test/cucumber/world.js      | 116 +++++++------
 2 files changed, 146 insertions(+), 150 deletions(-)

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 4c0414a..2ef400f 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
@@ -22,7 +22,7 @@
  */
 'use strict';
 
-const defineSupportCode = require('cucumber').defineSupportCode;
+const {Given, Then, When} = require('cucumber');
 const vm = require('vm');
 const expect = require('chai').expect;
 const util = require('util');
@@ -70,113 +70,111 @@ const ignoredScenarios = {
   'g_V_shortestPath_edgesIncluded_edgesXoutEX': new IgnoreError(ignoreReason.needsFurtherInvestigation)
 };
 
-defineSupportCode(function(methods) {
-  methods.Given(/^the (.+) graph$/, function (graphName) {
-    if (ignoredScenarios[this.scenario]) {
-      return 'skipped';
-    }
-    this.graphName = graphName;
-    const data = this.getData();
-    this.g = traversal().withRemote(data.connection);
-    if (graphName === 'empty') {
-      return this.cleanEmptyGraph();
-    }
-  });
+Given(/^the (.+) graph$/, function (graphName) {
+  if (ignoredScenarios[this.scenario]) {
+    return 'skipped';
+  }
+  this.graphName = graphName;
+  const data = this.getData();
+  this.g = traversal().withRemote(data.connection);
+  if (graphName === 'empty') {
+    return this.cleanEmptyGraph();
+  }
+});
 
-  methods.Given('the graph initializer of', function (traversalText) {
-    const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
-    return traversal.toList();
-  });
+Given('the graph initializer of', function (traversalText) {
+  const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
+  return traversal.toList();
+});
 
-  methods.Given('an unsupported test', () => {});
+Given('an unsupported test', () => {});
 
-  methods.Given('the traversal of', function (traversalText) {
-    this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
-  });
+Given('the traversal of', function (traversalText) {
+  this.traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
+});
 
-  methods.Given(/^using the parameter (.+) defined as "(.+)"$/, function (paramName, stringValue) {
-    // Remove escaped chars
-    stringValue = stringValue.replace(/\\"/g, '"');
-    let p = Promise.resolve();
-    if (this.graphName === 'empty') {
-      p = this.loadEmptyGraphData();
+Given(/^using the parameter (.+) defined as "(.+)"$/, function (paramName, stringValue) {
+  // Remove escaped chars
+  stringValue = stringValue.replace(/\\"/g, '"');
+  let p = Promise.resolve();
+  if (this.graphName === 'empty') {
+    p = this.loadEmptyGraphData();
+  }
+  return p.then(() => {
+    this.parameters[paramName] = parseValue.call(this, stringValue);
+  }).catch(err => {
+    if (err instanceof IgnoreError) {
+      return 'skipped';
     }
-    return p.then(() => {
-      this.parameters[paramName] = parseValue.call(this, stringValue);
-    }).catch(err => {
-      if (err instanceof IgnoreError) {
-        return 'skipped';
-      }
-      throw err;
-    });
+    throw err;
   });
+});
 
-  methods.When('iterated to list', function () {
-    return this.traversal.toList().then(list => this.result = list);
-  });
+When('iterated to list', function () {
+  return this.traversal.toList().then(list => this.result = list);
+});
 
-  methods.When('iterated next', function () {
-    return this.traversal.next().then(it => {
-      this.result = it.value;
-      if (this.result instanceof Path) {
-        // Compare using the objects array
-        this.result = this.result.objects;
-      }
-    });
+When('iterated next', function () {
+  return this.traversal.next().then(it => {
+    this.result = it.value;
+    if (this.result instanceof Path) {
+      // Compare using the objects array
+      this.result = this.result.objects;
+    }
   });
+});
 
-  methods.Then(/^the result should be (\w+)$/, function assertResult(characterizedAs, resultTable) {
-    if (characterizedAs === 'empty') {
-      expect(this.result).to.be.empty;
-      if (typeof resultTable === 'function'){
-        return resultTable();
-      }
-      return;
-    }
-    const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
-    switch (characterizedAs) {
-      case 'ordered':
-        expect(toCompare(this.result)).to.have.deep.ordered.members(expectedResult);
-        break;
-      case 'unordered':
-        expect(toCompare(this.result)).to.have.deep.members(expectedResult);
-        break;
-      case 'of':
-        // result is a subset of the expected
-        expect(expectedResult).to.include.deep.members(toCompare(this.result));
-        break;
+Then(/^the result should be (\w+)$/, function assertResult(characterizedAs, resultTable) {
+  if (characterizedAs === 'empty') {
+    expect(this.result).to.be.empty;
+    if (typeof resultTable === 'function'){
+      return resultTable();
     }
-  });
+    return;
+  }
+  const expectedResult = resultTable.rows().map(row => parseRow.call(this, row));
+  switch (characterizedAs) {
+    case 'ordered':
+      expect(toCompare(this.result)).to.have.deep.ordered.members(expectedResult);
+      break;
+    case 'unordered':
+      expect(toCompare(this.result)).to.have.deep.members(expectedResult);
+      break;
+    case 'of':
+      // result is a subset of the expected
+      expect(expectedResult).to.include.deep.members(toCompare(this.result));
+      break;
+  }
+});
 
-  methods.Then(/^the graph should return (\d+) for count of "(.+)"$/, function (stringCount, traversalText) {
-    const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
-    return traversal.toList().then(list => {
-      expect(list).to.have.lengthOf(parseInt(stringCount, 10));
-    });
+Then(/^the graph should return (\d+) for count of "(.+)"$/, function (stringCount, traversalText) {
+  const traversal = vm.runInNewContext(translate(traversalText), getSandbox(this.g, this.parameters));
+  return traversal.toList().then(list => {
+    expect(list).to.have.lengthOf(parseInt(stringCount, 10));
   });
+});
 
-  methods.Then(/^the result should have a count of (\d+)$/, function (stringCount) {
-    const expected = parseInt(stringCount, 10);
-    if (!Array.isArray(this.result)) {
-      let count = 0;
-      if (this.result instanceof Map) {
-        count = this.result.size;
-      }
-      else if (typeof this.result === 'object') {
-        count = Object.keys(this.result).length;
-      }
-      else {
-        throw new Error('result not supported: ' + util.inspect(this.result));
-      }
-      expect(count).to.be.equal(expected);
-      return;
+Then(/^the result should have a count of (\d+)$/, function (stringCount) {
+  const expected = parseInt(stringCount, 10);
+  if (!Array.isArray(this.result)) {
+    let count = 0;
+    if (this.result instanceof Map) {
+      count = this.result.size;
     }
-    expect(this.result).to.have.lengthOf(expected);
-  });
-
-  methods.Then('nothing should happen because', _ => {});
+    else if (typeof this.result === 'object') {
+      count = Object.keys(this.result).length;
+    }
+    else {
+      throw new Error('result not supported: ' + util.inspect(this.result));
+    }
+    expect(count).to.be.equal(expected);
+    return;
+  }
+  expect(this.result).to.have.lengthOf(expected);
 });
 
+Then('nothing should happen because', _ => {});
+
 function getSandbox(g, parameters) {
   const sandbox = {
     g: g,
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
index bde8a53..b9211c0 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/world.js
@@ -22,79 +22,77 @@
  */
 'use strict';
 
-const defineSupportCode = require('cucumber').defineSupportCode;
+const {setWorldConstructor, Before, BeforeAll, AfterAll} = require('cucumber');
 const helper = require('../helper');
 const traversal = require('../../lib/process/anonymous-traversal').traversal;
 const graphTraversalModule = require('../../lib/process/graph-traversal');
 const __ = graphTraversalModule.statics;
 
-defineSupportCode(function (methods) {
-  const cache = {};
+const cache = {};
 
-  function TinkerPopWorld(){
-    this.scenario = null;
-    this.g = null;
-    this.traversal = null;
-    this.result = null;
-    this.cache = null;
-    this.graphName = null;
-    this.parameters = {};
-  }
+function TinkerPopWorld(){
+  this.scenario = null;
+  this.g = null;
+  this.traversal = null;
+  this.result = null;
+  this.cache = null;
+  this.graphName = null;
+  this.parameters = {};
+}
 
-  TinkerPopWorld.prototype.getData = function () {
-    if (!this.graphName) {
-      throw new Error("Graph name is not set");
-    }
-    return this.cache[this.graphName];
-  };
+TinkerPopWorld.prototype.getData = function () {
+  if (!this.graphName) {
+    throw new Error("Graph name is not set");
+  }
+  return this.cache[this.graphName];
+};
 
-  TinkerPopWorld.prototype.cleanEmptyGraph = function () {
-    const connection = this.cache['empty'].connection;
-    const g = traversal().withRemote(connection);
-    return g.V().drop().toList();
-  };
+TinkerPopWorld.prototype.cleanEmptyGraph = function () {
+  const connection = this.cache['empty'].connection;
+  const g = traversal().withRemote(connection);
+  return g.V().drop().toList();
+};
 
-  TinkerPopWorld.prototype.loadEmptyGraphData = function () {
-    const cacheData = this.cache['empty'];
-    const c = cacheData.connection;
-    return Promise.all([ getVertices(c), getEdges(c) ]).then(values => {
-      cacheData.vertices = values[0];
-      cacheData.edges = values[1];
-    });
-  };
+TinkerPopWorld.prototype.loadEmptyGraphData = function () {
+  const cacheData = this.cache['empty'];
+  const c = cacheData.connection;
+  return Promise.all([ getVertices(c), getEdges(c) ]).then(values => {
+    cacheData.vertices = values[0];
+    cacheData.edges = values[1];
+  });
+};
 
-  methods.setWorldConstructor(TinkerPopWorld);
+setWorldConstructor(TinkerPopWorld);
 
-  methods.BeforeAll(function () {
-    // load all traversals
-    const promises = ['modern', 'classic', 'crew', 'grateful', 'sink', 'empty'].map(graphName => {
-      let connection = null;
-      if (graphName === 'empty') {
-        connection = helper.getConnection('ggraph');
-        return connection.open().then(() => cache['empty'] = { connection: connection });
-      }
-      connection = helper.getConnection('g' + graphName);
-      return connection.open()
-        .then(() => Promise.all([getVertices(connection), getEdges(connection)]))
-        .then(values => {
-          cache[graphName] = {
-            connection: connection,
-            vertices: values[0],
-            edges: values[1]
-          };
-        });
-    });
-    return Promise.all(promises);
+BeforeAll(function () {
+  // load all traversals
+  const promises = ['modern', 'classic', 'crew', 'grateful', 'sink', 'empty'].map(graphName => {
+    let connection = null;
+    if (graphName === 'empty') {
+      connection = helper.getConnection('ggraph');
+      return connection.open().then(() => cache['empty'] = { connection: connection });
+    }
+    connection = helper.getConnection('g' + graphName);
+    return connection.open()
+      .then(() => Promise.all([getVertices(connection), getEdges(connection)]))
+      .then(values => {
+        cache[graphName] = {
+          connection: connection,
+          vertices: values[0],
+          edges: values[1]
+        };
+      });
   });
+  return Promise.all(promises);
+});
 
-  methods.AfterAll(function () {
-    return Promise.all(Object.keys(cache).map(graphName => cache[graphName].connection.close()));
-  });
+AfterAll(function () {
+  return Promise.all(Object.keys(cache).map(graphName => cache[graphName].connection.close()));
+});
 
-  methods.Before(function (info) {
-    this.scenario = info.pickle.name;
-    this.cache = cache;
-  });
+Before(function (info) {
+  this.scenario = info.pickle.name;
+  this.cache = cache;
 });
 
 function getVertices(connection) {