Skip to content

Commit

Permalink
fixed code style
Browse files Browse the repository at this point in the history
  • Loading branch information
VysotskiVadim committed Oct 24, 2023
1 parent fd68f16 commit c0fdd97
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ class MapboxNavigation @VisibleForTesting internal constructor(
),
historyRecorderHandles.composite,
)
val routeParsingManager = createRouteParsingManager(navigationOptions.longRoutesOptimisationOptions)
val routeParsingManager = createRouteParsingManager(
navigationOptions.longRoutesOptimisationOptions
)
routeParsingManager.setPrepareForParsingAction(this::prepareNavigationForRoutesParsing)
val result = MapboxModuleProvider.createModule<Router>(MapboxModuleType.NavigationRouter) {
paramsProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ internal class RouteAlternativesController constructor(
origin
)
}

}
)
}
Expand Down Expand Up @@ -245,7 +244,8 @@ internal class RouteAlternativesController constructor(
RouteResponseInfo.fromResponses(allAlternatives.map { it.responseJsonRef.buffer }),
userTriggeredAlternativesRefresh = immediateAlternativesRefresh
)
val alternativesParsingResult: AlternativesParsingResult<Expected<Throwable, List<NavigationRoute>>> =
val alternativesParsingResult:
AlternativesParsingResult<Expected<Throwable, List<NavigationRoute>>> =
routeParsingManager.parseAlternatives(args) { parseArgs ->
withContext(ThreadController.DefaultDispatcher) {
parseRouteInterfaces(
Expand All @@ -258,7 +258,9 @@ internal class RouteAlternativesController constructor(
val expected = when (alternativesParsingResult) {
AlternativesParsingResult.NotActual -> {
notActualParsingCallback(getOrigin(nativeAlternatives))
ExpectedFactory.createError(Throwable("cancelled because another parsing is already in progress"))
ExpectedFactory.createError(
Throwable("cancelled because another parsing is already in progress")
)
}
is AlternativesParsingResult.Parsed -> alternativesParsingResult.value
}
Expand All @@ -271,7 +273,7 @@ internal class RouteAlternativesController constructor(
|unable to parse alternatives;
|failure for response with uuid:
|${nativeAlternatives.firstOrNull()?.route?.responseUuid}
""".trimMargin(),
""".trimMargin(),
LOG_CATEGORY
)
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ internal object MapboxNavigationTelemetry {
}
resetLocalVariables()
resetDynamicValues()
routeData.originalRouteMetrics = MetricsDirectionsRoute(routes.first().directionsRoute)
routeData.originalRouteMetrics = MetricsDirectionsRoute(
routes.first().directionsRoute
)
routeData.needHandleDeparture = true
}
reason == RoutesExtra.ROUTES_UPDATE_REASON_ALTERNATIVE -> {
Expand All @@ -239,7 +241,9 @@ internal object MapboxNavigationTelemetry {
handleReroute(routes.first().directionsRoute)
}
reason == RoutesExtra.ROUTES_UPDATE_REASON_REFRESH -> {
routeData.originalRouteMetrics = MetricsDirectionsRoute(routes.first().directionsRoute)
routeData.originalRouteMetrics = MetricsDirectionsRoute(
routes.first().directionsRoute
)
}
else -> logW(
"Unknown route update reason: [$reason]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.mapbox.navigation.core.telemetry.events

import com.mapbox.api.directions.v5.models.DirectionsRoute
import com.mapbox.navigation.base.route.NavigationRoute
import com.mapbox.navigation.core.telemetry.obtainStepCount

internal data class MetricsDirectionsRoute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class RoutesCacheClearerTest {

verify(exactly = 1) { DecodeUtils.clearCache() }
verify(exactly = 0) { DecodeUtils.clearCacheExceptFor(any()) }

}

@Test
Expand All @@ -55,7 +54,9 @@ class RoutesCacheClearerTest {
sut.onRoutesChanged(createRoutesUpdatedResult(testRoutes, ""))

verify(exactly = 0) { DecodeUtils.clearCache() }
verify(exactly = 1) { DecodeUtils.clearCacheExceptFor(testRoutes.first().directionsResponse.routes()) }
verify(exactly = 1) {
DecodeUtils.clearCacheExceptFor(testRoutes.first().directionsResponse.routes())
}
}

@Test
Expand All @@ -64,14 +65,25 @@ class RoutesCacheClearerTest {
createDirectionsResponse(uuid = "preview")
)
sut.routesPreviewUpdated(
RoutesPreviewUpdate("", RoutesPreview(testPreviewRoutes, emptyList(), testPreviewRoutes, 0))
RoutesPreviewUpdate(
"",
RoutesPreview(testPreviewRoutes, emptyList(), testPreviewRoutes, 0)
)
)
clearStaticMockk(DecodeUtils::class)

sut.onRoutesChanged(createRoutesUpdatedResult(emptyList(), ""))

verify(exactly = 0) { DecodeUtils.clearCache() }
verify(exactly = 1) { DecodeUtils.clearCacheExceptFor(match { it.map { it.requestUuid() } == listOf("preview") }) }
verify(exactly = 1) {
DecodeUtils.clearCacheExceptFor(
match {
it.map { it.requestUuid() } == listOf(
"preview"
)
}
)
}
}

@Test
Expand Down Expand Up @@ -131,7 +143,12 @@ class RoutesCacheClearerTest {

@Test
fun routesPreviewUpdated_emptyRoutesAndHasActiveRoutes() {
sut.onRoutesChanged(createRoutesUpdatedResult(createNavigationRoutes(), RoutesExtra.ROUTES_UPDATE_REASON_NEW))
sut.onRoutesChanged(
createRoutesUpdatedResult(
createNavigationRoutes(),
RoutesExtra.ROUTES_UPDATE_REASON_NEW
)
)
clearStaticMockk(DecodeUtils::class)

sut.routesPreviewUpdated(
Expand Down Expand Up @@ -177,7 +194,10 @@ class RoutesCacheClearerTest {
response = createDirectionsResponse(uuid = "active")
)
sut.routesPreviewUpdated(
RoutesPreviewUpdate("", RoutesPreview(testPreviewRoutes, emptyList(), testPreviewRoutes, 0))
RoutesPreviewUpdate(
"",
RoutesPreview(testPreviewRoutes, emptyList(), testPreviewRoutes, 0)
)
)
clearStaticMockk(DecodeUtils::class)

Expand All @@ -187,7 +207,7 @@ class RoutesCacheClearerTest {
verify(exactly = 1) {
DecodeUtils.clearCacheExceptFor(
match {
it.map { it.requestUuid() }.sortedBy { it } == listOf("active", "preview", )
it.map { it.requestUuid() }.sortedBy { it } == listOf("active", "preview")
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ class RouteAlternativesControllerTest {

@Test
fun `should set RouteOptions to alternative routes`() = coroutineRule.runBlockingTest {

val routeAlternativesController = createRouteAlternativesController()
val nativeObserver = slot<com.mapbox.navigator.RouteAlternativesObserver>()
every { controllerInterface.addObserver(capture(nativeObserver)) } just runs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,8 @@ class MapboxNavigationTelemetryTest {
every { anotherRouteOptions.profile() } returns ANOTHER_ROUTE_OPTIONS_PROFILE
every { anotherRouteOptions.geometries() } returns DirectionsCriteria.GEOMETRY_POLYLINE6
every { anotherRoute.directionsResponse.uuid() } returns ANOTHER_ROUTE_OPTIONS_REQUEST_UUID
every { anotherRoute.directionsRoute.requestUuid() } returns ANOTHER_ROUTE_OPTIONS_REQUEST_UUID
every { anotherRoute.directionsRoute.requestUuid() } returns
ANOTHER_ROUTE_OPTIONS_REQUEST_UUID
every { anotherRouteLeg.steps() } returns progressRouteSteps
every { anotherRouteStep.maneuver() } returns anotherStepManeuver
every { anotherStepManeuver.location() } returns anotherStepManeuverLocation
Expand Down

0 comments on commit c0fdd97

Please sign in to comment.