package Ġbet man . controller Ċ Ċ import Ġbet man . db . Cache Repository Ċ import Ġbet man . po jos . Group Ċ import Ġio . reactivex . Single Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġjava . util . concurrent . atomic . Atomic Integer Ċ Ċ class ĠCache Repository Test Ġ{ ĊĠĠĠ Ġprivate Ġvar Ġcounter Ġ= ĠAtomicInteger ( 0 ) ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcache : ĠCache Repository . Cache < String , ĠGroup > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrepo : ĠCache Repository ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġbefore () Ġ{ ĊĠĠĠĠĠĠĠ Ġrepo Ġ= ĠCache Repository () ĊĠĠĠĠĠĠĠ Ġcache Ġ= Ġrepo . get OrCreate (" my Id Cache ") Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcounter . increment AndGet () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSingle . just ( Group ( name Ġ= Ġit , Ġgame Ġ= Ġ" some ")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġcounter . get ()) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ Ġrepo . invalidate All () ĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġcounter . get ()) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ Ġrepo . invalidate All (" my Id Cache ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġcounter . get ()) ĊĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ Ġrepo . invalidate (" my Id Cache ", Ġ" name ") ĊĠĠĠĠĠĠĠ ĠassertEquals (" some ", Ġcache . get (" name "). blocking Get (). game ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 4 , Ġcounter . get ()) ĊĊĠĠĠ Ġ} Ċ }