2020import org .junit .rules .ExpectedException ;
2121
2222import java .io .IOException ;
23+ import java .net .URLEncoder ;
2324import java .util .ArrayList ;
2425import java .util .List ;
2526import java .util .Locale ;
@@ -299,8 +300,8 @@ public void annotations_doesGetFormattedInUrlCorrectly() throws Exception {
299300 .overview (DirectionsCriteria .OVERVIEW_FULL )
300301 .accessToken (ACCESS_TOKEN )
301302 .build ();
302- assertTrue ( directions . cloneCall (). request (). url (). toString ()
303- . contains ( "annotations=congestion,duration " ));
303+ assertEquals ( "congestion,duration" ,
304+ directions . cloneCall (). request (). url (). queryParameter ( "annotations" ));
304305 }
305306
306307 @ Test
@@ -312,7 +313,8 @@ public void addBearing_doesGetFormattedInUrlCorrectly() throws Exception {
312313 .addBearing (2d , 90d )
313314 .accessToken (ACCESS_TOKEN )
314315 .build ();
315- assertTrue (directions .cloneCall ().request ().url ().toString ().contains ("bearings=45,90;2,90" ));
316+ assertEquals ("45,90;2,90" ,
317+ directions .cloneCall ().request ().url ().queryParameter ("bearings" ));
316318 }
317319
318320 @ Test
@@ -323,7 +325,8 @@ public void radiuses_doesGetFormattedInUrlCorrectly() throws Exception {
323325 .radiuses (23 , 30 )
324326 .accessToken (ACCESS_TOKEN )
325327 .build ();
326- assertTrue (directions .cloneCall ().request ().url ().toString ().contains ("radiuses=23;30" ));
328+ assertEquals ("23;30" ,
329+ directions .cloneCall ().request ().url ().queryParameter ("radiuses" ));
327330 }
328331
329332 @ Test
@@ -458,8 +461,8 @@ public void testRadiusWithUnlimitedDistance() throws IOException {
458461 .radiuses (100 , Double .POSITIVE_INFINITY , 100 )
459462 .build ();
460463
461- assertThat ( client . cloneCall (). request (). url (). toString () ,
462- containsString ( "radiuses=100;unlimited;100 " ));
464+ assertEquals ( "100;unlimited;100" ,
465+ client . cloneCall (). request (). url (). queryParameter ( "radiuses" ));
463466 }
464467
465468 @ Test
@@ -576,8 +579,9 @@ public void sanityApproachesInstructions() throws Exception {
576579 .accessToken (ACCESS_TOKEN )
577580 .build ();
578581 assertNotNull (mapboxDirections );
579- assertTrue (mapboxDirections .cloneCall ().request ().url ().toString ()
580- .contains ("approaches=unrestricted;;;curb" ));
582+
583+ assertEquals ("unrestricted;;;curb" ,
584+ mapboxDirections .cloneCall ().request ().url ().queryParameter ("approaches" ));
581585 }
582586
583587 @ Test
@@ -640,7 +644,9 @@ public void testRouteOptionsApproaches() throws Exception {
640644 Response <DirectionsResponse > response = mapboxDirections .executeCall ();
641645 RouteOptions routeOptions = response .body ().routes ().get (0 ).routeOptions ();
642646
643- assertEquals ("unrestricted;curb" , routeOptions .approaches ());
647+
648+ String approaches = routeOptions .approaches ();
649+ assertEquals ("unrestricted;curb" , approaches );
644650 }
645651
646652 @ Test
@@ -654,8 +660,8 @@ public void sanityWaypointNamesInstructions() throws Exception {
654660 .accessToken (ACCESS_TOKEN )
655661 .build ();
656662 assertNotNull (mapboxDirections );
657- assertTrue ( mapboxDirections . cloneCall (). request (). url (). toString ()
658- . contains ( "waypoint_names=Home;Store;Work " ));
663+ assertEquals ( "Home;Store;Work" ,
664+ mapboxDirections . cloneCall (). request (). url (). queryParameter ( "waypoint_names" ));
659665 }
660666
661667 @ Test
@@ -680,7 +686,7 @@ public void build_exceptionThrownWhenWaypointNamesExceedLimit() throws Exception
680686 thrown .expectMessage (
681687 startsWith ("Waypoint names exceed 500 character limit" ));
682688
683- StringBuffer longWpName = new StringBuffer ();
689+ StringBuilder longWpName = new StringBuilder ();
684690 for (int i = 0 ; i < 124 ; i ++) {
685691 longWpName .append ("Home" );
686692 }
0 commit comments