Skip to content

Commit

Permalink
bump NN, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
korshaknn committed Sep 20, 2021
1 parent 734265f commit 076a6e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package com.mapbox.navigation.route.internal

import com.mapbox.api.directions.v5.DirectionsCriteria
import com.mapbox.navigation.base.route.RouterOrigin.Offboard
import com.mapbox.navigation.base.route.RouterOrigin.Onboard
import com.mapbox.navigator.RouterOrigin
import com.mapbox.navigator.RoutingMode

internal fun RouterOrigin.mapToSdkRouteOrigin(): com.mapbox.navigation.base.route.RouterOrigin {
return when (this) {
RouterOrigin.ONLINE -> Offboard
RouterOrigin.ONBOARD -> Onboard
}
}

internal fun String.mapToRoutingMode(): RoutingMode {
return when (this) {
DirectionsCriteria.PROFILE_CYCLING -> RoutingMode.CYCLING
DirectionsCriteria.PROFILE_WALKING -> RoutingMode.WALKING
DirectionsCriteria.PROFILE_DRIVING -> RoutingMode.DRIVING
DirectionsCriteria.PROFILE_DRIVING_TRAFFIC -> RoutingMode.DRIVING_TRAFFIC
else -> throw IllegalArgumentException("Invalid routing profile: $this")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ class RouterWrapper(
return REQUEST_FAILURE
}

val userAndProfile = "${routeOptions.user()}/${routeOptions.profile()}"
val refreshOptions = RouteRefreshOptions(
requestUuid,
routeIndex,
legIndex,
RoutingProfile(userAndProfile),
RoutingProfile(routeOptions.profile().mapToRoutingMode(), routeOptions.user())
)

return router.getRouteRefresh(refreshOptions, route.toJson()) { result, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -424,7 +423,6 @@ class RouterWrapperTests {
assertEquals(expectedErrorMessage, errorSlot.captured.throwable?.message)
}

@Ignore("Remove after https://github.com/mapbox/mapbox-navigation-native/issues/4016")
@Test
fun `route refresh set right params`() {
val route: DirectionsRoute = mockk(relaxed = true)
Expand All @@ -438,7 +436,7 @@ class RouterWrapperTests {
UUID,
1,
0,
RoutingProfile("${routerOptions.user()}/${routerOptions.profile()}")
RoutingProfile(routerOptions.profile().mapToRoutingMode(), routerOptions.user())
)

verify(exactly = 1) {
Expand All @@ -450,31 +448,13 @@ class RouterWrapperTests {
}
}

@Ignore("Remove after https://github.com/mapbox/mapbox-navigation-native/issues/4016")
@Test
fun `route refresh set non-valid route index`() {
routerWrapper.getRouteRefresh(route, 0, routerRefreshCallback)

val expectedRefreshOptions = RouteRefreshOptions(
UUID,
0,
0,
RoutingProfile("${routerOptions.user()}/${routerOptions.profile()}")
)

verify(exactly = 1) {
router.getRouteRefresh(
expectedRefreshOptions,
route.toJson(),
any()
)
}
}

@Ignore("Remove after https://github.com/mapbox/mapbox-navigation-native/issues/4016")
@Test
fun `route refresh successful`() = runBlockingTest {
val route = DirectionsRoute.fromJson(ROUTE, routerOptions, UUID)
val route: DirectionsRoute = mockk(relaxed = true)
every { route.requestUuid() } returns UUID
every { route.routeIndex() } returns "1"
every { route.routeOptions() } returns routerOptions

routerWrapper.getRouteRefresh(route, 0, routerRefreshCallback)
refreshRouteSlot.captured.run(routerRefreshSuccess, nativeOriginOnboard)

Expand All @@ -487,11 +467,14 @@ class RouterWrapperTests {
verify(exactly = 1) { routerRefreshCallback.onRefresh(expected) }
}

@Ignore("Remove after https://github.com/mapbox/mapbox-navigation-native/issues/4016")
@Test
fun `route refresh failure`() {
val route: DirectionsRoute = mockk(relaxed = true)
every { route.requestUuid() } returns UUID
every { route.routeIndex() } returns "1"
every { route.routeOptions() } returns routerOptions

val legIndex = 0
val route = DirectionsRoute.fromJson(ROUTE, routerOptions, UUID)
routerWrapper.getRouteRefresh(route, legIndex, routerRefreshCallback)
refreshRouteSlot.captured.run(routerResultFailure, nativeOriginOnboard)

Expand Down

0 comments on commit 076a6e2

Please sign in to comment.