Skip to content

Commit 1c80b0e

Browse files
committed
add missing properties to Incident object
1 parent 9830e09 commit 1c80b0e

2 files changed

Lines changed: 74 additions & 2 deletions

File tree

  • services-directions-models/src

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,36 @@ public abstract class Incident extends DirectionsJsonObject {
249249
@SerializedName("end_time")
250250
public abstract String endTime();
251251

252+
/**
253+
* Two letter country code where the incident is located.
254+
* @see <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2.">ISO Country code Wikipedia page</a>
255+
*/
256+
@Nullable
257+
@SerializedName("iso_3166_1_alpha2")
258+
public abstract String countryCodeAlpha2();
259+
260+
/**
261+
* Three letter country code where the incident is located.
262+
* @see <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3.">ISO Country code Wikipedia page</a>
263+
*/
264+
@Nullable
265+
@SerializedName("iso_3166_1_alpha3")
266+
public abstract String countryCodeAlpha3();
267+
268+
/**
269+
* A list of lanes that are blocked by the incident.
270+
*/
271+
@Nullable
272+
@SerializedName("lanes_blocked")
273+
public abstract List<String> lanesBlocked();
274+
275+
/**
276+
* The number of items in the {@link Incident#lanesBlocked()} list.
277+
*/
278+
@Nullable
279+
@SerializedName("num_lanes_blocked")
280+
public abstract Integer numLanesBlocked();
281+
252282
/**
253283
* Create a new instance of this class by using the {@link Incident.Builder} class.
254284
*
@@ -406,6 +436,36 @@ public abstract static class Builder {
406436
*/
407437
public abstract Builder endTime(@Nullable String endTime);
408438

439+
/**
440+
* Two letter country code where the incident is located.
441+
* @see <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2.">ISO Country code Wikipedia page</a>
442+
*
443+
* @param countryCodeAlpha2 2 letter country code
444+
*/
445+
public abstract Builder countryCodeAlpha2(@Nullable String countryCodeAlpha2);
446+
447+
/**
448+
* Three letter country code where the incident is located.
449+
* @see <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3.">ISO Country code Wikipedia page</a>
450+
*
451+
* @param countryCodeAlpha3 3 letter country code
452+
*/
453+
public abstract Builder countryCodeAlpha3(@Nullable String countryCodeAlpha3);
454+
455+
/**
456+
* A list of lanes that are blocked by the incident.
457+
*
458+
* @param lanesBlocked lanes blocked
459+
*/
460+
public abstract Builder lanesBlocked(@Nullable List<String> lanesBlocked);
461+
462+
/**
463+
* The number of items in the {@link Incident#lanesBlocked()} list.
464+
*
465+
* @param numLanesBlocked number lanes blocked
466+
*/
467+
public abstract Builder numLanesBlocked(@Nullable Integer numLanesBlocked);
468+
409469
/**
410470
* Build a new instance of {@link Incident}.
411471
*

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import com.mapbox.core.TestUtils;
55
import org.junit.Test;
66

7-
import static org.junit.Assert.assertEquals;
8-
import static org.junit.Assert.assertNotNull;
7+
import java.util.ArrayList;
8+
9+
import static org.junit.Assert.*;
910

1011
public class IncidentTest extends TestUtils {
1112

@@ -32,6 +33,10 @@ public void testSerializableObject() throws Exception {
3233
.subType("sub type")
3334
.subTypeDescription("sub type desc")
3435
.type(Incident.INCIDENT_DISABLED_VEHICLE)
36+
.lanesBlocked(Lists.<String>newArrayList())
37+
.numLanesBlocked(null)
38+
.countryCodeAlpha2("US")
39+
.countryCodeAlpha3("USA")
3540
.build();
3641
byte[] serialized = TestUtils.serialize(incident);
3742
assertEquals(incident, deserialize(serialized, Incident.class));
@@ -57,6 +62,9 @@ public void testSerializableFromJson(){
5762
"803" +
5863
"]," +
5964
"\"lanes_blocked\": []," +
65+
"\"num_lanes_blocked\": null," +
66+
"\"iso_3166_1_alpha2\": US," +
67+
"\"iso_3166_1_alpha3\": USA," +
6068
"\"geometry_index_start\": 805," +
6169
"\"geometry_index_end\": 896" +
6270
"}";
@@ -78,6 +86,10 @@ public void testSerializableFromJson(){
7886
assertEquals(fromJson.alertcCodes().size(), 2);
7987
assertEquals(fromJson.geometryIndexStart().longValue(), 805L);
8088
assertEquals(fromJson.geometryIndexEnd().longValue(), 896L);
89+
assertEquals(fromJson.countryCodeAlpha2(), "US");
90+
assertEquals(fromJson.countryCodeAlpha3(), "USA");
91+
assertEquals(fromJson.lanesBlocked().size(), 0);
92+
assertNull(fromJson.numLanesBlocked());
8193
}
8294

8395
private Incident getDefault() {

0 commit comments

Comments
 (0)