package Ġcom . rod rig ob res an . data . review . source Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġcom . rod rig ob res an . data . connection . Connection Status Ċ import Ġcom . rod rig ob res an . data . movie . sources . data _ store . Review DataStore Factory Ċ import Ġcom . rod rig ob res an . data . review . sources . data _ store . local . Review Cache Ċ import Ġcom . rod rig ob res an . data . review . sources . data _ store . local . Review Cache DataStore Ċ import Ġcom . rod rig ob res an . data . review . sources . data _ store . local . Review Remote DataStore Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠReview DataStore Factory Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġreview DataStore Factory : ĠReview DataStore Factory ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġreview Cache : ĠReview Cache ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġreview Cache DataStore : ĠReview Cache DataStore ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġreview Remote DataStore : ĠReview Remote DataStore ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġconnection Status : ĠConnection Status ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġreview Cache Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġreview Cache DataStore Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġreview Remote DataStore Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġconnection Status Ġ= Ġmock () ĊĊĠĠĠĠĠĠĠ Ġreview DataStore Factory Ġ= ĠReview DataStore Factory ( connection Status , Ġreview Remote DataStore , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreview Cache DataStore ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġretrieve DataStore When No Connection Returns Cached DataStore () Ġ{ ĊĠĠĠĠĠĠĠ Ġstub Is Offline ( true ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdata Store Ġ= Ġreview DataStore Factory . retrieve DataStore () ĊĠĠĠĠĠĠĠ Ġassert ( data Store Ġis ĠReview Cache DataStore ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġretrieve Remote DataStore Returns Remote DataStore () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠReview DataStore Ġ= Ġreview DataStore Factory . retrieve Remote DataStore () ĊĠĠĠĠĠĠĠ Ġassert ( Review DataStore Ġis ĠReview Remote DataStore ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġretrieve Cached DataStore Returns Cached DataStore () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠReview DataStore Ġ= Ġreview DataStore Factory . retrieve Cached DataStore () ĊĠĠĠĠĠĠĠ Ġassert ( Review DataStore Ġis ĠReview Cache DataStore ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġstub Is Offline ( is Offline : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( connection Status . is Offline ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( is Offline ) ĊĠĠĠ Ġ} Ċ Ċ }