-
Notifications
You must be signed in to change notification settings - Fork 117
[NAVAND-830] payment methods [DO-NOT-MERGE] #1449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import static com.google.gson.JsonParser.parseString; | ||
| import static com.mapbox.api.directions.v5.utils.Asserts.assertContains; | ||
| import static com.mapbox.api.directions.v5.utils.Asserts.assertContainsExactCount; | ||
| import static com.mapbox.api.directions.v5.utils.Asserts.assertDoesNotContain; | ||
| import static com.mapbox.api.directions.v5.utils.Asserts.assertNoDuplicatedParameters; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
|
|
@@ -37,7 +38,7 @@ public class RouteOptionsTest extends TestUtils { | |
| */ | ||
| private static final String ROUTE_OPTIONS_JSON = "route_options_v5.json"; | ||
| private static final String ROUTE_OPTIONS_URL = | ||
| "https://api.mapbox.com/directions/v5/mapbox/driving/-122.4003312,37.7736941;-122.4187529,37.7689715;-122.4255172,37.7775835?access_token=pk.token&geometries=polyline6&alternatives=false&overview=full&radiuses=%3Bunlimited%3B5.1&steps=true&avoid_maneuver_radius=200.0&bearings=0%2C90%3B90%2C0%3B&layers=-42%3B%3B0&continue_straight=false&annotations=congestion%2Cdistance%2Cduration&language=ru&roundabout_exits=false&voice_instructions=true&banner_instructions=true&voice_units=metric&exclude=toll%2Cferry%2Cpoint%2811.0+-22.0%29&include=hot%2Chov2&approaches=%3Bcurb%3B&waypoints=0%3B1%3B2&waypoint_names=%3BSerangoon+Garden+Market+%26+Food+Centre%3BFunky+%26nAmE*&waypoint_targets=%3B12.2%2C21.2%3B&enable_refresh=true&walking_speed=5.11&walkway_bias=-0.2&alley_bias=0.75&snapping_include_closures=%3Bfalse%3Btrue&snapping_include_static_closures=true%3B%3Bfalse&arrive_by=2021-01-01%27T%2701%3A01&depart_at=2021-02-02%27T%2702%3A02&max_height=1.5&max_width=1.4&max_weight=2.9&compute_toll_cost=true&waypoints_per_route=true&metadata=true"; | ||
| "https://api.mapbox.com/directions/v5/mapbox/driving/-122.4003312,37.7736941;-122.4187529,37.7689715;-122.4255172,37.7775835?access_token=pk.token&geometries=polyline6&alternatives=false&overview=full&radiuses=%3Bunlimited%3B5.1&steps=true&avoid_maneuver_radius=200.0&bearings=0%2C90%3B90%2C0%3B&layers=-42%3B%3B0&continue_straight=false&annotations=congestion%2Cdistance%2Cduration&language=ru&roundabout_exits=false&voice_instructions=true&banner_instructions=true&voice_units=metric&exclude=toll%2Cferry%2Cpoint%2811.0+-22.0%29&include=hot%2Chov2&approaches=%3Bcurb%3B&waypoints=0%3B1%3B2&waypoint_names=%3BSerangoon+Garden+Market+%26+Food+Centre%3BFunky+%26nAmE*&waypoint_targets=%3B12.2%2C21.2%3B&enable_refresh=true&walking_speed=5.11&walkway_bias=-0.2&alley_bias=0.75&snapping_include_closures=%3Bfalse%3Btrue&snapping_include_static_closures=true%3B%3Bfalse&arrive_by=2021-01-01%27T%2701%3A01&depart_at=2021-02-02%27T%2702%3A02&max_height=1.5&max_width=1.4&max_weight=2.9&compute_toll_cost=true&waypoints_per_route=true&metadata=true&payment_methods=general"; | ||
| private static final String ACCESS_TOKEN = "pk.token"; | ||
|
|
||
| private final String optionsJson = loadJsonFixture(ROUTE_OPTIONS_JSON); | ||
|
|
@@ -1011,6 +1012,45 @@ public void emptyExcludeObjectsCleansUpExcludes() { | |
| assertNull(routeOptions.exclude()); | ||
| } | ||
|
|
||
| @Test | ||
| public void etcPaymentMethod() { | ||
| RouteOptions routeOptions = routeOptions().toBuilder() | ||
| .paymentMethodsList(Arrays.asList(DirectionsCriteria.PAYMENT_METHOD_ETC)) | ||
| .build(); | ||
| String query = routeOptions.toUrl("test").getQuery(); | ||
|
|
||
| assertEquals("etc", routeOptions.paymentMethods()); | ||
| assertContains(query, "payment_methods=etc"); | ||
| } | ||
|
|
||
| @Test | ||
| public void generalAndEtcPaymentsMethod() { | ||
| List<String> paymentMethods = Arrays.asList( | ||
| DirectionsCriteria.PAYMENT_METHOD_ETC, | ||
| DirectionsCriteria.PAYMENT_METHOD_GENERAL | ||
| ); | ||
| RouteOptions routeOptions = routeOptions().toBuilder() | ||
| .paymentMethodsList(paymentMethods) | ||
| .build(); | ||
| String query = routeOptions.toUrl("test").getQuery(); | ||
|
|
||
| assertEquals("etc,general", routeOptions.paymentMethods()); | ||
| assertEquals(paymentMethods, routeOptions.paymentMethodsList()); | ||
| assertContains(query, "payment_methods=etc%2Cgeneral"); | ||
| } | ||
|
|
||
| @Test | ||
| public void emptyPaymentMethodsList() { | ||
| RouteOptions routeOptions = routeOptions().toBuilder() | ||
| .paymentMethodsList(Collections.<String>emptyList()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a test that checks what happens if you pass null (if it's supported) or don't call the method at all?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. I just felt confidence in case of null, because it's a default value. I didn't felt confidence in case of an empty list and added the test 🙂
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will happen? Will there be a parameter with an empty string or no parameter at all? Since it's no parameter at all for an empty list I guess it will be the same for null so here I don't think it's necessary. I usually add tests for null and empty as a rule, just to be sure. No pressure tho. :) |
||
| .build(); | ||
| String query = routeOptions.toUrl("test").getQuery(); | ||
|
|
||
| assertNull(routeOptions.paymentMethods()); | ||
| assertNull(routeOptions.paymentMethodsList()); | ||
| assertDoesNotContain(query, "payment_methods"); | ||
| } | ||
|
|
||
| /** | ||
| * Fills up all the options using string variants. Values need ot be equal to the ones in {@link #optionsJson}. | ||
| */ | ||
|
|
@@ -1061,6 +1101,7 @@ private RouteOptions routeOptions() { | |
| .metadata(true) | ||
| .computeTollCost(true) | ||
| .waypointsPerRoute(true) | ||
| .paymentMethods(DirectionsCriteria.PAYMENT_METHOD_GENERAL) | ||
| .build(); | ||
| } | ||
|
|
||
|
|
@@ -1168,6 +1209,7 @@ private RouteOptions routeOptionsList() { | |
| .metadata(true) | ||
| .computeTollCost(true) | ||
| .waypointsPerRoute(true) | ||
| .paymentMethodsList(Arrays.asList(DirectionsCriteria.PAYMENT_METHOD_GENERAL)) | ||
| .build(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're missing updates to
MapboxDirectionsthat use this new parameter (and corresponding request/response tests).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. But I'm not sure about response tests in the
services-directionsmodule. They seem like a duplication of tests from theservices-dirctions-modelmodule, as they just check how a JSON test file transforms to model. WDYT?