package Ġcom . al wan . b aj ps ub mission 2 . ui . movie Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġcom . al wan . b aj ps ub mission 2 . data . Catalog ue Repository Ċ import Ġcom . al wan . b aj ps ub mission 2 . data . source . local . entity . Catalog ue Entity Ċ import Ġcom . al wan . b aj ps ub mission 2 . utils . Dummy Catalog ue Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertNotNull Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠMovie ViewModel Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcatalog ue Repository : ĠCatalog ue Repository ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmovies Observer : ĠObserver < ArrayList < Catalog ue Entity >> ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠMovie ViewModel ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠMovie ViewModel ( catalog ue Repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Movies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdummy Movies Ġ= ĠDummy Catalog ue . get Movies () ĊĠĠĠĠĠĠĠ Ġval Ġmovies Ġ= ĠMutable LiveData < ArrayList < Catalog ue Entity >>() ĊĠĠĠĠĠĠĠ Ġmovies . value Ġ= Ġdummy Movies ĊĊĠĠĠĠĠĠĠ Ġ` when `( catalog ue Repository . get Movies ()). thenReturn ( movies ) ĊĠĠĠĠĠĠĠ Ġval Ġmovie Ġ= ĠviewModel . get Movies (). value ĊĠĠĠĠĠĠĠ Ġverify ( catalog ue Repository ). get Movies () ĊĠĠĠĠĠĠĠ ĠassertNotNull ( movie ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 3 , Ġmovie ?. size ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . get Movies (). observe Fore ver ( movies Observer ) ĊĠĠĠĠĠĠĠ Ġverify ( movies Observer ). on Changed ( dummy Movies ) ĊĠĠĠ Ġ} Ċ }