package Ġnet . dub lin . bus . data . rout est op Ċ Ċ import Ġandroid . arch . persistence . room . Room Ċ import Ġorg . hamcrest . Core Matchers .` is ` Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ Ċ import Ġandroid . support . test . Instrumentation Registry Ċ import Ġandroid . support . test . runner . Android JUnit 4 Ċ import Ġnet . dub lin . bus . data . Bus Database Ċ import Ġnet . dub lin . bus . model . Route Ċ import Ġnet . dub lin . bus . model . Route Stop Ċ import Ġnet . dub lin . bus . model . Stop Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠRoute Stop Dao Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdatabase : ĠBus Database ĊĊĠĠĠ Ġprivate Ġval Ġroute 1 Ġ= ĠRoute ( number Ġ= Ġ" 1 ", Ġdescription Ġ= Ġ" 1 ") ĊĠĠĠ Ġprivate Ġval Ġroute 2 Ġ= ĠRoute ( number Ġ= Ġ" 2 ", Ġdescription Ġ= Ġ" 2 ") ĊĠĠĠ Ġprivate Ġval Ġroute 3 Ġ= ĠRoute ( number Ġ= Ġ" 3 ", Ġdescription Ġ= Ġ" 3 ") ĊĠĠĠ Ġprivate Ġval Ġroute 4 Ġ= ĠRoute ( number Ġ= Ġ" 4 ", Ġdescription Ġ= Ġ" 4 ") ĊĠĠĠ Ġprivate Ġval Ġroutes Ġ= ĠlistOf ( route 1 , Ġroute 2 , Ġroute 3 , Ġroute 4 ) ĊĊĠĠĠ Ġprivate Ġval Ġstop 1 Ġ= ĠStop ( stop Number Ġ= Ġ" 1 ", Ġdescription Ġ= Ġ" 1 ") ĊĠĠĠ Ġprivate Ġval Ġstop 2 Ġ= ĠStop ( stop Number Ġ= Ġ" 2 ", Ġdescription Ġ= Ġ" 2 ") ĊĠĠĠ Ġprivate Ġval Ġstop 3 Ġ= ĠStop ( stop Number Ġ= Ġ" 3 ", Ġdescription Ġ= Ġ" 3 ") ĊĠĠĠ Ġprivate Ġval Ġstop 4 Ġ= ĠStop ( stop Number Ġ= Ġ" 4 ", Ġdescription Ġ= Ġ" 4 ") ĊĠĠĠ Ġprivate Ġval Ġstops Ġ= ĠlistOf ( stop 1 , Ġstop 2 , Ġstop 3 , Ġstop 4 ) ĊĊĠĠĠ Ġprivate Ġval Ġroute Stop 1 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 1 ", Ġnumber Stop Ġ= Ġ" 1 ") ĊĠĠĠ Ġprivate Ġval Ġroute Stop 2 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 1 ", Ġnumber Stop Ġ= Ġ" 2 ") ĊĠĠĠ Ġprivate Ġval Ġroute Stop 3 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 1 ", Ġnumber Stop Ġ= Ġ" 3 ") ĊĠĠĠ Ġprivate Ġval Ġroute Stop 4 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 2 ", Ġnumber Stop Ġ= Ġ" 1 ") ĊĠĠĠ Ġprivate Ġval Ġroute Stop 5 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 2 ", Ġnumber Stop Ġ= Ġ" 3 ") ĊĠĠĠ Ġprivate Ġval Ġroute Stop 6 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 2 ", Ġnumber Stop Ġ= Ġ" 4 ") ĊĠĠĠ Ġprivate Ġval Ġroute Stop 7 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 3 ", Ġnumber Stop Ġ= Ġ" 4 ") ĊĠĠĠ Ġprivate Ġval Ġroute Stop 8 Ġ= ĠRoute Stop ( number Route Ġ= Ġ" 4 ", Ġnumber Stop Ġ= Ġ" 3 ") ĊĊĠĠĠ Ġprivate Ġval Ġroute Stops Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 2 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 4 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 5 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 6 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 7 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġroute Stop 8 ĊĠĠĠ Ġ) ĊĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit Db () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase Ġ= ĠRoom . in Memory Database Builder ( Instrumentation Registry . getContext (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBus Database :: class . java ). build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġclose Db () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase . close () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinsert Route Stops AndGet By Route Number () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase . get Route Dao (). save All Routes ( routes ) ĊĠĠĠĠĠĠĠ Ġdatabase . get Stop Dao (). save All Stops ( stops ) ĊĠĠĠĠĠĠĠ Ġdatabase . get Route Stop Dao (). save All Route Stops ( route Stops ) ĊĊĠĠĠĠĠĠĠ Ġvar Ġloaded Ġ= Ġdatabase . get Route Stop Dao (). get Stops For Routes ( array Of ( route 1 . number )) ĊĠĠĠĠĠĠĠ ĠassertThat < Int >( loaded . size , Ġ` is `( 3 )) ĊĊĠĠĠĠĠĠĠ Ġloaded Ġ= Ġdatabase . get Route Stop Dao (). get Stops For Routes ( array Of ( route 1 . number , Ġroute 4 . number )) ĊĠĠĠĠĠĠĠ ĠassertThat < Int >( loaded . size , Ġ` is `( 4 )) ĊĊĠĠĠĠĠĠĠ ĠassertThat < Boolean >( loaded [ 0 ] Ġ== Ġstop 1 , Ġ` is `< Boolean >( true )) ĊĠĠĠĠĠĠĠ ĠassertThat < Boolean >( loaded [ 3 ] Ġ== Ġstop 3 , Ġ` is `< Boolean >( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinsert Route Stops AndGet By Stop Number () Ġ{ ĊĠĠĠĠĠĠĠ Ġdatabase . get Route Dao (). save All Routes ( routes ) ĊĠĠĠĠĠĠĠ Ġdatabase . get Stop Dao (). save All Stops ( stops ) ĊĠĠĠĠĠĠĠ Ġdatabase . get Route Stop Dao (). save All Route Stops ( route Stops ) ĊĊĠĠĠĠĠĠĠ Ġval Ġloaded Ġ= Ġdatabase . get Route Stop Dao (). get Routes For Stop ( stop 1 . stop Number ) ĊĠĠĠĠĠĠĠ ĠassertThat < Int >( loaded . size , Ġ` is `( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat < Boolean >( loaded [ 0 ] Ġ== Ġroute 1 , Ġ` is `< Boolean >( true )) ĊĠĠĠĠĠĠĠ ĠassertThat < Boolean >( loaded [ 1 ] Ġ== Ġroute 2 , Ġ` is `< Boolean >( true )) ĊĠĠĠ Ġ} Ċ }