From 6777127497f7608176e398c847b2b40b31b2deea Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Thu, 19 May 2016 11:04:00 -0400 Subject: [PATCH] Add cucumber tests for node IDs --- features/step_definitions/matching.js | 12 +++++++++++- features/support/route.js | 5 +++++ features/testbot/matching.feature | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/features/step_definitions/matching.js b/features/step_definitions/matching.js index c36db1956..4ca378f6d 100644 --- a/features/step_definitions/matching.js +++ b/features/step_definitions/matching.js @@ -34,7 +34,8 @@ module.exports = function () { turns = '', route = '', duration = '', - annotation = ''; + annotation = '', + OSMIDs = ''; if (res.statusCode === 200) { @@ -61,6 +62,11 @@ module.exports = function () { if (json.matchings.length != 1) throw new Error('*** Checking annotation only supported for matchings with one subtrace'); annotation = this.annotationList(json.matchings[0]); } + + if (headers.has('OSM IDs')) { + if (json.matchings.length != 1) throw new Error('*** CHecking annotation only supported for matchings with one subtrace'); + OSMIDs = this.OSMIDList(json.matchings[0]); + } } if (headers.has('turns')) { @@ -79,6 +85,10 @@ module.exports = function () { got.annotation = annotation.toString(); } + if (headers.has('OSM IDs')) { + got['OSM IDs'] = OSMIDs; + } + var ok = true; var encodedResult = '', extendedTarget = ''; diff --git a/features/support/route.js b/features/support/route.js index 1801250c7..6ba5bff27 100644 --- a/features/support/route.js +++ b/features/support/route.js @@ -163,6 +163,11 @@ module.exports = function () { return matching.legs.map(l => {return zip(l.annotation.duration, l.annotation.distance).map(p => { return p.join(':'); }).join(','); }).join(','); }; + this.OSMIDList = (instructions) => { + // OSM node IDs also come from the annotation list + return instructions.annotation.nodes.map(x => x.toString()).join(','); + } + this.turnList = (instructions) => { return instructions.legs.reduce((m, v) => m.concat(v.steps), []) .map(v => { diff --git a/features/testbot/matching.feature b/features/testbot/matching.feature index ce949940b..f105a7200 100644 --- a/features/testbot/matching.feature +++ b/features/testbot/matching.feature @@ -122,3 +122,9 @@ Feature: Basic Map Matching | trace | matchings | annotation | | abeh | abcedgh | 1:9.897633,0:0,1:10.008842,1:10.008842,1:10.008842,0:0,2:20.017685,1:10.008842 | | abci | abc,ci | 1:9.897633,0:0,1:10.008842,0:0.111209,1:10.010367 | + + # The following is the same as the above, but separated for readability (line length) + When I match I should get + | trace | matchings | OSM IDs | + | abeh | abcedgh | 1,2,3,2,3,4,5,4,5,6,7 | + | abci | abc,ci | 1,2,3,2,3,8,3,8 |