Skip to content

Commit 03a5554

Browse files
author
Pablo Guardiola
authored
make directions waypoint name nullable as non-null breaks backwards compatibility (#1386)
1 parent f724bfd commit 03a5554

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

services-directions-models/src/main/java/com/mapbox/api/directions/v5/models/DirectionsWaypoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static Builder builder() {
3434
* @return string with the name of the way the coordinate snapped to
3535
* @since 1.0.0
3636
*/
37-
@NonNull
37+
@Nullable
3838
public abstract String name();
3939

4040
/**
@@ -121,7 +121,7 @@ public abstract static class Builder {
121121
* @since 3.0.0
122122
*/
123123
@NonNull
124-
public abstract Builder name(@NonNull String name);
124+
public abstract Builder name(@Nullable String name);
125125

126126
/**
127127
* The rawLocation as a double array representing a location snapped to the road network.

services-directions-models/src/test/java/com/mapbox/api/directions/v5/models/DirectionsResponseTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.mapbox.geojson.Point;
66

77
import java.io.IOException;
8-
import java.util.Arrays;
98
import java.util.List;
109
import org.junit.Assert;
1110
import org.junit.Test;
@@ -22,6 +21,8 @@ public class DirectionsResponseTest extends TestUtils {
2221
private static final String DIRECTIONS_V5_MULTIPLE_ROUTES_WITH_OPTIONS =
2322
"directions_v5_multiple_routes_with_options.json";
2423
private static final String DIRECTIONS_V5_SILENT_WAYPOINT = "directions_v5_silent_waypoints.json";
24+
private static final String DIRECTIONS_WAYPOINTS_WITHOUT_NAMES =
25+
"directions_response_waypoints_without_names.json";
2526

2627
@Test
2728
public void sanity() throws Exception {
@@ -114,7 +115,7 @@ public void fromJson_deserializesOptions() throws Exception {
114115
}
115116

116117
@Test
117-
public void fromJson_deserializeWiaWaypoints() throws IOException {
118+
public void fromJson_deserializeViaWaypoints() throws IOException {
118119
String json = loadJsonFixture(DIRECTIONS_V5_SILENT_WAYPOINT);
119120

120121
DirectionsRoute route = DirectionsResponse.fromJson(json).routes().get(0);
@@ -138,4 +139,14 @@ public void fromToJsonForRouteWithSilentWaypoints() throws IOException {
138139

139140
assertEquals(initial, deserialized);
140141
}
142+
143+
@Test
144+
public void fromJson_deserializeWaypointsWithoutNames() throws Exception {
145+
String json = loadJsonFixture(DIRECTIONS_WAYPOINTS_WITHOUT_NAMES);
146+
147+
DirectionsResponse response = DirectionsResponse.fromJson(json);
148+
149+
assertNotNull(response);
150+
assertEquals(2, response.routes().size());
151+
}
141152
}

services-directions-models/src/test/resources/directions_response_waypoints_without_names.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)