import Ġkh op .* Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġsimple travel . methods . Travel Ċ import Ġsimple travel . model .* Ċ import Ġsimple travel . operators .* Ċ import Ġjava . util .* Ċ Ċ class ĠSimple Travel Example Tests Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġl ondon Ġ= ĠLocation (" L ondon ", Ġ 5 1 . 5 0 7 3 5 1 , Ġ- 0 . 1 2 7 7 5 8 ) ĊĠĠĠ Ġprivate Ġval Ġman che ster Ġ= ĠLocation (" Man che ster ", Ġ 5 3 . 4 8 0 7 5 9 , Ġ- 2 . 2 4 2 6 3 1 ) ĊĠĠĠ Ġprivate Ġval Ġed in bur gh Ġ= ĠLocation (" Ed in bur gh ", Ġ 5 5 . 9 5 3 2 5 2 , Ġ- 3 . 1 8 8 2 6 7 ) ĊĠĠĠ Ġprivate Ġval Ġlocations Ġ= Ġarray ListOf ( l ondon , Ġman che ster , Ġed in bur gh ) ĊĠĠĠ Ġprivate Ġval Ġtax i Driver Ġ= ĠSimple Person ( man che ster ) ĊĊĠĠĠ Ġfun Ġget Travel By Foot Test Planner (): ĠK H OP < Simple Travel State > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġax el Ġ= ĠPerson ( l ondon , Ġ 0 . 0 , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġval ĠinitialState Ġ= ĠSimple Travel State ( ax el , Ġtax i Driver , Ġlocations ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Network Ġ= ĠArray Deque < Network Element < Simple Travel State >>( listOf ( Travel ( l ondon , Ġman che ster ))) ĊĠĠĠĠĠĠĠ Ġval Ġpl anner Ġ= ĠK H OP ( Domain ( initialState , Ġinitial Network ), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġreturn Ġpl anner ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtravel By Foot Operator Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġplan Ġ= Ġget Travel By Foot Test Planner (). find Plan () ĊĠĠĠĠĠĠĠ Ġval Ġexpected Actions Ġ= Ġmutable ListOf ( Walk ( l ondon , Ġman che ster ) Ġas ĠOperator < Simple Travel State >) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Plan Ġ= ĠPlan Obj ( actions Ġ= Ġexpected Actions ) ĊĠĠĠĠĠĠĠ Ġassert Plan Action Status Equals ( expected Plan , Ġplan ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Travel By Tax i Test Planner (): ĠK H OP < Simple Travel State > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġax el Ġ= ĠPerson ( l ondon , Ġ 5 3 4 . 0 Ġ* Ġ 1 0 0 0 , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġval ĠinitialState Ġ= ĠSimple Travel State ( ax el , Ġtax i Driver , Ġlocations ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Network Ġ= ĠArray Deque < Network Element < Simple Travel State >>( listOf ( Travel ( l ondon , Ġed in bur gh ))) ĊĠĠĠĠĠĠĠ Ġval Ġpl anner Ġ= ĠK H OP ( Domain ( initialState , Ġinitial Network ), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġreturn Ġpl anner ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtravel By Tax i Method Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġplan Ġ= Ġget Travel By Tax i Test Planner (). find Plan () ĊĠĠĠĠĠĠĠ Ġassert Plan Action Status Equals ( Plan Obj ( actions Ġ= Ġmutable ListOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCall Tax i ( l ondon ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR ide Tax i ( l ondon , Ġed in bur gh ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠPay Driver ())), Ġplan ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return Two Plans () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġax el Ġ= ĠPerson ( l ondon , Ġ 5 3 4 . 0 Ġ* Ġ 1 0 0 0 0 , Ġ 0 . 0 ) ĊĠĠĠĠĠĠĠ Ġval ĠinitialState Ġ= ĠSimple Travel State ( ax el , Ġtax i Driver , Ġlocations ) ĊĠĠĠĠĠĠĠ Ġval Ġinitial Network Ġ= ĠArray Deque < Network Element < Simple Travel State >>( listOf ( Travel ( l ondon , Ġman che ster ))) ĊĠĠĠĠĠĠĠ Ġval Ġpl anner Ġ= ĠK H OP ( Domain ( initialState , Ġinitial Network ), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġplans Ġ= Ġpl anner . getAll Plans () ĊĠĠĠĠĠĠĠ Ġval Ġexpected Plan 1 Ġ= ĠPlan Obj ( actions Ġ= Ġmutable ListOf ( Walk ( l ondon , Ġman che ster ))) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Plan 2 Ġ= ĠPlan Obj ( actions Ġ= Ġmutable ListOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCall Tax i ( l ondon ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR ide Tax i ( l ondon , Ġman che ster ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠPay Driver ())) ĊĠĠĠĠĠĠĠ Ġvar Ġpasses Test Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġfor Ġ( plan Ġin Ġplans ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpasses Test Ġ= Ġplan . custom Equals ( expected Plan 1 ) Ġ|| Ġplan . custom Equals ( expected Plan 2 ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( passes Test ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġplans . size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġplan Should Return Same State As Plan Execution () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpl anners Ġ= ĠlistOf ( get Travel By Foot Test Planner (), Ġget Travel By Tax i Test Planner ()) ĊĠĠĠĠĠĠĠ Ġfor Ġ( planner Ġin Ġpl anners ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġplan Ġ= Ġpl anner . find Plan () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( plan . state , Ġpl anner . execute Plan ( plan )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }