@@ -1685,13 +1685,14 @@ public void testLMConstraints() {
16851685assertFalse (response .hasErrors (),response .getErrors ().toString ());
16861686assertEquals (3587 ,response .getBest ().getDistance (),1 );
16871687
1688- //currently required to disable LM for p2too, see #1904 (default is LMfor *all* profiles once LM preparation isenabled for any profile)
1688+ // p2has no LMand so no lm.disable=true isrequired
16891689response =hopper .route (new GHRequest (43.727687 ,7.418737 ,43.74958 ,7.436566 ).
16901690setCustomModel (customModel ).
16911691setProfile ("p2" ));
1692- assertTrue (response .getErrors (). get ( 0 ). toString (). contains ( "Cannot find LM preparation for the requested profile: 'p2'" ),response .getErrors ().toString ());
1693- assertEquals (IllegalArgumentException . class ,response .getErrors ().get ( 0 ). getClass () );
1692+ assertFalse (response .hasErrors ( ),response .getErrors ().toString ());
1693+ assertEquals (3587 ,response .getBest ().getDistance (), 1 );
16941694
1695+ // but still works
16951696response =hopper .route (new GHRequest (43.727687 ,7.418737 ,43.74958 ,7.436566 ).
16961697setCustomModel (customModel ).
16971698setProfile ("p2" ).putHint ("lm.disable" ,true ));
@@ -1743,21 +1744,21 @@ public void testPreparedProfileNotAvailable() {
17431744GHRequest req =new GHRequest (43.727687 ,7.418737 ,43.74958 ,7.436566 ).
17441745setProfile (profile2 );
17451746
1746- //try with CH
1747+ //no CH or LM profile and so nothing can be ignored
17471748req .putHint (CH .DISABLE ,false );
17481749req .putHint (Landmark .DISABLE ,false );
17491750GHResponse res =hopper .route (req );
1750- assertTrue (res .hasErrors (),res .getErrors ().toString ());
1751- assertTrue ( res . getErrors (). get ( 0 ). getMessage (). contains ( "Cannot find CH preparation for the requested profile: 'short_fast_profile'" ) ,res .getErrors ().toString () );
1751+ assertFalse (res .hasErrors (),res .getErrors ().toString ());
1752+ assertEquals ( 3587 ,res .getBest ().getDistance (), 1 );
17521753
17531754// try with LM
17541755req .putHint (CH .DISABLE ,true );
17551756req .putHint (Landmark .DISABLE ,false );
17561757res =hopper .route (req );
1757- assertTrue (res .hasErrors (),res .getErrors ().toString ());
1758- assertTrue ( res . getErrors (). get ( 0 ). getMessage (). contains ( "Cannot find LM preparation for the requested profile: 'short_fast_profile'" ) ,res .getErrors ().toString () );
1758+ assertFalse (res .hasErrors (),res .getErrors ().toString ());
1759+ assertEquals ( 3587 ,res .getBest ().getDistance (), 1 );
17591760
1760- // falling back to non-prepared algo works
1761+ // falling back to non-prepared algo
17611762req .putHint (CH .DISABLE ,true );
17621763req .putHint (Landmark .DISABLE ,true );
17631764res =hopper .route (req );
@@ -1978,44 +1979,41 @@ public void testCHOnOffWithTurnCosts() {
19781979
19791980@ Test
19801981public void testNodeBasedCHOnlyButTurnCostForNonCH () {
1981- final String profile1 ="car_profile_tc" ;
1982- final String profile2 ="car_profile_notc" ;
1982+ final String profile_tc ="car_profile_tc" ;
1983+ final String profile_no_tc ="car_profile_notc" ;
19831984
19841985// before edge-based CH was added a common case was to use edge-based without CH and CH for node-based
19851986GraphHopper hopper =new GraphHopper ().
19861987setGraphHopperLocation (GH_LOCATION ).
19871988setOSMFile (MOSCOW ).
19881989setEncodedValuesString ("car_access, car_average_speed" ).
19891990setProfiles (List .of (
1990- TestProfiles .accessAndSpeed (profile1 ,"car" ).setTurnCostsConfig (TurnCostsConfig .car ()),
1991- TestProfiles .accessAndSpeed (profile2 ,"car" )
1991+ TestProfiles .accessAndSpeed (profile_tc ,"car" ).setTurnCostsConfig (TurnCostsConfig .car ()),
1992+ TestProfiles .accessAndSpeed (profile_no_tc ,"car" )
19921993 )).
19931994setStoreOnFlush (true );
19941995hopper .getCHPreparationHandler ()
19951996// we only do the CH preparation for the profile without turn costs
1996- .setCHProfiles (new CHProfile (profile2 ));
1997+ .setCHProfiles (new CHProfile (profile_no_tc ));
19971998hopper .importOrLoad ();
19981999
19992000GHRequest req =new GHRequest (55.813357 ,37.5958585 ,55.811042 ,37.594689 );
2000- // without CH, turn turn costs on andoff
2001+ // without CH andwith tc
20012002req .putHint (CH .DISABLE ,true );
2002- req .setProfile (profile1 );
2003+ req .setProfile (profile_tc );
20032004assertEquals (1044 ,hopper .route (req ).getBest ().getDistance (),1 );
2004- req .setProfile (profile2 );
2005+ // without CH and without tc
2006+ req .setProfile (profile_no_tc );
20052007assertEquals (400 ,hopper .route (req ).getBest ().getDistance (),1 );
20062008
2007- // with CH, turn turn costs on and off, since turn costs not supported for CH throw an error
2009+ // with CH and without tc => since turn costs not supported for CH throw an error
20082010req .putHint (CH .DISABLE ,false );
2009- req .setProfile (profile2 );
2011+ req .setProfile (profile_no_tc );
20102012assertEquals (400 ,hopper .route (req ).getBest ().getDistance (),1 );
2011- req .setProfile (profile1 );
2013+ // since there is no CH preparation for car_profile_tc the ch.disable parameter is ignored
2014+ req .setProfile (profile_tc );
20122015GHResponse rsp =hopper .route (req );
2013- assertEquals (1 ,rsp .getErrors ().size ());
2014- String expected ="Cannot find CH preparation for the requested profile: 'car_profile_tc'" +
2015- "\n You can try disabling CH using ch.disable=true" +
2016- "\n available CH profiles: [car_profile_notc]" ;
2017- assertTrue (rsp .getErrors ().toString ().contains (expected ),"unexpected error:\n " +rsp .getErrors ().toString () +"\n when expecting an error containing:\n " +expected
2018- );
2016+ assertEquals (1044 ,hopper .route (req ).getBest ().getDistance (),1 );
20192017 }
20202018
20212019@ Test