-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAVAND-547 route refresh for new annotations (#7582)
- Loading branch information
1 parent
a73af29
commit 6f43f1a
Showing
13 changed files
with
21,005 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Route refresh now refreshes `LegAnnotation#freeflowSpeed` and `LegAnnotation#currentSpeed`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...mapbox/navigation/instrumentation_tests/utils/http/MockDynamicDirectionsRefreshHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.mapbox.navigation.instrumentation_tests.utils.http | ||
|
||
import com.mapbox.api.directionsrefresh.v1.models.DirectionsRefreshResponse | ||
import com.mapbox.api.directionsrefresh.v1.models.DirectionsRouteRefresh | ||
import com.mapbox.navigation.testing.ui.http.BaseMockRequestHandler | ||
import okhttp3.mockwebserver.MockResponse | ||
import okhttp3.mockwebserver.RecordedRequest | ||
|
||
data class RequestRequestParams( | ||
val routeUUID: String, | ||
val routeIndex: Int, | ||
val legIndex: Int, | ||
val geometryIndex: Int | ||
) | ||
|
||
class MockDynamicDirectionsRefreshHandler( | ||
val directionsResponseGenerator: (RequestRequestParams) -> DirectionsRouteRefresh | ||
) : BaseMockRequestHandler() { | ||
|
||
override fun handleInternal(request: RecordedRequest): MockResponse? { | ||
val expectedPrefix = "/directions-refresh/v1/mapbox/driving-traffic/" | ||
if (request.path!!.startsWith(expectedPrefix)) { | ||
val segments = request.requestUrl!!.encodedPathSegments | ||
if (segments.size < 7) return null | ||
val routeUUID = segments[4] | ||
val routeIndex = segments[5].toIntOrNull() ?: return null | ||
val legIndex = segments[6].toIntOrNull() ?: return null | ||
val currentGeometryIndex = request.requestUrl!! | ||
.queryParameter("current_route_geometry_index")?.toIntOrNull() | ||
?: return null | ||
val routeRefresh = directionsResponseGenerator( | ||
RequestRequestParams( | ||
legIndex = legIndex, | ||
geometryIndex = currentGeometryIndex, | ||
routeUUID = routeUUID, | ||
routeIndex = routeIndex | ||
) | ||
) | ||
val response = DirectionsRefreshResponse.builder() | ||
.code("Ok") | ||
.route(routeRefresh) | ||
.build() | ||
.toJson() | ||
return MockResponse().setBody(response) | ||
} | ||
return null | ||
} | ||
} |
Oops, something went wrong.