@@ -3715,11 +3715,11 @@ public void testUserRoadSpeed() {
3715
3715
JSONObject body = new JSONObject ();
3716
3716
JSONArray coords = new JSONArray ();
3717
3717
JSONArray neuenheim = new JSONArray ();
3718
- neuenheim .put (8.684435 );
3719
- neuenheim .put (49.417367 );
3718
+ neuenheim .put (8.685036 );
3719
+ neuenheim .put (49.4201314 );
3720
3720
JSONArray dossenheim = new JSONArray ();
3721
- dossenheim .put (8.664275 );
3722
- dossenheim .put (49.453557 );
3721
+ dossenheim .put (8.668814 );
3722
+ dossenheim .put (49.442794 );
3723
3723
coords .put (neuenheim );
3724
3724
coords .put (dossenheim );
3725
3725
body .put ("coordinates" , coords );
@@ -3739,8 +3739,8 @@ public void testUserRoadSpeed() {
3739
3739
.then ().log ().ifValidationFails ()
3740
3740
.assertThat ()
3741
3741
.body ("any { it.key == 'routes' }" , is (true ))
3742
- .body ("routes[0].summary.distance" , is (5492.7f ))
3743
- .body ("routes[0].summary.duration" , is (5492.7f ))
3742
+ .body ("routes[0].summary.distance" , is (4507.5f ))
3743
+ .body ("routes[0].summary.duration" , is (469.1f ))
3744
3744
.statusCode (200 );
3745
3745
3746
3746
JSONObject userSpeedLimits = new JSONObject ();
@@ -3761,19 +3761,104 @@ public void testUserRoadSpeed() {
3761
3761
.then ().log ().ifValidationFails ()
3762
3762
.assertThat ()
3763
3763
.body ("any { it.key == 'routes' }" , is (true ))
3764
- .body ("routes[0].summary.distance" , is (6010.3f ))
3765
- .body ("routes[0].summary.duration" , is (6010 .3f ))
3764
+ .body ("routes[0].summary.distance" , is (3811.0f ))
3765
+ .body ("routes[0].summary.duration" , is (554 .3f ))
3766
3766
.statusCode (200 );
3767
3767
}
3768
3768
3769
3769
@ Test
3770
3770
public void testUserSurfaceSpeed () {
3771
+ JSONObject body = new JSONObject ();
3772
+ JSONArray coords = new JSONArray ();
3773
+ JSONArray neuenheim = new JSONArray ();
3774
+ neuenheim .put (8.685036 );
3775
+ neuenheim .put (49.4201314 );
3776
+ JSONArray dossenheim = new JSONArray ();
3777
+ dossenheim .put (8.668814 );
3778
+ dossenheim .put (49.442794 );
3779
+ coords .put (neuenheim );
3780
+ coords .put (dossenheim );
3781
+ body .put ("coordinates" , coords );
3782
+
3783
+ // since we're testing on the same profile, "shortest" would not be dependent on speed settings
3784
+ // and "recommended" will make too many assumptions on what route could be preferred.
3785
+ body .put ("preference" , "fastest" );
3786
+
3787
+ // request route without specifying user Speed
3788
+ given ()
3789
+ .header ("Accept" , "application/json" )
3790
+ .header ("Content-Type" , "application/json" )
3791
+ .pathParam ("profile" , getParameter ("carProfile" ))
3792
+ .body (body .toString ())
3793
+ .when ().log ().ifValidationFails ()
3794
+ .post (getEndPointPath () + "/{profile}" )
3795
+ .then ().log ().ifValidationFails ()
3796
+ .assertThat ()
3797
+ .body ("any { it.key == 'routes' }" , is (true ))
3798
+ .body ("routes[0].summary.distance" , is (4507.5f ))
3799
+ .body ("routes[0].summary.duration" , is (469.1f ))
3800
+ .statusCode (200 );
3801
+
3802
+ JSONObject userSpeedLimits = new JSONObject ();
3803
+ JSONObject roadSpeedLimits = new JSONObject ();
3804
+ roadSpeedLimits .put ("primary" , 30 );
3805
+ roadSpeedLimits .put ("secondary" , 30 );
3806
+ userSpeedLimits .put ("roadSpeeds" , roadSpeedLimits );
3807
+ body .put ("user_speed_limits" , userSpeedLimits );
3808
+
3809
+ // request route limiting speed on primary and secondary roads to 30
3810
+ given ()
3811
+ .header ("Accept" , "application/json" )
3812
+ .header ("Content-Type" , "application/json" )
3813
+ .pathParam ("profile" , getParameter ("carProfile" ))
3814
+ .body (body .toString ())
3815
+ .when ().log ().ifValidationFails ()
3816
+ .post (getEndPointPath () + "/{profile}" )
3817
+ .then ().log ().ifValidationFails ()
3818
+ .assertThat ()
3819
+ .body ("any { it.key == 'routes' }" , is (true ))
3820
+ .body ("routes[0].summary.distance" , is (3811.0f ))
3821
+ .body ("routes[0].summary.duration" , is (554.3f ))
3822
+ .statusCode (200 );
3771
3823
3772
3824
}
3773
3825
3774
3826
@ Test
3775
3827
public void testUserSpeedUnit () {
3828
+ JSONObject body = new JSONObject ();
3829
+ JSONArray coords = new JSONArray ();
3830
+ JSONArray neuenheim = new JSONArray ();
3831
+ neuenheim .put (8.685036 );
3832
+ neuenheim .put (49.4201314 );
3833
+ JSONArray dossenheim = new JSONArray ();
3834
+ dossenheim .put (8.668814 );
3835
+ dossenheim .put (49.442794 );
3836
+ coords .put (neuenheim );
3837
+ coords .put (dossenheim );
3838
+ body .put ("coordinates" , coords );
3776
3839
3840
+ // this is the same query as testUserRoadSpeed uses, but has speeds in mph
3841
+ JSONObject userSpeedLimits = new JSONObject ();
3842
+ JSONObject roadSpeedLimits = new JSONObject ();
3843
+ roadSpeedLimits .put ("primary" , 18.6412f );
3844
+ roadSpeedLimits .put ("secondary" , 18.6412f );
3845
+ userSpeedLimits .put ("roadSpeeds" , roadSpeedLimits );
3846
+ userSpeedLimits .put ("unit" , "mph" );
3847
+ body .put ("user_speed_limits" , userSpeedLimits );
3848
+
3849
+ given ()
3850
+ .header ("Accept" , "application/json" )
3851
+ .header ("Content-Type" , "application/json" )
3852
+ .pathParam ("profile" , getParameter ("carProfile" ))
3853
+ .body (body .toString ())
3854
+ .when ().log ().ifValidationFails ()
3855
+ .post (getEndPointPath () + "/{profile}" )
3856
+ .then ().log ().ifValidationFails ()
3857
+ .assertThat ()
3858
+ .body ("any { it.key == 'routes' }" , is (true ))
3859
+ .body ("routes[0].summary.distance" , is (3811.0f ))
3860
+ .body ("routes[0].summary.duration" , is (554.3f ))
3861
+ .statusCode (200 );
3777
3862
}
3778
3863
3779
3864
private JSONArray constructBearings (String coordString ) {
0 commit comments