package Ġcom . j pp . mp data . cache Ċ Ċ import Ġcom . j pp . mp data . cache . adapter . Domain Room Adapter Ċ import Ġcom . j pp . mp data . cache . adapter . Room Domain Adapter Ċ import Ġcom . j pp . mp data . cache . room . Credits Dao Ċ import Ġcom . j pp . mp data . cache . room . DB Cast Character Ċ import Ġcom . j pp . mp data . cache . room . DB Cre w Person Ċ import Ġcom . j pp . mp data . cache . room . MP Room Data Base Ċ import Ġcom . j pp . mp domain . Credits Ċ import Ġio . mock k . every Ċ import Ġio . mock k . impl . annotations . Rel ax ed Mock K Ċ import Ġio . mock k . junit 5 . Mock K Extension Ċ import Ġio . mock k . mock k Ċ import Ġorg . junit . jupiter . api . Assertions . assertEquals Ċ import Ġorg . junit . jupiter . api . Assertions . assertNull Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ Ċ @ Extend With ( Mock K Extension :: class ) Ċ class ĠCred its Cache Test Ġ{ ĊĊĠĠĠ Ġ@ Rel ax ed Mock K ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcredits Dao : ĠCred its Dao ĊĠĠĠ Ġ@ Rel ax ed Mock K ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġto Domain : ĠRoom Domain Adapter ĊĠĠĠ Ġ@ Rel ax ed Mock K ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġto Room : ĠDomain Room Adapter ĊĠĠĠ Ġ@ Rel ax ed Mock K ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtimestamp Helper : ĠCache Timestamp Helper ĊĊĠĠĠ Ġprivate Ġval Ġnow Ġ= Ġ 1 2 L ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsubject : ĠCred its Cache ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġroom Database Ġ= Ġmock k < MP Room Data Base >() ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġroom Database . credits Dao () Ġ} Ġreturns Ġcredits Dao ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġtimestamp Helper . now () Ġ} Ġreturns Ġnow ĊĊĠĠĠĠĠĠĠ Ġsubject Ġ= ĠCred its Cache ( room Database , Ġto Domain , Ġto Room , Ġtimestamp Helper ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Should Ġreturn Ġnull Ġwhen Ġthere Ġis Ġno Ġcast Ġstored Ġin ĠDatabase `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cast Characters ( any (), Ġany ()) Ġ} Ġreturns Ġnull ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cre w ( any (), Ġany ()) Ġ} Ġreturns Ġmock k ( relax ed Ġ= Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubject . getC red its For Movie ( 1 2 . toDouble ()) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Should Ġreturn Ġnull Ġwhen Ġthere Ġis Ġno Ġcre w Ġstored Ġin ĠDatabase `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cast Characters ( any (), Ġany ()) Ġ} Ġreturns Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cre w ( any (), Ġany ()) Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubject . getC red its For Movie ( 1 2 . toDouble ()) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Should Ġreturn Ġnull Ġwhen Ġthere Ġis Ġno Ġdata Ġstored Ġin ĠDatabase `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cast Characters ( any (), Ġany ()) Ġ} Ġreturns Ġnull ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cre w ( any (), Ġany ()) Ġ} Ġreturns Ġnull ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubject . getC red its For Movie ( 1 2 . toDouble ()) ĊĊĠĠĠĠĠĠĠ ĠassertNull ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Should Ġreturn Ġmapped Ġcredits `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdb Characters : ĠList < DB Cast Character > Ġ= Ġmock k () ĊĠĠĠĠĠĠĠ Ġval Ġdb Cre w : ĠList < DB Cre w Person > Ġ= Ġmock k () ĊĠĠĠĠĠĠĠ Ġval Ġexpected Credits : ĠCred its Ġ= Ġmock k () ĊĠĠĠĠĠĠĠ Ġval Ġmovie Id Ġ= Ġ 1 2 . toDouble () ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdb Characters . isEmpty () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġdb Cre w . isEmpty () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġtimestamp Helper . credits Refresh Time () Ġ} Ġreturns Ġ 1 ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cast Characters ( any (), Ġany ()) Ġ} Ġreturns Ġdb Characters ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcredits Dao . get Movie Cre w ( any (), Ġany ()) Ġ} Ġreturns Ġdb Cre w ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġto Domain . credits ( any (), Ġany (), Ġany ()) Ġ} Ġreturns Ġexpected Credits ĊĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġsubject . getC red its For Movie ( movie Id ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Credits , Ġresult ) ĊĠĠĠ Ġ} Ċ } Ċ