package Ġcom . the d ancer codes . android . cre atures . data . source Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . any Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġcom . the d ancer codes . android . cre atures . data . model . Creature Entity Ċ import Ġcom . the d ancer codes . android . cre atures . data . repository . Creature Cache Ċ import Ġcom . the d ancer codes . android . cre atures . data . test . factory . Creature Entity Factory Ċ import Ġio . reactivex . Comp letable Ċ import Ġio . reactivex . Flow able Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 ĊĊ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠCre ature Cache DataStore Test Ġ{ ĊĊĠ Ġprivate Ġlateinit Ġvar Ġcreature Cache DataStore : ĠCre ature Cache DataStore ĊĠ Ġprivate Ġlateinit Ġvar Ġcreature Cache : ĠCre ature Cache ĊĊĠ Ġ@ Before ĊĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠ Ġcreature Cache Ġ= Ġmock () ĊĠĠĠ Ġcreature Cache DataStore Ġ= ĠCre ature Cache DataStore ( creature Cache ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġclear Cre atures Comp letes () Ġ{ ĊĠĠĠ Ġstub Creature Cache Clear Cre atures ( Comp letable . complete ()) ĊĠĠĠ Ġval Ġtest Observer Ġ= Ġcreature Cache DataStore . clear Cre atures (). test () ĊĠĠĠ Ġtest Observer . assert Complete () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsave Cre atures Comp letes () Ġ{ ĊĠĠĠ Ġstub Creature Cache Save Cre atures ( Comp letable . complete ()) ĊĠĠĠ Ġval Ġtest Observer Ġ= Ġcreature Cache DataStore . save Cre atures ( ĊĠĠĠĠĠĠĠ ĠCre ature Entity Factory . make Creature Entity List ( 2 )). test () ĊĠĠĠ Ġtest Observer . assert Complete () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget Cre atures Comp letes () Ġ{ ĊĠĠĠ Ġstub Creature Cache Get Cre atures ( Flow able . just ( Creature Entity Factory . make Creature Entity List ( 2 ))) ĊĠĠĠ Ġval Ġtest Observer Ġ= Ġcreature Cache DataStore . get Cre atures (). test () ĊĠĠĠ Ġtest Observer . assert Complete () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġstub Creature Cache Save Cre atures ( comp letable : ĠComp letable ) Ġ{ ĊĠĠĠ Ġwhenever ( creature Cache . save Cre atures ( any ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( comp letable ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġstub Creature Cache Get Cre atures ( single : ĠFlow able < List < Creature Entity >>) Ġ{ ĊĠĠĠ Ġwhenever ( creature Cache . get Cre atures ()) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( single ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġstub Creature Cache Clear Cre atures ( comp letable : ĠComp letable ) Ġ{ ĊĠĠĠ Ġwhenever ( creature Cache . clear Cre atures ()) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( comp letable ) ĊĠ Ġ} Ċ }