package Ġcom . tel en . easy line up . domain Ċ Ċ import Ġcom . tel en . easy line up . domain . model . Line up Ċ import Ġcom . tel en . easy line up . domain . model . Player Ċ import Ġcom . tel en . easy line up . domain . model . Player Number Overlay Ċ import Ġcom . tel en . easy line up . domain . model . Team Strategy Ċ import Ġcom . tel en . easy line up . domain . repository . Line up Repository Ċ import Ġcom . tel en . easy line up . domain . repository . Player Repository Ċ import Ġcom . tel en . easy line up . domain . use cases . Get R oster Ċ import Ġio . reactivex . Single Ċ import Ġio . reactivex . ob servers . Test Observer Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġorg . mockito . junit . Mockito JUnit Runner ĊĊ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ internal Ġclass ĠGet R oster Tests Ġ{ ĊĊĠĠĠ Ġ@ Mock Ġlateinit Ġvar Ġline up Dao : ĠLine up Repository ĊĠĠĠ Ġ@ Mock Ġlateinit Ġvar Ġplayer Dao : ĠPlayer Repository ĊĠĠĠ Ġlateinit Ġvar Ġm Get R oster : ĠGet R oster ĊĠĠĠ Ġprivate Ġval Ġextra H itter s Ġ= Ġ 0 ĊĊĠĠĠ Ġprivate Ġval Ġline up Ġ= ĠLine up ( 1 L , Ġ" A ", Ġ 1 L , Ġ 1 L , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 , ĠTeam Strategy . STANDARD . id , Ġextra H itter s , Ġ 3 L , 1 L , 1 L , Ġnull , Ġ" hash ") ĊĊĠĠĠ Ġprivate Ġval Ġplayer 1 Ġ= ĠPlayer ( 1 L , Ġ 1 L , Ġ" A ", Ġ 1 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 1 , Ġnull , Ġ 1 , Ġ 0 , Ġ 0 , Ġ" hash ") ĊĊĠĠĠ Ġprivate Ġval Ġplayer 2 Ġ= ĠPlayer ( 2 L , Ġ 1 L , Ġ" B ", Ġ 2 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 , Ġnull , Ġ 1 , Ġ 0 , Ġ 0 , Ġ" hash ") ĊĊĠĠĠ Ġprivate Ġval Ġplayer 3 Ġ= ĠPlayer ( 3 L , Ġ 1 L , Ġ" C ", Ġ 3 , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 3 , Ġnull , Ġ 1 , Ġ 0 , Ġ 0 , Ġ" hash ") ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠĠĠĠĠ Ġm Get R oster Ġ= ĠGet R oster ( player Dao , Ġline up Dao ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( line up Dao . getLine up ById Single ( 1 L )). thenReturn ( Single . just ( line up )) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( player Dao . get Players ( 1 L )). thenReturn ( Single . just ( listOf ( player 1 , Ġplayer 2 , Ġplayer 3 ))) ĊĊĠĠĠĠĠĠĠ Ġval Ġoverlay s Ġ= Ġmutable ListOf < Player Number Overlay >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd ( Player Number Overlay ( 1 L , Ġ 1 L , Ġplayer 1 . id , Ġ 4 2 )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd ( Player Number Overlay ( 3 L , Ġ 1 L , Ġplayer 3 . id , Ġ 6 9 )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( player Dao . get Players Number Overlay ( 1 L )). thenReturn ( Single . just ( overlay s )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return All Players If Line up Id IsNull () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Get R oster . Response Value >() ĊĠĠĠĠĠĠĠ Ġm Get R oster . execute UseCase ( Get R oster . Request Values ( 1 L , Ġnull )). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . await () ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 3 , Ġobserver . values (). first (). summary . players . filter Ġ{ Ġit . status Ġ}. size ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( Constants . STATUS _ ALL , Ġobserver . values (). first (). summary . status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return All Players If Line up R oster IsNull () Ġ{ ĊĠĠĠĠĠĠĠ Ġline up . ro ster Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Get R oster . Response Value >() ĊĠĠĠĠĠĠĠ Ġm Get R oster . execute UseCase ( Get R oster . Request Values ( 1 L , Ġ 1 L )). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . await () ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 3 , Ġobserver . values (). first (). summary . players . filter Ġ{ Ġit . status Ġ}. size ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( Constants . STATUS _ ALL , Ġobserver . values (). first (). summary . status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return No Players If Line up R oster IsEmpty () Ġ{ ĊĠĠĠĠĠĠĠ Ġline up . ro ster Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Get R oster . Response Value >() ĊĠĠĠĠĠĠĠ Ġm Get R oster . execute UseCase ( Get R oster . Request Values ( 1 L , Ġ 1 L )). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . await () ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 0 , Ġobserver . values (). first (). summary . players . filter Ġ{ Ġit . status Ġ}. size ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( Constants . STATUS _ PAR TIAL , Ġobserver . values (). first (). summary . status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return All Players If Line up R oster Is Full () Ġ{ ĊĠĠĠĠĠĠĠ Ġline up . ro ster Ġ= Ġ" 1 ; 2 ; 3 " ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Get R oster . Response Value >() ĊĠĠĠĠĠĠĠ Ġm Get R oster . execute UseCase ( Get R oster . Request Values ( 1 L , Ġ 1 L )). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . await () ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 3 , Ġobserver . values (). first (). summary . players . filter Ġ{ Ġit . status Ġ}. size ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( Constants . STATUS _ ALL , Ġobserver . values (). first (). summary . status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return 2 Players In R oster Selection () Ġ{ ĊĠĠĠĠĠĠĠ Ġline up . ro ster Ġ= Ġ" 1 ; 3 " ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Get R oster . Response Value >() ĊĠĠĠĠĠĠĠ Ġm Get R oster . execute UseCase ( Get R oster . Request Values ( 1 L , Ġ 1 L )). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . await () ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 2 , Ġobserver . values (). first (). summary . players . filter Ġ{ Ġit . status Ġ}. size ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( false , Ġobserver . values (). first (). summary . players . filter Ġ{ Ġit . player . id Ġ== Ġ 2 L Ġ}. first (). status ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( Constants . STATUS _ PAR TIAL , Ġobserver . values (). first (). summary . status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return Overlay s Number () Ġ{ ĊĠĠĠĠĠĠĠ Ġline up . ro ster Ġ= Ġ" 1 ; 2 ; 3 " ĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Get R oster . Response Value >() ĊĠĠĠĠĠĠĠ Ġm Get R oster . execute UseCase ( Get R oster . Request Values ( 1 L , Ġ 1 L )). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . await () ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 4 2 , Ġobserver . values (). first (). summary . players [ 0 ]. player Number Overlay ?. number ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( null , Ġobserver . values (). first (). summary . players [ 1 ]. player Number Overlay ?. number ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 6 9 , Ġobserver . values (). first (). summary . players [ 2 ]. player Number Overlay ?. number ) ĊĠĠĠ Ġ} Ċ }