From 24ce7b286f8de8b69dba58d35d02185fbf09ecba Mon Sep 17 00:00:00 2001 From: Dzina Date: Mon, 13 Nov 2023 14:01:24 +0300 Subject: [PATCH] add etc2 --- CHANGELOG.md | 2 ++ .../api/directions/v5/DirectionsCriteria.java | 10 ++++++++++ .../v5/models/IntersectionLanesTest.java | 14 ++++++++++++++ .../api/directions/v5/models/RouteOptionsTest.java | 11 +++++++++++ 4 files changed, 37 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d78a84e5..9e70d397b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Mapbox welcomes participation and contributions from everyone. ### main +- Added `DirectionsCriteria#PAYMENT_METHOD_ETC2` option to pass as `RouteOptions#computeTollCosts` and to receive in `IntersectionsLanes#paymentMethods`. + ### v6.14.0 - October 26, 2023 - Added `LegAnnotation#freeflowSpeed` and `LegAnnotation#currentSpeed`. To receive these annotations, pass `DirectionsCriteria.ANNOTATION_FREEFLOW_SPEED` and `DirectionsCriteria.ANNOTATION_CURRENT_SPEED` in the request in the "annotations" parameter. diff --git a/services-directions-models/src/main/java/com/mapbox/api/directions/v5/DirectionsCriteria.java b/services-directions-models/src/main/java/com/mapbox/api/directions/v5/DirectionsCriteria.java index 7e58489bc..c8be202d3 100644 --- a/services-directions-models/src/main/java/com/mapbox/api/directions/v5/DirectionsCriteria.java +++ b/services-directions-models/src/main/java/com/mapbox/api/directions/v5/DirectionsCriteria.java @@ -338,6 +338,15 @@ public final class DirectionsCriteria { @SuppressWarnings("checkstyle:javadocvariable") public static final String PAYMENT_METHOD_ETC = "etc"; + /* + * A ETC 2.0 transponder. + * NOTE: If the specified `payment_methods` parameter includes `etc2`, + * `etc` lane will be validated and activated. + * This is because ETC2 user can pass through ETC tollbooths. + */ + @SuppressWarnings("checkstyle:javadocvariable") + public static final String PAYMENT_METHOD_ETC2 = "etc2"; + /* * A transponder only used for several specific roads in Japan. */ @@ -668,6 +677,7 @@ private DirectionsCriteria() { PAYMENT_METHOD_VIDEO, PAYMENT_METHOD_CRYPTOCURRENCIES, PAYMENT_METHOD_APP, + PAYMENT_METHOD_ETC2, }) public @interface PaymentMethodsCriteria { } diff --git a/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/IntersectionLanesTest.java b/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/IntersectionLanesTest.java index dbdf8be61..c6df601ce 100644 --- a/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/IntersectionLanesTest.java +++ b/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/IntersectionLanesTest.java @@ -88,4 +88,18 @@ public void testFromJson_etcAndGeneralPayment() { assertEquals(intersectionLanes, intersectionLanesFromJson); } + + @Test + public void testFromJson_etc2Payment() { + IntersectionLanes intersectionLanes = IntersectionLanes.builder() + .paymentMethods(Arrays.asList( + DirectionsCriteria.PAYMENT_METHOD_ETC2 + )) + .build(); + + String jsonString = "{\"payment_methods\": [\"etc2\"]}"; + IntersectionLanes intersectionLanesFromJson = IntersectionLanes.fromJson(jsonString); + + assertEquals(intersectionLanes, intersectionLanesFromJson); + } } diff --git a/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/RouteOptionsTest.java b/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/RouteOptionsTest.java index b7a29d21e..4f2ba022c 100644 --- a/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/RouteOptionsTest.java +++ b/services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/RouteOptionsTest.java @@ -1037,6 +1037,17 @@ public void etcPaymentMethod() { assertContains(query, "payment_methods=etc"); } + @Test + public void etc2PaymentMethod() { + RouteOptions routeOptions = routeOptions().toBuilder() + .paymentMethodsList(Arrays.asList(DirectionsCriteria.PAYMENT_METHOD_ETC2)) + .build(); + String query = routeOptions.toUrl("test").getQuery(); + + assertEquals("etc2", routeOptions.paymentMethods()); + assertContains(query, "payment_methods=etc2"); + } + @Test public void generalAndEtcPaymentsMethod() { List paymentMethods = Arrays.asList(