4040
4141public class MapboxDirectionsTest {
4242
43- public static final String DIRECTIONS_V5_FIXTURE = "src/test/fixtures/directions_v5.json" ;
44- public static final String DIRECTIONS_V5_PRECISION6_FIXTURE = "src/test/fixtures/directions_v5_precision_6.json" ;
45- public static final String DIRECTIONS_TRAFFIC_FIXTURE = "src/test/fixtures/directions_v5_traffic.json" ;
46- public static final String DIRECTIONS_ROTARY_FIXTURE = "src/test/fixtures/directions_v5_fixtures_rotary.json" ;
43+ private static final String DIRECTIONS_V5_FIXTURE = "src/test/fixtures/directions_v5.json" ;
44+ private static final String DIRECTIONS_V5_PRECISION6_FIXTURE = "src/test/fixtures/directions_v5_precision_6.json" ;
45+ private static final String DIRECTIONS_TRAFFIC_FIXTURE = "src/test/fixtures/directions_v5_traffic.json" ;
46+ private static final String DIRECTIONS_ROTARY_FIXTURE = "src/test/fixtures/directions_v5_fixtures_rotary.json" ;
4747 private static final double DELTA = 1E-10 ;
4848
4949 private MockWebServer server ;
@@ -108,11 +108,11 @@ public void requiredAccessToken() throws ServicesException {
108108 @ Test
109109 public void callFactoryNonNull () throws ServicesException , IOException {
110110 MapboxDirections client = new MapboxDirections .Builder ()
111- .setAccessToken ("pk.XXX" )
112- .setCoordinates (positions )
113- .setProfile (DirectionsCriteria .PROFILE_DRIVING )
114- .setBaseUrl (mockUrl .toString ())
115- .build ();
111+ .setAccessToken ("pk.XXX" )
112+ .setCoordinates (positions )
113+ .setProfile (DirectionsCriteria .PROFILE_DRIVING )
114+ .setBaseUrl (mockUrl .toString ())
115+ .build ();
116116
117117 // Setting a null call factory doesn't make the request fail
118118 // (the default OkHttp client is used)
@@ -499,7 +499,7 @@ public void testRotaryLegStepAndStepManeuver() throws ServicesException, IOExcep
499499 assertEquals (maneuver .getModifier (), "slight right" );
500500 assertEquals (maneuver .getInstruction (),
501501 "Enter Dupont Circle Northwest and take the 3rd exit onto P Street Northwest" );
502- assertEquals (maneuver .getExit (), new Integer (3 ));
502+ assertEquals (maneuver .getExit (), Integer . valueOf (3 ));
503503
504504
505505 LegStep step = response .body ().getRoutes ().get (0 ).getLegs ().get (0 ).getSteps ().get (1 );
@@ -510,7 +510,7 @@ public void testRotaryLegStepAndStepManeuver() throws ServicesException, IOExcep
510510
511511 @ Test
512512 public void testSetCoordinates () {
513- ArrayList test = new ArrayList <>();
513+ List < Position > test = new ArrayList <>();
514514 test .add (Position .fromCoordinates (2.1 , 2.2 ));
515515 test .add (Position .fromCoordinates (3.1 , 3.2 ));
516516
@@ -531,7 +531,7 @@ public void setOriginDestination() {
531531
532532 @ Test
533533 public void testSetCoordinatesMixed () {
534- ArrayList test = new ArrayList <>();
534+ List < Position > test = new ArrayList <>();
535535 test .add (Position .fromCoordinates (2.1 , 2.2 ));
536536 test .add (Position .fromCoordinates (3.1 , 3.2 ));
537537
@@ -544,24 +544,9 @@ public void testSetCoordinatesMixed() {
544544 assertEquals (coordinates , "1.100000,1.200000;2.100000,2.200000;3.100000,3.200000;4.100000,4.200000" );
545545 }
546546
547- @ Test
548- public void testSetCoordinatesMixedHidden () {
549- ArrayList test = new ArrayList <>();
550- test .add (Position .fromCoordinates (2.1 , 2.2 ));
551- test .add (Position .fromCoordinates (3.1 , 3.2 ));
552-
553- // The order matters
554- String coordinates = new MapboxDirections .Builder ()
555- .setOrigin (Position .fromCoordinates (1.1 , 1.2 ))
556- .setDestination (Position .fromCoordinates (4.1 , 4.2 ))
557- .setCoordinates (test )
558- .getCoordinates ();
559- assertEquals (coordinates , "2.100000,2.200000;3.100000,3.200000" );
560- }
561-
562547 @ Test
563548 public void testLocale () {
564- ArrayList test = new ArrayList <>();
549+ List < Position > test = new ArrayList <>();
565550 test .add (Position .fromCoordinates (2.1 , 2.2 ));
566551 test .add (Position .fromCoordinates (3.1 , 3.2 ));
567552
@@ -572,7 +557,7 @@ public void testLocale() {
572557 .setDestination (Position .fromCoordinates (4.1 , 4.2 ))
573558 .setCoordinates (test )
574559 .getCoordinates ();
575- assertEquals (coordinates , "2.100000,2.200000;3.100000,3.200000" );
560+ assertEquals (coordinates , "1.100000,1.200000; 2.100000,2.200000;3.100000,3.200000;4.100000,4 .200000" );
576561 }
577562
578563 @ Test
@@ -586,4 +571,21 @@ public void testUserAgent() throws ServicesException, IOException {
586571 .build ();
587572 assertTrue (service .executeCall ().raw ().request ().header ("User-Agent" ).contains ("APP" ));
588573 }
574+
575+ @ Test
576+ public void originDestinationCoordinatesListCorrectOrder () throws ServicesException , IOException {
577+ MapboxDirections client = new MapboxDirections .Builder ()
578+ .setAccessToken ("pk.XXX" )
579+ .setOrigin (Position .fromCoordinates (-122.4313 , 37.7789 ))
580+ .setCoordinates (positions )
581+ .setDestination (Position .fromCoordinates (-121.8001 , 37.2275 ))
582+ .setProfile (DirectionsCriteria .PROFILE_DRIVING )
583+ .setBaseUrl (mockUrl .toString ())
584+ .build ();
585+
586+ String callUrl = client .executeCall ().raw ().request ().url ().toString ();
587+ assertTrue (
588+ callUrl .contains ("-122.431300,37.778900;-122.416667,37.783333;-121.900000,37.333333;-121.800100,37.227500" )
589+ );
590+ }
589591}
0 commit comments