From 2a5e46cba7071b5dbf67087214c8956b3e149b0b Mon Sep 17 00:00:00 2001 From: Guardiola31337 Date: Mon, 11 Feb 2019 18:00:58 -0500 Subject: [PATCH] fix waypoints apis naming for map matching and directions services - from waypoints to waypoint indices --- .../api/directions/v5/DirectionsService.java | 18 +++-- .../api/directions/v5/MapboxDirections.java | 42 +++++------ .../directions/v5/models/RouteOptions.java | 12 +-- .../directions/v5/MapboxDirectionsTest.java | 28 ++----- .../api/matching/v5/MapMatchingService.java | 14 ++-- .../api/matching/v5/MapboxMapMatching.java | 52 ++++++++----- .../matching/v5/MapboxMapMatchingTest.java | 75 ++++++------------- 7 files changed, 107 insertions(+), 134 deletions(-) diff --git a/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java b/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java index a76184947..811c1956d 100644 --- a/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java +++ b/services-directions/src/main/java/com/mapbox/api/directions/v5/DirectionsService.java @@ -31,14 +31,15 @@ public interface DirectionsService { * @param steps define if you'd like the route steps * @param bearings used to filter the road segment the waypoint will be placed on by * direction and dictates the angle of approach - * @param continueStraight define whether the route should continue straight even if the route - * will be slower + * @param continueStraight define whether the route should continue straight even if the + * route will be slower * @param annotations an annotations object that contains additional details about each - * line segment along the route geometry. Each entry in an annotations - * field corresponds to a coordinate along the route geometry + * line segment along the route geometry. Each entry in an + * annotations field corresponds to a coordinate along the route + * geometry * @param language language of returned turn-by-turn text instructions - * @param roundaboutExits Add extra step when roundabouts occur with additional information for - * the user + * @param roundaboutExits Add extra step when roundabouts occur with additional information + * for the user * @param voiceInstructions request that the response contain voice instruction information, * useful for navigation * @param bannerInstructions request that the response contain banner instruction information, @@ -46,7 +47,8 @@ public interface DirectionsService { * @param voiceUnits voice units * @param exclude exclude tolls, motorways or more along your route * @param approaches which side of the road to approach a waypoint - * @param viaWayPoints which input coordinates should be treated as via waypoints + * @param waypointIndices which input coordinates should be treated as waypoints/separate legs. + * Note: coordinate indices not added here act as silent waypoints * @param waypointNames custom names for waypoints used for the arrival instruction * @param waypointTargets list of coordinate pairs for drop-off locations * @return the {@link DirectionsResponse} in a Call wrapper @@ -74,7 +76,7 @@ Call getCall( @Query("voice_units") String voiceUnits, @Query("exclude") String exclude, @Query("approaches") String approaches, - @Query("waypoints") String viaWayPoints, + @Query("waypoints") String waypointIndices, @Query("waypoint_names") String waypointNames, @Query("waypoint_targets") String waypointTargets ); diff --git a/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java b/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java index bdb81d938..2e9ac7527 100644 --- a/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java +++ b/services-directions/src/main/java/com/mapbox/api/directions/v5/MapboxDirections.java @@ -92,7 +92,7 @@ protected Call initializeCall() { voiceUnits(), exclude(), approaches(), - viaWayPoints(), + waypointIndices(), waypointNames(), waypointTargets()); } @@ -235,6 +235,7 @@ private List generateRouteOptions(Response RouteOptions.builder() .profile(profile()) .coordinates(coordinates()) + .waypointIndices(waypointIndices()) .waypointNames(waypointNames()) .waypointTargets(waypointTargets()) .continueStraight(continueStraight()) @@ -362,7 +363,7 @@ private static String formatWaypointTargets(Point[] waypointTargets) { abstract String approaches(); @Nullable - abstract String viaWayPoints(); + abstract String waypointIndices(); @Nullable abstract String waypointNames(); @@ -424,7 +425,7 @@ public abstract static class Builder { private Point destination; private Point origin; private String[] approaches; - private Integer[] viaWayPoints; + private Integer[] waypointIndices; private String[] waypointNames; private Point[] waypointTargets; @@ -794,7 +795,8 @@ public Builder addApproaches(String... approaches) { abstract Builder approaches(@Nullable String approaches); /** - * Optionally, set which input coordinates should be treated as via way points. + * Optionally, set which input coordinates should be treated as waypoints / separate legs. + * Note: coordinate indices not added here act as silent waypoints *

* Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, @@ -802,16 +804,16 @@ public Builder addApproaches(String... approaches) { * {@link #steps()} *

* - * @param viaWayPoints integer array of coordinate indices to be used as via way points + * @param waypointIndices integer array of coordinate indices to be used as waypoints * @return this builder for chaining options together * @since 4.4.0 */ - public Builder addViaWayPoints(@Nullable @IntRange(from = 0) Integer... viaWayPoints) { - this.viaWayPoints = viaWayPoints; + public Builder addWaypointIndices(@Nullable @IntRange(from = 0) Integer... waypointIndices) { + this.waypointIndices = waypointIndices; return this; } - abstract Builder viaWayPoints(@Nullable String viaWayPoints); + abstract Builder waypointIndices(@Nullable String waypointIndices); /** * Custom names for waypoints used for the arrival instruction, @@ -871,30 +873,26 @@ public MapboxDirections build() { + " directions API request."); } - if (viaWayPoints != null) { - if (viaWayPoints.length < 2) { + if (waypointIndices != null) { + if (waypointIndices.length < 2) { throw new ServicesException( - "Via way points must be a list of at least two indexes separated by ';'"); + "Waypoints must be a list of at least two indexes separated by ';'"); } - if (viaWayPoints[0] != 0 - || viaWayPoints[viaWayPoints.length - 1] != coordinates.size() - 1) { + if (waypointIndices[0] != 0 || waypointIndices[waypointIndices.length - 1] + != coordinates.size() - 1) { throw new ServicesException( - "Via way points must contain indices of the first and last coordinates" + "Waypoints must contain indices of the first and last coordinates" ); } - for (int i = 1; i < viaWayPoints.length - 1; i++) { - if (viaWayPoints[i] < 0 || viaWayPoints[i] >= coordinates.size()) { + for (int i = 1; i < waypointIndices.length - 1; i++) { + if (waypointIndices[i] < 0 || waypointIndices[i] >= coordinates.size()) { throw new ServicesException( - "Via way points index too large (no corresponding coordinate)"); + "Waypoints index too large (no corresponding coordinate)"); } } } if (waypointNames != null) { - if (waypointNames.length != coordinates.size()) { - throw new ServicesException("Number of waypoint names must match " - + " the number of waypoints provided."); - } final String waypointNamesStr = TextUtils.formatWaypointNames(waypointNames); waypointNames(waypointNamesStr); } @@ -924,7 +922,7 @@ public MapboxDirections build() { bearing(TextUtils.formatBearing(bearings)); annotation(TextUtils.join(",", annotations)); radius(TextUtils.formatRadiuses(radiuses)); - viaWayPoints(TextUtils.join(";", viaWayPoints)); + waypointIndices(TextUtils.join(";", waypointIndices)); MapboxDirections directions = autoBuild(); diff --git a/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java b/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java index 1ead3f367..e8c0a32b5 100644 --- a/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java +++ b/services-directions/src/main/java/com/mapbox/api/directions/v5/models/RouteOptions.java @@ -268,7 +268,7 @@ public static Builder builder() { public abstract String approaches(); /** - * Indicates which input coordinates should be treated as via way points. + * Indicates which input coordinates should be treated as waypoints. *

* Most useful in combination with steps=true and requests based on traces * with high sample rates. Can be an index corresponding to any of the input coordinates, @@ -276,12 +276,12 @@ public static Builder builder() { * {@link #steps()} *

* - * @return a string representing indices to be used as via way points + * @return a string representing indices to be used as waypoints * @since 4.4.0 */ @SerializedName("waypoints") @Nullable - public abstract String viaWayPoints(); + public abstract String waypointIndices(); /** * Custom names for waypoints used for the arrival instruction in banners and voice instructions, @@ -558,15 +558,15 @@ public abstract Builder overview( public abstract Builder approaches(String approaches); /** - * The same via way points the user originally made when the request was made. + * The same waypoint indices the user originally made when the request was made. * - * @param indices to be used as via way points + * @param indices to be used as waypoints * @return this builder for chaining options together * @since 4.4.0 */ @Nullable - public abstract Builder viaWayPoints(@Nullable String indices); + public abstract Builder waypointIndices(@Nullable String indices); /** * The same waypoint names the user originally made when the request was made. diff --git a/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java b/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java index b740bf400..dff1410f8 100644 --- a/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java +++ b/services-directions/src/test/java/com/mapbox/api/directions/v5/MapboxDirectionsTest.java @@ -231,12 +231,12 @@ public void addWaypoint_doesGetFormattedInUrlCorrectly() throws Exception { } @Test - public void waypoints_doesGetFormattedInUrlCorrectly() throws Exception { + public void waypoints_doesGetFormattedInUrlCorrectly() { MapboxDirections directions = MapboxDirections.builder() .destination(Point.fromLngLat(13.4930, 9.958)) .addWaypoint(Point.fromLngLat(4.56, 7.89)) .origin(Point.fromLngLat(1.234, 2.345)) - .addViaWayPoints(0, 2) + .addWaypointIndices(0, 2) .accessToken(ACCESS_TOKEN) .build(); String semicolon = "%3B"; @@ -673,7 +673,7 @@ public void build_exceptionThrownWhenLessThanTwoWaypointsProvided() { MapboxDirections.builder() .origin(Point.fromLngLat(2.0, 2.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addViaWayPoints(0) + .addWaypointIndices(0) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -685,7 +685,7 @@ public void build_exceptionThrownWhenWaypointsDoNotStartWith0() { .origin(Point.fromLngLat(2.0, 2.0)) .addWaypoint(Point.fromLngLat(3.0, 3.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addViaWayPoints(1, 2) + .addWaypointIndices(1, 2) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -697,7 +697,7 @@ public void build_exceptionThrownWhenWaypointDoNotEndWithLast() { .origin(Point.fromLngLat(2.0, 2.0)) .addWaypoint(Point.fromLngLat(3.0, 3.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addViaWayPoints(0, 1) + .addWaypointIndices(0, 1) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -709,7 +709,7 @@ public void build_exceptionThrownWhenMiddleWaypointsAreWrong() { .origin(Point.fromLngLat(2.0, 2.0)) .addWaypoint(Point.fromLngLat(3.0, 3.0)) .destination(Point.fromLngLat(4.0, 4.0)) - .addViaWayPoints(0, 3, 2) + .addWaypointIndices(0, 3, 2) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -730,22 +730,6 @@ public void sanityWaypointNamesInstructions() throws Exception { mapboxDirections.cloneCall().request().url().queryParameter("waypoint_names")); } - @Test - public void build_exceptionThrownWhenWaypointNamesDoNotMatchCoordinates() throws Exception { - thrown.expect(ServicesException.class); - thrown.expectMessage( - startsWith("Number of waypoint names must match")); - MapboxDirections mapboxDirections = MapboxDirections.builder() - .origin(Point.fromLngLat(2.0, 2.0)) - .addWaypoint(Point.fromLngLat(2.0, 2.0)) - .addWaypoint(Point.fromLngLat(3.0, 3.0)) - .destination(Point.fromLngLat(4.0, 4.0)) - .addWaypointNames("Home", "Work") - .baseUrl("https://foobar.com") - .accessToken(ACCESS_TOKEN) - .build(); - } - @Test public void testWithWaypointNames() throws Exception { diff --git a/services-matching/src/main/java/com/mapbox/api/matching/v5/MapMatchingService.java b/services-matching/src/main/java/com/mapbox/api/matching/v5/MapMatchingService.java index 615560643..383b13e37 100644 --- a/services-matching/src/main/java/com/mapbox/api/matching/v5/MapMatchingService.java +++ b/services-matching/src/main/java/com/mapbox/api/matching/v5/MapMatchingService.java @@ -59,8 +59,9 @@ public interface MapMatchingService { * @param voiceInstructions whether or not to return * marked-up text for voice guidance along the route. * @param voiceUnits voice units - * @param waypoints Which input coordinates should be treated as waypoints. - * @param waypointNames wustom names for waypoints used for the arrival instruction. + * @param waypointIndices which input coordinates should be treated as waypoints/separate legs. + * Note: coordinate indices not added here act as silent waypoints + * @param waypointNames custom names for waypoints used for the arrival instruction. * @param approaches which side of the road to approach a waypoint. * @return the MapMatchingResponse in a Call wrapper * @since 2.0.0 @@ -84,7 +85,7 @@ Call getCall( @Query("banner_instructions") Boolean bannerInstructions, @Query("voice_instructions") Boolean voiceInstructions, @Query("voice_units") String voiceUnits, - @Query("waypoints") String waypoints, + @Query("waypoints") String waypointIndices, @Query("waypoint_names") String waypointNames, @Query("approaches") String approaches); @@ -130,8 +131,9 @@ Call getCall( * @param voiceInstructions whether or not to return * marked-up text for voice guidance along the route. * @param voiceUnits voice units - * @param waypoints Which input coordinates should be treated as waypoints. - * @param waypointNames wustom names for waypoints used for the arrival instruction. + * @param waypointIndices which input coordinates should be treated as waypoints/separate legs. + * Note: coordinate indices not added here act as silent waypoints + * @param waypointNames custom names for waypoints used for the arrival instruction. * @param approaches which side of the road to approach a waypoint. * @return the MapMatchingResponse in a Call wrapper * @since 4.4.0 @@ -156,7 +158,7 @@ Call postCall( @Field("banner_instructions") Boolean bannerInstructions, @Field("voice_instructions") Boolean voiceInstructions, @Field("voice_units") String voiceUnits, - @Field("waypoints") String waypoints, + @Field("waypoints") String waypointIndices, @Field("waypoint_names") String waypointNames, @Field("approaches") String approaches); } diff --git a/services-matching/src/main/java/com/mapbox/api/matching/v5/MapboxMapMatching.java b/services-matching/src/main/java/com/mapbox/api/matching/v5/MapboxMapMatching.java index 0e6c7b62b..d82796542 100644 --- a/services-matching/src/main/java/com/mapbox/api/matching/v5/MapboxMapMatching.java +++ b/services-matching/src/main/java/com/mapbox/api/matching/v5/MapboxMapMatching.java @@ -90,7 +90,7 @@ protected Call initializeCall() { bannerInstructions(), voiceInstructions(), voiceUnits(), - waypoints(), + waypointIndices(), waypointNames(), approaches()); } @@ -112,7 +112,7 @@ protected Call initializeCall() { bannerInstructions(), voiceInstructions(), voiceUnits(), - waypoints(), + waypointIndices(), waypointNames(), approaches()); } @@ -245,6 +245,7 @@ private List generateRouteOptions(Response formatCoordinates(String coordinates) { abstract String voiceUnits(); @Nullable - abstract String waypoints(); + abstract String waypointIndices(); @Nullable abstract String waypointNames(); @@ -360,7 +361,7 @@ public abstract static class Builder { private String[] annotations; private String[] timestamps; private Double[] radiuses; - private Integer[] waypoints; + private Integer[] waypointIndices; private String[] waypointNames; private String[] approaches; @@ -482,14 +483,34 @@ public Builder radiuses(@Nullable @FloatRange(from = 0) Double... radiuses) { * @param waypoints integer array of coordinate indices to be used as waypoints * @return this builder for chaining options together * @since 3.0.0 + * @deprecated you should now use {@link #waypointIndices(Integer[])} */ + @Deprecated public Builder waypoints(@Nullable @IntRange(from = 0) Integer... waypoints) { - this.waypoints = waypoints; + this.waypointIndices = waypoints; return this; } - // Required for matching with MapboxMapMatching waypoints() method. - abstract Builder waypoints(@Nullable String waypoints); + /** + * Optionally, set which input coordinates should be treated as waypoints / separate legs. + * Note: coordinate indices not added here act as silent waypoints + *

+ * Most useful in combination with steps=true and requests based on traces + * with high sample rates. Can be an index corresponding to any of the input coordinates, + * but must contain the first ( 0 ) and last coordinates' index separated by ; . + * {@link #steps()} + *

+ * + * @param waypointIndices integer array of coordinate indices to be used as waypoints + * @return this builder for chaining options together + * @since 3.0.0 + */ + public Builder waypointIndices(@Nullable @IntRange(from = 0) Integer... waypointIndices) { + this.waypointIndices = waypointIndices; + return this; + } + + abstract Builder waypointIndices(@Nullable String waypointIndices); /** * Setting this will determine whether to return steps and turn-by-turn instructions. Can be @@ -756,18 +777,19 @@ public MapboxMapMatching build() { "There must be as many timestamps as there are coordinates."); } - if (waypoints != null) { - if (waypoints.length < 2) { + if (waypointIndices != null) { + if (waypointIndices.length < 2) { throw new ServicesException( "Waypoints must be a list of at least two indexes separated by ';'"); } - if (waypoints[0] != 0 || waypoints[waypoints.length - 1] != coordinates.size() - 1) { + if (waypointIndices[0] != 0 + || waypointIndices[waypointIndices.length - 1] != coordinates.size() - 1) { throw new ServicesException( "Waypoints must contain indices of the first and last coordinates" ); } - for (int i = 1; i < waypoints.length - 1; i++) { - if (waypoints[i] < 0 || waypoints[i] >= coordinates.size()) { + for (int i = 1; i < waypointIndices.length - 1; i++) { + if (waypointIndices[i] < 0 || waypointIndices[i] >= coordinates.size()) { throw new ServicesException( "Waypoints index too large (no corresponding coordinate)"); } @@ -775,10 +797,6 @@ public MapboxMapMatching build() { } if (waypointNames != null) { - if (waypointNames.length != waypoints.length) { - throw new ServicesException("Number of waypoint names must match " - + " the number of waypoints provided."); - } final String waypointNamesStr = TextUtils.formatWaypointNames(waypointNames); waypointNames(waypointNamesStr); } @@ -799,7 +817,7 @@ public MapboxMapMatching build() { timestamps(TextUtils.join(";", timestamps)); annotations(TextUtils.join(",", annotations)); radiuses(TextUtils.join(";", radiuses)); - waypoints(TextUtils.join(";", waypoints)); + waypointIndices(TextUtils.join(";", waypointIndices)); // Generate build so that we can check that values are valid. MapboxMapMatching mapMatching = autoBuild(); diff --git a/services-matching/src/test/java/com/mapbox/api/matching/v5/MapboxMapMatchingTest.java b/services-matching/src/test/java/com/mapbox/api/matching/v5/MapboxMapMatchingTest.java index 00a73f6f7..873844edf 100644 --- a/services-matching/src/test/java/com/mapbox/api/matching/v5/MapboxMapMatchingTest.java +++ b/services-matching/src/test/java/com/mapbox/api/matching/v5/MapboxMapMatchingTest.java @@ -380,72 +380,60 @@ public void baseUrl_doesShowInUrlCorrectly() throws Exception { } - @Test - public void build_exceptionThrownWhenLessThanTwoWayPointsProvided() throws Exception { - thrown.expect(ServicesException.class); - thrown.expectMessage( - startsWith("Waypoints must be a list of at least two indexes separated by")); - MapboxMapMatching mapMatching = MapboxMapMatching.builder() + @Test(expected = ServicesException.class) + public void build_exceptionThrownWhenLessThanTwoSeparatesLegsProvided() { + MapboxMapMatching.builder() .coordinate(Point.fromLngLat(2.0, 2.0)) .coordinate(Point.fromLngLat(4.0, 4.0)) - .waypoints(0) + .waypointIndices(0) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); } - @Test - public void build_exceptionThrownWhenWaypointsDoNotStartWith0() throws Exception { - thrown.expect(ServicesException.class); - thrown.expectMessage( - startsWith("Waypoints must contain indices of the first and last coordinates")); - MapboxMapMatching mapMatching = MapboxMapMatching.builder() + @Test(expected = ServicesException.class) + public void build_exceptionThrownWhenSeparatesLegsDoNotStartWith0() { + MapboxMapMatching.builder() .coordinate(Point.fromLngLat(2.0, 2.0)) .coordinate(Point.fromLngLat(3.0, 3.0)) .coordinate(Point.fromLngLat(4.0, 4.0)) - .waypoints(1, 2) + .waypointIndices(1, 2) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); } - @Test - public void build_exceptionThrownWhenWaypointDoNotEndWithLast() throws Exception { - thrown.expect(ServicesException.class); - thrown.expectMessage( - startsWith("Waypoints must contain indices of the first and last coordinates")); - MapboxMapMatching mapMatching = MapboxMapMatching.builder() + @Test(expected = ServicesException.class) + public void build_exceptionThrownWhenSeparatesLegsDoNotEndWithLast() { + MapboxMapMatching.builder() .coordinate(Point.fromLngLat(2.0, 2.0)) .coordinate(Point.fromLngLat(3.0, 3.0)) .coordinate(Point.fromLngLat(4.0, 4.0)) - .waypoints(0, 1) + .waypointIndices(0, 1) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); } - @Test - public void build_exceptionThrownWhenMiddleWaypointsAreWrong() throws Exception { - thrown.expect(ServicesException.class); - thrown.expectMessage( - startsWith("Waypoints index too large (no corresponding coordinate)")); - MapboxMapMatching mapMatching = MapboxMapMatching.builder() + @Test(expected = ServicesException.class) + public void build_exceptionThrownWhenMiddleSeparatesLegsAreWrong() { + MapboxMapMatching.builder() .coordinate(Point.fromLngLat(2.0, 2.0)) .coordinate(Point.fromLngLat(3.0, 3.0)) .coordinate(Point.fromLngLat(4.0, 4.0)) - .waypoints(0, 3, 2) + .waypointIndices(0, 3, 2) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); } @Test - public void sanityWaypoints() throws Exception { + public void sanitySeparatesLegs() { MapboxMapMatching mapMatching = MapboxMapMatching.builder() .coordinate(Point.fromLngLat(2.0, 2.0)) .coordinate(Point.fromLngLat(3.0, 3.0)) .coordinate(Point.fromLngLat(4.0, 4.0)) - .waypoints(0, 1, 2) + .waypointIndices(0, 1, 2) .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .build(); @@ -616,14 +604,14 @@ public void testRouteOptionsApproaches() throws Exception { } @Test - public void sanityWaypointNamesInstructions() throws Exception { + public void sanityWaypointNamesInstructions() { MapboxMapMatching mapMatching = MapboxMapMatching.builder() .baseUrl("https://foobar.com") .accessToken(ACCESS_TOKEN) .coordinate(Point.fromLngLat(1.0, 1.0)) .coordinate(Point.fromLngLat(2.0, 2.0)) .coordinate(Point.fromLngLat(4.0, 4.0)) - .waypoints(0,1,2) + .waypointIndices(0, 1 ,2) .addWaypointNames("Home", "Store", "Work") .build(); assertNotNull(mapMatching); @@ -631,25 +619,6 @@ public void sanityWaypointNamesInstructions() throws Exception { mapMatching.cloneCall().request().url().queryParameter("waypoint_names")); } - @Test - public void build_exceptionThrownWhenWaypointNamesDoNotMatchWaypoints() throws Exception { - thrown.expect(ServicesException.class); - thrown.expectMessage( - startsWith("Number of waypoint names must match")); - - MapboxMapMatching mapMatching = MapboxMapMatching.builder() - .baseUrl("https://foobar.com") - .accessToken(ACCESS_TOKEN) - .coordinate(Point.fromLngLat(2.0, 2.0)) - .coordinate(Point.fromLngLat(2.5, 2.5)) - .coordinate(Point.fromLngLat(3.0, 3.0)) - .coordinate(Point.fromLngLat(3.5, 3.5)) - .coordinate(Point.fromLngLat(4.0, 4.0)) - .waypoints(0, 3, 4) - .addWaypointNames("Home", "Work") - .build(); - } - @Test public void testWithWaypointNames() throws Exception { @@ -667,7 +636,7 @@ public void testWithWaypointNames() throws Exception { .steps(true) .tidy(true) .bannerInstructions(true) - .waypoints(0,6) + .waypointIndices(0, 6) .addWaypointNames("Home", "Work") .accessToken(ACCESS_TOKEN) .baseUrl(mockUrl.toString()) @@ -687,7 +656,7 @@ public void testUsePostMethod() throws Exception { .profile(PROFILE_DRIVING) .steps(true) .tidy(true) - .waypoints("0;6") + .waypointIndices("0;6") .coordinates(Arrays.asList( Point.fromLngLat(2.344003915786743,48.85805170891599), Point.fromLngLat(2.346750497817993,48.85727523615161),