package Ġp aw els ad an ow ic z . movie playground . data . movies . service Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . any Ċ import Ġcom . n ha ar man . mockito _ kotlin . do Return Ċ import Ġcom . n ha ar man . mockito _ kotlin . do Throw Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . times Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . ob servers . Test Observer Ċ import Ġorg . junit . Test Ċ import Ġp aw els ad an ow ic z . movie playground . data . movies . Movie Data Mock Helper Ċ import Ġp aw els ad an ow ic z . movie playground . data . movies . entity . Movie Data Ċ import Ġp aw els ad an ow ic z . movie playground . data . movies . entity . Pop ular Movies Response Ċ import Ġjava . io . IOException Ċ Ċ class ĠMov ies Service Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return All Pop ular Movies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmovie Data Ġ= ĠMovie Data Mock Helper . get Movie Data () ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġmock < Pop ular Movies Response > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġresults Ġ} Ġdo Return Ġarray ListOf ( movie Data ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġservice Ġ= Ġmock < Movies Service > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġget Pop ular Movies ( any ()) Ġ} Ġdo Return ĠObservable . just ( response ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Pop ular Movies Response >() ĊĠĠĠĠĠĠĠ Ġservice . get Pop ular Movies ( 0 ). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ Ġobserver . assert No Errors () ĊĠĠĠĠĠĠĠ Ġobserver . assert Result ( response ) ĊĠĠĠĠĠĠĠ Ġverify ( service , Ġtimes ( 1 )). get Pop ular Movies ( 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Return Error For Pop ular Movies () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġservice Ġ= Ġmock < Movies Service > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġget Pop ular Movies ( any ()) Ġ} Ġdo Return ĠObservable . error ( IOException ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Pop ular Movies Response >() ĊĠĠĠĠĠĠĠ Ġservice . get Pop ular Movies ( 0 ). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . assert Error ( IOException :: class . java ) ĊĠĠĠĠĠĠĠ Ġobserver . assertNot Complete () ĊĠĠĠĠĠĠĠ Ġverify ( service , Ġtimes ( 1 )). get Pop ular Movies ( 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġshould Pro per ly Return Pop ular Movies For Next Page () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġservice Ġ= Ġmock < Movies Service > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Ġ{ Ġget Pop ular Movies ( any ()) Ġ} Ġdo Return ĠObservable . just ( Movie Data Mock Helper . get Pop ular Movies Response ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= ĠTest Observer < Pop ular Movies Response >() ĊĠĠĠĠĠĠĠ Ġservice . get Pop ular Movies ( 0 ). subscribe () ĊĠĠĠĠĠĠĠ Ġservice . get Pop ular Movies ( 1 ). subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġobserver . assert Complete () ĊĠĠĠĠĠĠĠ Ġobserver . assert No Errors () ĊĠĠĠĠĠĠĠ Ġobserver . assert Result ( Movie Data Mock Helper . get Pop ular Movies Response ()) ĊĠĠĠĠĠĠĠ Ġverify ( service , Ġtimes ( 2 )). get Pop ular Movies ( any ()) ĊĠĠĠ Ġ} Ċ } Ċ