@@ -2,10 +2,12 @@ package com.mbta.tid.mbta_app.repositories
22
33import com.mbta.tid.mbta_app.AppVariant
44import com.mbta.tid.mbta_app.model.Route
5+ import com.mbta.tid.mbta_app.model.RoutePatternKey
6+ import com.mbta.tid.mbta_app.model.RouteSegment
7+ import com.mbta.tid.mbta_app.model.SegmentedRouteShape
58import com.mbta.tid.mbta_app.model.Shape
6- import com.mbta.tid.mbta_app.model.TripShape
79import com.mbta.tid.mbta_app.model.response.ApiResult
8- import com.mbta.tid.mbta_app.model.response.ShapeWithStops
10+ import com.mbta.tid.mbta_app.model.response.MapFriendlyRouteResponse
911import com.mbta.tid.mbta_app.model.response.TripSchedulesResponse
1012import com.mbta.tid.mbta_app.network.MobileBackendClient
1113import io.ktor.client.engine.mock.MockEngine
@@ -55,14 +57,42 @@ class TripRepositoryTest : KoinTest {
5557 respond(
5658 """
5759 {
58- "shape_with_stops": {
59- "shape": {"id": "shape_id", "polyline": "shape_polyline"},
60- "stop_ids": ["1", "2", "3"],
61- "route_id": "66",
62- "route_pattern_id": "66_rp",
63- "direction_id": 1
60+ "map_friendly_route_shapes": [
61+ {
62+ "route_id": "66",
63+ "route_shapes": [
64+ {
65+ "direction_id": 1,
66+ "shape": {
67+ "id": "shape_id",
68+ "polyline": "shape_polyline"
69+ },
70+ "source_route_pattern_id": "66_rp",
71+ "source_route_id": "66",
72+ "route_segments": [
73+ {
74+ "id": "1-3",
75+ "stop_ids": ["1","2","3"],
76+ "source_route_pattern_id": "66_rp",
77+ "source_route_id": "66",
78+ "other_patterns_by_stop_id": {
79+ "1": [
80+ { "route_id": "66", "route_pattern_id": "66_rp_2" }
81+ ],
82+ "2": [
83+ { "route_id": "66", "route_pattern_id": "66_rp_2" }
84+ ],
85+ "3": [
86+ { "route_id": "66", "route_pattern_id": "66_rp_2" }
87+ ]
88+ }
89+ }
90+ ]
91+ }
92+ ]
93+ }
94+ ]
6495 }
65- }
6696 """
6797 .trimIndent(),
6898 headers = headersOf(HttpHeaders .ContentType , " application/json" ),
@@ -75,17 +105,62 @@ class TripRepositoryTest : KoinTest {
75105
76106 runBlocking {
77107 val response = TripRepository ().getTripShape(tripId = " 12345" )
108+ val routeId = Route .Id (" 66" )
78109
79110 assertEquals(
80111 ApiResult .Ok (
81- TripShape (
82- shapeWithStops =
83- ShapeWithStops (
84- directionId = 1 ,
85- routeId = Route .Id (" 66" ),
86- routePatternId = " 66_rp" ,
87- shape = Shape (id = " shape_id" , polyline = " shape_polyline" ),
88- stopIds = listOf (" 1" , " 2" , " 3" ),
112+ MapFriendlyRouteResponse (
113+ routesWithSegmentedShapes =
114+ listOf (
115+ MapFriendlyRouteResponse .RouteWithSegmentedShapes (
116+ routeId = routeId,
117+ segmentedShapes =
118+ listOf (
119+ SegmentedRouteShape (
120+ sourceRoutePatternId = " 66_rp" ,
121+ sourceRouteId = routeId,
122+ directionId = 1 ,
123+ routeSegments =
124+ listOf (
125+ RouteSegment (
126+ id = " 1-3" ,
127+ sourceRoutePatternId = " 66_rp" ,
128+ sourceRouteId = routeId,
129+ stopIds = listOf (" 1" , " 2" , " 3" ),
130+ otherPatternsByStopId =
131+ mapOf (
132+ " 1" to
133+ listOf (
134+ RoutePatternKey (
135+ routeId,
136+ " 66_rp_2" ,
137+ )
138+ ),
139+ " 2" to
140+ listOf (
141+ RoutePatternKey (
142+ routeId,
143+ " 66_rp_2" ,
144+ )
145+ ),
146+ " 3" to
147+ listOf (
148+ RoutePatternKey (
149+ routeId,
150+ " 66_rp_2" ,
151+ )
152+ ),
153+ ),
154+ )
155+ ),
156+ shape =
157+ Shape (
158+ id = " shape_id" ,
159+ polyline = " shape_polyline" ,
160+ ),
161+ )
162+ ),
163+ )
89164 )
90165 )
91166 ),
@@ -147,7 +222,10 @@ class TripRepositoryTest : KoinTest {
147222 val apiResult = TripRepository ().getTripShape(tripId = " 12345" )
148223 assertIs<ApiResult .Error <* >>(apiResult)
149224
150- assertContains(apiResult.message, " Field 'shape_with_stops' is required for type" )
225+ assertContains(
226+ apiResult.message,
227+ " Field 'map_friendly_route_shapes' is required for type" ,
228+ )
151229 }
152230
153231 stopKoin()
0 commit comments