package Ġcom . k ans us . team maker . data Ċ Ċ import Ġcom . k ans us . team maker . TestData Ċ import Ġandroid . database . sqlite . SQLite Constraint Exception Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . room . Room Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġcom . k ans us . team maker . android . data . App Database Ċ import Ġcom . k ans us . team maker . android . data . dao . Fixture Dao Ċ import Ġcom . k ans us . team maker . android . data . dao . Game Dao Ċ import Ġcom . k ans us . team maker . android . data . dao . Player Dao Ċ import Ġcom . k ans us . team maker . android . data . dao . Team Dao Ċ import Ġcom . k ans us . team maker . android . data . entity . Game Player Entity Ċ import Ġcom . k ans us . team maker . android . data . entity . Team Entity Ċ import Ġcom . k ans us . team maker . android . data . entity . Team Player Entity Ċ import Ġcom . k ans us . team maker . TestData . FIX TURE _ ENTITY _ 1 Ċ import Ġcom . k ans us . team maker . TestData . FIX TURE _ ENTITY _ 2 Ċ import Ġcom . k ans us . team maker . TestData . GAME _ ENTITY _ 1 Ċ import Ġcom . k ans us . team maker . TestData . GAME _ ENTITY _ 2 Ċ import Ġcom . k ans us . team maker . TestData . PLAYER _ ENTITY _ 1 Ċ import Ġcom . k ans us . team maker . TestData . PLAYER _ ENTITY _ 2 Ċ import Ġcom . k ans us . team maker . TestData . TEAM _ ENTITY _ 1 Ċ import Ġcom . k ans us . team maker . TestData . TEAM _ ENTITY _ 2 Ċ import Ġorg . hamcrest . Matchers .* Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert . assertThat Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġjava . util .* Ċ Ċ /** Ċ Ġ* ĠTest Ġthe Ġimplementation Ġof Ġ[ Team Dao ] Ċ Ġ*/ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠTeam Dao Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Database : ĠApp Database ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Game Dao : ĠGame Dao ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Player Dao : ĠPlayer Dao ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Team Dao : ĠTeam Dao ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Fixture Dao : ĠFix ture Dao ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit Db () Ġ{ ĊĠĠĠĠĠĠĠ Ġm Database Ġ= ĠRoom . in Memory Database Builder ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstrument ation Registry . get Instrumentation (). target Context , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠApp Database :: class . java ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. allow MainThread Queries () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ Ġm Game Dao Ġ= Ġm Database . game Dao () ĊĠĠĠĠĠĠĠ Ġm Player Dao Ġ= Ġm Database . player Dao () ĊĠĠĠĠĠĠĠ Ġm Team Dao Ġ= Ġm Database . team Dao () ĊĠĠĠĠĠĠĠ Ġm Fixture Dao Ġ= Ġm Database . fixture Dao () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġclose Db () Ġ{ ĊĠĠĠĠĠĠĠ Ġm Database . close () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( InterruptedException :: class ) ĊĠĠĠ Ġfun Ġget Teams When Empty () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġteams Ġ= Ġm Team Dao . getAll () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( teams , Ġempty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( InterruptedException :: class ) ĊĠĠĠ Ġfun Ġget Teams After Inserted () Ġ{ ĊĠĠĠĠĠĠĠ Ġinsert TestData () ĊĊĠĠĠĠĠĠĠ Ġval Ġteams Ġ= Ġm Team Dao . getAll () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( teams , Ġhas Size ( 2 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( InterruptedException :: class ) ĊĠĠĠ Ġfun Ġget Team ById () Ġ{ ĊĠĠĠĠĠĠĠ Ġinsert TestData () ĊĊĠĠĠĠĠĠĠ Ġval Ġteam Ġ= Ġm Team Dao . get ( 2 ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( team , ĠequalTo ( TEAM _ ENTITY _ 2 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( InterruptedException :: class ) ĊĠĠĠ Ġfun Ġget Team Players () Ġ{ ĊĠĠĠĠĠĠĠ Ġinsert TestData () ĊĊĠĠĠĠĠĠĠ Ġval Ġteam 1 Players Ġ= Ġm Player Dao . get Team Players ( 1 ) ĊĠĠĠĠĠĠĠ Ġval Ġteam 2 Players Ġ= Ġm Player Dao . get Team Players ( 2 ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( team 1 Players , Ġhas Size ( 2 )) ĊĠĠĠĠĠĠĠ ĠassertThat ( team 2 Players , Ġempty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠSQLite Constraint Exception :: class ) ĊĠĠĠ Ġ@ Throws ( InterruptedException :: class ) ĊĠĠĠ Ġfun Ġinsert Without Fixture Throws () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġteam To Insert Ġ= ĠTeam Entity ( 3 , ĠDate (), Ġ 0 ) ĊĊĠĠĠĠĠĠĠ Ġm Team Dao . insert ( team To Insert ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( InterruptedException :: class ) ĊĠĠĠ Ġfun Ġinsert Existing Team Updates Current () Ġ{ ĊĠĠĠĠĠĠĠ Ġinsert TestData () ĊĠĠĠĠĠĠĠ Ġval Ġteam Update Ġ= ĠTeam Entity ( 1 , ĠDate (), ĠFIX TURE _ ENTITY _ 1 . id ) ĊĊĠĠĠĠĠĠĠ Ġm Team Dao . insert ( team Update ) ĊĊĠĠĠĠĠĠĠ Ġval Ġteam Ġ= Ġm Team Dao . get ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( team , ĠequalTo ( team Update )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( InterruptedException :: class ) ĊĠĠĠ Ġfun Ġdelete Team () Ġ{ ĊĠĠĠĠĠĠĠ Ġinsert TestData () ĊĊĠĠĠĠĠĠĠ Ġm Team Dao . delete ( TEAM _ ENTITY _ 1 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġteam Ġ= Ġm Team Dao . get ( 1 ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( team , Ġnull Value ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinsert TestData () Ġ{ ĊĠĠĠĠĠĠĠ Ġm Game Dao . insert ( GAME _ ENTITY _ 1 ) ĊĠĠĠĠĠĠĠ Ġm Game Dao . insert ( GAME _ ENTITY _ 2 ) ĊĊĠĠĠĠĠĠĠ Ġm Player Dao . insert ( PLAYER _ ENTITY _ 1 ) ĊĠĠĠĠĠĠĠ Ġm Player Dao . insert ( PLAYER _ ENTITY _ 2 ) ĊĊĠĠĠĠĠĠĠ Ġm Game Dao . insert Game Player ( Game Player Entity ( 1 , ĠGAME _ ENTITY _ 1 . id , ĠTest Data . PLAYER _ ENTITY _ 1 . id )) ĊĠĠĠĠĠĠĠ Ġm Game Dao . insert Game Player ( Game Player Entity ( 2 , ĠGAME _ ENTITY _ 1 . id , ĠTest Data . PLAYER _ ENTITY _ 2 . id )) ĊĊĠĠĠĠĠĠĠ Ġm Fixture Dao . insert ( FIX TURE _ ENTITY _ 1 ) ĊĠĠĠĠĠĠĠ Ġm Fixture Dao . insert ( FIX TURE _ ENTITY _ 2 ) ĊĊĠĠĠĠĠĠĠ Ġm Team Dao . insert ( TEAM _ ENTITY _ 1 ) ĊĠĠĠĠĠĠĠ Ġm Team Dao . insert ( TEAM _ ENTITY _ 2 ) ĊĊĠĠĠĠĠĠĠ Ġm Team Dao . insert ( Team Player Entity ( 1 , ĠTE AM _ ENTITY _ 1 . id , ĠP LAYER _ ENTITY _ 1 . id )) ĊĠĠĠĠĠĠĠ Ġm Team Dao . insert ( Team Player Entity ( 2 , ĠTE AM _ ENTITY _ 1 . id , ĠP LAYER _ ENTITY _ 2 . id )) ĊĠĠĠ Ġ} Ċ } Ċ