Search in sources :

Example 1 with NavigationRoute

use of com.mapbox.services.android.navigation.v5.navigation.NavigationRoute in project mapbox-navigation-android by mapbox.

the class NavigationRouteTest method addRouteOptionsIncludedInRequest.

@Test
public void addRouteOptionsIncludedInRequest() throws Exception {
    List<Point> coordinates = new ArrayList<>();
    coordinates.add(Point.fromLngLat(1.0, 2.0));
    coordinates.add(Point.fromLngLat(1.0, 5.0));
    RouteOptions routeOptions = RouteOptions.builder().accessToken(ACCESS_TOKEN).baseUrl("https://api-directions-traf.com").requestUuid("XYZ_UUID").alternatives(true).language(Locale.US.getLanguage()).profile(DirectionsCriteria.PROFILE_WALKING).coordinates(coordinates).voiceUnits(DirectionsCriteria.METRIC).user("example_user").build();
    NavigationRoute navigationRoute = NavigationRoute.builder().origin(coordinates.get(0)).destination(coordinates.get(1)).routeOptions(routeOptions).build();
    String request = navigationRoute.getCall().request().url().toString();
    assertThat(request, containsString("https://api-directions-traf.com"));
    assertThat(request, containsString("alternatives=true"));
    assertThat(request, containsString(ACCESS_TOKEN));
    assertThat(request, containsString("voice_units=metric"));
    assertThat(request, containsString("example_user"));
    assertThat(request, containsString("language=en"));
    assertThat(request, containsString("walking"));
}
Also used : ArrayList(java.util.ArrayList) Point(com.mapbox.geojson.Point) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RouteOptions(com.mapbox.api.directions.v5.models.RouteOptions) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 2 with NavigationRoute

use of com.mapbox.services.android.navigation.v5.navigation.NavigationRoute in project mapbox-navigation-android by mapbox.

the class NavigationRouteTest method addingPointAndBearingKeepsCorrectOrder.

@Test
public void addingPointAndBearingKeepsCorrectOrder() throws Exception {
    NavigationRoute navigationRoute = NavigationRoute.builder().accessToken(ACCESS_TOKEN).origin(Point.fromLngLat(1.0, 2.0), 90d, 90d).addBearing(2.0, 3.0).destination(Point.fromLngLat(1.0, 5.0)).build();
    String requestUrl = navigationRoute.getCall().request().url().toString();
    assertThat(requestUrl, containsString("bearings=90%2C90%3B2%2C3%3B"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Aggregations

BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 RouteOptions (com.mapbox.api.directions.v5.models.RouteOptions)1 Point (com.mapbox.geojson.Point)1 ArrayList (java.util.ArrayList)1