package Ġcom . zh eng . home Ċ Ċ import Ġcom . zh eng . home . data . DataManager Ċ import Ġcom . zh eng . home . data . model . Quiz Ċ import Ġcom . zh eng . home . features . quiz . Quiz M vp View Ċ import Ġcom . zh eng . home . features . quiz . Quiz Presenter Ċ import Ġcom . zh eng . home . util . Rx Schedulers Override Rule Ċ import Ġcom . zh eng . home . util . TestUtils Ċ import Ġio . reactivex . Single Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Argument Matchers . any Boolean Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .* Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠQu iz Presenter Test Ġ{ ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate ĊĠĠĠ Ġlateinit Ġvar Ġquiz M vp View : ĠQu iz M vp View ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate ĊĠĠĠ Ġlateinit Ġvar Ġm Mock DataManager : ĠData Manager ĊĠĠĠ Ġprivate Ġvar Ġquiz Presenter : ĠQu iz Presenter ? Ġ= Ġnull ĊĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġval Ġm Override Schedulers Rule Ġ= ĠRx Schedulers Override Rule () ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġquiz Presenter Ġ= ĠQu iz Presenter ( m Mock DataManager ) ĊĠĠĠĠĠĠĠ Ġquiz Presenter ?. attach View ( quiz M vp View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġquiz Presenter ?. detach View () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġget Qu ize () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtest Utils Ġ= ĠTestUtils () ĊĠĠĠĠĠĠĠ Ġval Ġload Json Ġ= Ġtest Utils . load Json (" mock / quiz . json ") ĊĠĠĠĠĠĠĠ Ġ` when `( m Mock DataManager . response ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Single . just ( load Json )) ĊĊĠĠĠĠĠĠĠ Ġquiz Presenter ?. get Qu ize () ĊĠĠĠĠĠĠĠ Ġverify < Quiz M vp View >( quiz M vp View , Ġtimes ( 2 )). show Progress ( any Boolean ()) ĊĠĠĠĠĠĠĠ Ġverify < Quiz M vp View >( quiz M vp View ). show Quiz ( Quiz ("", ĠlistOf ()), Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġverify < Quiz M vp View >( quiz M vp View , Ġnever ()). show Error ( RuntimeException ()) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġquiz : ĠQu iz ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġget Qu ize Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( m Mock DataManager . response ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Single . error < String >( RuntimeException ())) ĊĊĠĠĠĠĠĠĠ Ġquiz Presenter ?. get Qu ize () ĊĠĠĠĠĠĠĠ Ġverify < Quiz M vp View >( quiz M vp View , Ġtimes ( 2 )). show Progress ( any Boolean ()) ĊĠĠĠĠĠĠĠ Ġverify < Quiz M vp View >( quiz M vp View , Ġnever ()). show Quiz ( quiz , Ġ 1 ) ĊĠĠĠ Ġ} Ċ }