package Ġcom . ali . par ando osh . sample . domain . use case . restaurant Ċ Ċ import Ġcom . ali . par ando osh . sample . domain . inter actor . main . Get Rest aurants Ċ import Ġcom . ali . par ando osh . sample . domain . model . Restaurant Ċ import Ġcom . ali . par ando osh . sample . domain . repository . Restaurant Repository Ċ import Ġcom . ali . par ando osh . sample . domain . test . factory . Restaurant Factory Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġio . reactivex . Flow able Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ class ĠGet Rest aurants Test Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġget Rest aurants : ĠGet Rest aurants ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Repository : ĠRest aurant Repository ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Repository Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġget Rest aurants Ġ= ĠGet Rest aurants ( mock Repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild UseCase Observable Calls Repository () Ġ{ ĊĠĠĠĠĠĠĠ Ġget Rest aurants . build UseCase Observable ( null ) ĊĠĠĠĠĠĠĠ Ġverify ( mock Repository ). get Rest aurants () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild UseCase Observable Comp letes () Ġ{ ĊĠĠĠĠĠĠĠ Ġstub Repository Get ( Flow able . just ( Restaurant Factory . make List ( 2 ))) ĊĠĠĠĠĠĠĠ Ġval Ġtest Observer Ġ= Ġget Rest aurants . build UseCase Observable ( null ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . assert Complete () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġbuild UseCase Observable Returns Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlist Ġ= ĠRest aurant Factory . make List ( 2 ) ĊĠĠĠĠĠĠĠ Ġstub Repository Get ( Flow able . just ( list )) ĊĠĠĠĠĠĠĠ Ġval Ġtest Observer Ġ= Ġget Rest aurants . build UseCase Observable ( null ). test () ĊĠĠĠĠĠĠĠ Ġtest Observer . assert Value ( list ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġstub Repository Get ( single : ĠFlow able < List < Restaurant >>) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Repository . get Rest aurants ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( single ) ĊĠĠĠ Ġ} Ċ }