package Ġcom . program mer gab ut . mov iec atalog ue . ui . movie Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . paging . Paged List Ċ import Ġcom . program mer gab ut . mov iec atalog ue . data . local . entity . NP Movie Ċ import Ġcom . program mer gab ut . mov iec atalog ue . data . repository . MC Repository Ċ import Ġcom . program mer gab ut . mov iec atalog ue . utils . Resource Ċ 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 . Mockito . verify Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ Ċ /* Ċ Ġ* Ġ ĠCreated Ġby ĠK at ili ĠJ i wo ĠA di ĠW iy ono Ġon Ġ 2 4 / 0 4 / 2 0 . Ċ Ġ*/ Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠMovie Fragment ViewModel Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠMovie Fragment ViewModel ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm cr Repository : ĠMC Repository ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġobserver : ĠObserver < Resource < Paged List < NP Movie >>> ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpage d List : ĠP aged List < NP Movie > ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp (){ ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠMovie Fragment ViewModel ( m cr Repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Movie () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġdummy Courses Ġ= ĠResource . success ( page d List ) ĊĠĠĠĠĠĠĠ Ġ` when `( dummy Courses . data ?. size ). thenReturn ( 5 ) ĊĠĠĠĠĠĠĠ Ġval Ġmovie Ġ= ĠMutable LiveData < Resource < Paged List < NP Movie >> >() ĊĠĠĠĠĠĠĠ Ġmovie . value Ġ= Ġdummy Courses ĊĊĊĠĠĠĠĠĠĠ Ġ` when `( m cr Repository . get NP Movie ()). thenReturn ( movie ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmovie Ret Val Ġ= ĠviewModel . movie () ĊĠĠĠĠĠĠĠ Ġverify ( m cr Repository ). get NP Movie () ĊĊĠĠĠĠĠĠĠ ĠassertNotNull ( movie Ret Val ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 , Ġmovie Ret Val . value ?. data ?. size ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . movie (). observe Fore ver ( observer ) ĊĠĠĠĠĠĠĠ Ġverify ( observer ). on Changed ( dummy Courses ) ĊĊĊĠĠĠĠĠĠĠ Ġ/* Ġval Ġdummy Movie Ġ= ĠData Dummy . generate Movie () ĊĠĠĠĠĠĠĠ Ġval Ġmovie Ġ= ĠMutable LiveData < Resource < NP Movie Api >>() ĊĠĠĠĠĠĠĠ Ġmovie . value Ġ= Ġdummy Movie ĊĊĠĠĠĠĠĠĠ Ġ` when `( m cr Repository . get NP Movie ()). thenReturn ( movie ) ĊĊĠĠĠĠĠĠĠ Ġval Ġmovie Ret val Ġ= ĠviewModel . nP Movie () ĊĠĠĠĠĠĠĠ Ġverify ( m cr Repository ). get NP Movie () ĊĠĠĠĠĠĠĠ ĠassertNotNull ( movie Ret val ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 5 , Ġmovie Ret val . value . data . results . size ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . nP Movie (). observe Fore ver ( observer ) ĊĠĠĠĠĠĠĠ Ġverify ( observer ). on Changed ( dummy Movie ) Ġ*/ ĊĠĠĠ Ġ} Ċ }