diff --git a/CommonCoreLegacy/src/main/java/com/skedgo/tripkit/routing/RoutingResponse.kt b/CommonCoreLegacy/src/main/java/com/skedgo/tripkit/routing/RoutingResponse.kt index 762823ba..fdf264d0 100644 --- a/CommonCoreLegacy/src/main/java/com/skedgo/tripkit/routing/RoutingResponse.kt +++ b/CommonCoreLegacy/src/main/java/com/skedgo/tripkit/routing/RoutingResponse.kt @@ -253,9 +253,8 @@ class RoutingResponse { notes, resources ) - - rawSegment.addProperty(SegmentJsonKeys.NODE_NOTES, notes) } + rawSegment.addProperty(SegmentJsonKeys.NODE_NOTES, notes) } } diff --git a/TripKitAndroid/src/test/java/com/skedgo/tripkit/RoutingResponseTest.kt b/TripKitAndroid/src/test/java/com/skedgo/tripkit/RoutingResponseTest.kt index 4ef49932..c35490da 100644 --- a/TripKitAndroid/src/test/java/com/skedgo/tripkit/RoutingResponseTest.kt +++ b/TripKitAndroid/src/test/java/com/skedgo/tripkit/RoutingResponseTest.kt @@ -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) @@ -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().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() {