Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,8 @@ class RoutingResponse {
notes,
resources
)

rawSegment.addProperty(SegmentJsonKeys.NODE_NOTES, notes)
}
rawSegment.addProperty(SegmentJsonKeys.NODE_NOTES, notes)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class RoutingResponseTest {

val motorbikeSegment = trip.segmentList[1]
assertThat(motorbikeSegment.alerts).hasSize(1).doesNotContainNull()
assertThat(motorbikeSegment.notes)
.describedAs("Template notes should be copied even without serviceDirection")
.contains("25km")

val alert = motorbikeSegment.alerts!![0]
assertThat(alert.severity()).isEqualTo(RealtimeAlert.SEVERITY_WARNING)
Expand All @@ -103,6 +106,51 @@ class RoutingResponseTest {
.isEqualTo("Unusually high traffic on the route.")
}

@Test
fun notesShouldRemainNullWhenTemplateNotesIsNull() {
val routingJson = """
{
"segmentTemplates": [
{
"hashCode": 1001,
"type": "unscheduled",
"visibility": "in summary",
"from": {"lat": -33.8, "lng": 151.2, "class": "Location"},
"to": {"lat": -33.9, "lng": 151.3, "class": "Location"},
"action": "Walk",
"notes": null
}
],
"groups": [
{
"trips": [
{
"segments": [
{
"segmentTemplateHashCode": 1001,
"startTime": 1422849991,
"endTime": 1422852824
}
]
}
]
}
]
}
""".trimIndent()

val gson = createForLowercaseEnum()
val response = gson.fromJson(routingJson, RoutingResponse::class.java)
response.processRawData(
ApplicationProvider.getApplicationContext<Context>().resources,
gson
)

val trip = response.tripGroupList!![0].trips!![0]
assertThat(trip.segmentList).hasSize(3)
assertNull(trip.segmentList[1].notes)
}

@Test
@Throws(IOException::class)
fun parseMultipleStreets() {
Expand Down
Loading