Skip to content

Commit af2493a

Browse files
authored
tunnelName field (#1197)
1 parent cac4e82 commit af2493a

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ public Point location() {
196196
@SerializedName("mapbox_streets_v8")
197197
public abstract MapboxStreetsV8 mapboxStreetsV8();
198198

199+
/**
200+
* Name of the tunnel. Value may be present if {@link #classes} contains "tunnel".
201+
*
202+
* @return name of the tunnel
203+
*/
204+
@Nullable
205+
@SerializedName("tunnel_name")
206+
public abstract String tunnelName();
207+
199208
/**
200209
* Convert the current {@link StepIntersection} to its builder holding the currently assigned
201210
* values. This allows you to modify a single property and then rebuild the object resulting in
@@ -383,6 +392,14 @@ public abstract static class Builder {
383392
@Nullable
384393
public abstract Builder mapboxStreetsV8(@Nullable MapboxStreetsV8 street);
385394

395+
/**
396+
* Name of the tunnel. Value is present only if class is tunnel.
397+
*
398+
* @param tunnelName name of the tunnel
399+
* @return this builder for chaining options together
400+
*/
401+
public abstract Builder tunnelName(@Nullable String tunnelName);
402+
386403
/**
387404
* The rawLocation as a double array. Once the {@link StepIntersection} object's created,
388405
* this raw location gets converted into a {@link Point} object and is public exposed as such.

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ public void testToFromJson1() {
5050
.tollCollection(TollCollection.builder().type("toll_gantry").build())
5151
.adminIndex(2)
5252
.mapboxStreetsV8(MapboxStreetsV8.builder().roadClass("street").build())
53+
.tunnelName("tunnel_name")
5354
.build();
5455

5556
String jsonString = intersection.toJson();
5657
StepIntersection intersectionFromJson = StepIntersection.fromJson(jsonString);
5758

58-
Assert.assertEquals(intersection, intersectionFromJson);
59+
assertEquals(intersection, intersectionFromJson);
5960
}
6061

6162
@Test
@@ -67,12 +68,13 @@ public void testToFromJson2() {
6768
.bearings(Arrays.asList(120, 210, 300))
6869
.rawLocation(new double[]{13.424671, 52.508812})
6970
.mapboxStreetsV8(MapboxStreetsV8.builder().roadClass("street").build())
71+
.tunnelName("tunnel_name")
7072
.build();
7173

7274
String jsonString = intersection.toJson();
7375
StepIntersection intersectionFromJson = StepIntersection.fromJson(jsonString);
7476

75-
Assert.assertEquals(intersection, intersectionFromJson);
77+
assertEquals(intersection, intersectionFromJson);
7678
}
7779

7880

@@ -85,17 +87,19 @@ public void testFromJson() {
8587
+ "\"out\": 0, "
8688
+ "\"geometry_index\": 123,"
8789
+ "\"is_urban\": true,"
88-
+ "\"mapbox_streets_v8\": {\"class\": \"street\"}"
90+
+ "\"mapbox_streets_v8\": {\"class\": \"street\"},"
91+
+ "\"tunnel_name\": \"test tunnel name\""
8992
+ "}";
9093

9194
StepIntersection stepIntersection = StepIntersection.fromJson(stepIntersectionJsonString);
92-
Assert.assertEquals(123, stepIntersection.geometryIndex().intValue());
95+
assertEquals(123, stepIntersection.geometryIndex().intValue());
9396
assertTrue(stepIntersection.isUrban());
9497
assertEquals("street", stepIntersection.mapboxStreetsV8().roadClass());
98+
assertEquals("test tunnel name", stepIntersection.tunnelName());
9599

96100
Point location = stepIntersection.location();
97-
Assert.assertEquals(13.426579, location.longitude(), 0.0001);
98-
Assert.assertEquals(52.508068, location.latitude(), 0.0001);
101+
assertEquals(13.426579, location.longitude(), 0.0001);
102+
assertEquals(52.508068, location.latitude(), 0.0001);
99103

100104
String jsonStr = stepIntersection.toJson();
101105

0 commit comments

Comments
 (0)