package Ġcom . hal cy on mobile . multi plat for mp lay ground . use case Ċ Ċ import Ġcom . hal cy on mobile . multi plat for mp lay ground . model . Application Detail Ċ import Ġcom . hal cy on mobile . multi plat for mp lay ground . repository . application . Application Repository Ċ import Ġcom . hal cy on mobile . multi plat for mp lay ground . shared . Result Ċ import Ġcom . hal cy on mobile . multi plat for mp lay ground . util . Base Test Ċ import Ġcom . hal cy on mobile . multi plat for mp lay ground . util . application Detail Data Ċ import Ġio . mock k . Mock K Annotations Ċ import Ġio . mock k . co Every Ċ import Ġio . mock k . impl . annotations . Rel ax ed Mock K Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġkotlin . test . assertEquals Ċ Ċ class ĠGet Application Detail UseCase Test Ġ: ĠBaseTest () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsut : ĠGet Application Detail UseCase ĊĊĠĠĠ Ġ@ Rel ax ed Mock K ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrepository : ĠApplication Repository ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ ĠMock K Annotations . init ( this ) ĊĊĠĠĠĠĠĠĠ Ġsut Ġ= ĠGet Application Detail UseCase ( repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġrepository Ġfails Ġto Ġretrieve Ġapplication Ġdetail ĠThen Ġcorrect Ġerror Ġresponse Ġis Ġreturned `() Ġ= ĊĠĠĠĠĠĠĠ Ġcoroutine Test Rule . run Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexception Ġ= ĠRuntimeException () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġrepository . get Detail ById ( any ()) Ġ} Ġthrows Ġexception ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠResult . Error < Application Detail >( exception ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected , Ġactual Ġ= Ġsut ( 0 )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġrepository Ġretrieves Ġapplication Ġdetail Ġsuccessfully ĠThen Ġthe Ġapplication Ġdetail Ġis Ġreturned `() Ġ= ĊĠĠĠĠĠĠĠ Ġcoroutine Test Rule . run Test Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġrepository . get Detail ById ( any ()) Ġ} Ġreturns Ġapplication Detail Data ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( expected Ġ= ĠResult . Success ( application Detail Data ), Ġactual Ġ= Ġsut ( 1 )) ĊĠĠĠĠĠĠĠ Ġ} Ċ }