/* Ċ Ġ* ĠCopyright Ġ 2 0 1 9 ĠAnd rey ĠT ol pe ev Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġcom . github . v ase 4 kin . team city app . tests . presenter Ċ Ċ import Ġandroid . view . Menu Ċ import Ġandroid . view . Menu Inflater Ċ import Ġandroid . view . MenuItem Ċ import Ġcom . github . v ase 4 kin . team city app . account . create . data . On Loading Listener Ċ import Ġcom . github . v ase 4 kin . team city app . base . tracker . View Tracker Ċ import Ġcom . github . v ase 4 kin . team city app . tests . data . Tests DataManager Ċ import Ġcom . github . v ase 4 kin . team city app . tests . extractor . Tests Value Extractor Ċ import Ġcom . github . v ase 4 kin . team city app . tests . router . Tests Router Ċ import Ġcom . github . v ase 4 kin . team city app . tests . view . Tests View Ċ import Ġcom . github . v ase 4 kin . team city app . utils . any Ċ import Ġcom . github . v ase 4 kin . team city app . utils . capture Ċ import Ġcom . github . v ase 4 kin . team city app . utils . eq Ċ import Ġcom . m ug en . M ug en Callbacks Ċ import Ġorg . hamcrest . core . Is .` is ` Ċ import Ġorg . hamcrest . core . Is Equal . equalTo Ċ import Ġorg . junit . Assert . assertThat Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Argument Captor Ċ import Ġorg . mockito . Captor Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . times Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġorg . mockito . Mockito . verify No More Interactions Ċ import Ġorg . mockito . runners . Mockito JUnit Runner Ċ import Ġteam city app . features . test _ details . repository . models . Test Occurrence Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠTests Presenter Impl Test Ġ{ ĊĊĠĠĠ Ġ@ Captor ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġon Loading Integer Listener Argument Captor : ĠArgument Captor < On Loading Listener < Int >> ĊĠĠĠ Ġ@ Captor ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠonLoad More Listener Argument Captor : ĠArgument Captor < M ug en Callbacks > ĊĠĠĠ Ġ@ Captor ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġon Loading Listener Argument Captor : ĠArgument Captor < On Loading Listener < List < Test Occurrence >>> ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmenu Item : ĠMenuItem ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmenu : ĠMenu ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmenu Inflater : ĠMenu Inflater ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtest Occurrence : ĠTest Occurrence ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġloading Listener : ĠOn Loading Listener < List < Test Occurrence >> ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview : ĠTests View ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdata Manager : ĠTests DataManager ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtracker : ĠView Tracker ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġvalue Extractor : ĠTests Value Extractor ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrouter : ĠTests Router ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpresenter : ĠTests Presenter Impl ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter Ġ= ĠTests Presenter Impl ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Load Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( value Extractor . url ). thenReturn (" url ") ĊĠĠĠĠĠĠĠ Ġpresenter . load Data ( loading Listener , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġverify ( value Extractor ). url ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). load Failed Tests ( eq (" url "), Ġeq ( loading Listener ), Ġeq ( false )) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest CreateModel () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( test Occurrence . name ). thenReturn (" name ") ĊĠĠĠĠĠĠĠ ĠassertThat ( presenter . create Model ( listOf ( test Occurrence )). getName ( 0 ), Ġ` is `( equalTo (" name "))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Init Views () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( data Manager . can Load More ()). thenReturn ( false ) ĊĠĠĠĠĠĠĠ Ġpresenter . init Views () ĊĠĠĠĠĠĠĠ Ġverify ( view ). setOn Load More Listener ( capture ( on Load More Listener Argument Captor )) ĊĊĠĠĠĠĠĠĠ Ġval ĠonLoad More Listener Ġ= ĠonLoad More Listener Argument Captor . value ĊĠĠĠĠĠĠĠ ĠassertThat ( on Load More Listener . has Loaded All Items (), Ġ` is `( true )) ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). can Load More () ĊĊĠĠĠĠĠĠĠ ĠonLoad More Listener . on Load More () ĊĠĠĠĠĠĠĠ Ġverify ( view ). add Load More () ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). load More ( capture ( on Loading Listener Argument Captor )) ĊĠĠĠĠĠĠĠ ĠassertThat ( presenter . is Load More Loading , Ġ` is `( true )) ĊĊĠĠĠĠĠĠĠ Ġval Ġlist On Loading Listener Ġ= Ġon Loading Listener Argument Captor . value ĊĠĠĠĠĠĠĠ Ġval Ġtests Ġ= Ġempty List < Test Occurrence >() ĊĠĠĠĠĠĠĠ Ġlist On Loading Listener . on Success ( tests ) ĊĠĠĠĠĠĠĠ Ġverify ( view ). remove Load More () ĊĠĠĠĠĠĠĠ Ġverify ( view ). add More Build s ( any ()) ĊĠĠĠĠĠĠĠ ĠassertThat ( presenter . is Load More Loading , Ġ` is `( false )) ĊĊĠĠĠĠĠĠĠ Ġlist On Loading Listener . on Fail (" error ") ĊĠĠĠĠĠĠĠ Ġverify ( view , Ġtimes ( 2 )). remove Load More () ĊĠĠĠĠĠĠĠ Ġverify ( view ). show Retry Load More Sn ackBar () ĊĠĠĠĠĠĠĠ ĠassertThat ( presenter . is Load More Loading , Ġ` is `( false )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest On Views Created () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( value Extractor . url ). thenReturn (" url ") ĊĠĠĠĠĠĠĠ Ġpresenter . on Views Created () ĊĠĠĠĠĠĠĠ Ġverify ( value Extractor , Ġtimes ( 2 )). url ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). load Test Details ( eq (" url "), Ġcapture ( on Loading Integer Listener Argument Captor )) ĊĊĠĠĠĠĠĠĠ Ġval Ġlistener Ġ= Ġon Loading Integer Listener Argument Captor . value ĊĠĠĠĠĠĠĠ Ġlistener . on Success ( 1 ) ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). post Change Tab Title Event ( eq ( 1 )) ĊĊĠĠĠĠĠĠĠ Ġlistener . on Fail (" error ") ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( value Extractor ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest On Create Options Menu () Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . onCreate Options Menu ( menu , Ġmenu Inflater ) ĊĠĠĠĠĠĠĠ Ġverify ( view ). onCreate Options Menu ( eq ( menu ), Ġeq ( menu Inflater )) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter , Ġmenu , Ġmenu Inflater ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest On Prepare Options Menu () Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . on Prepare Options Menu ( menu ) ĊĠĠĠĠĠĠĠ Ġverify ( view ). on Prepare Options Menu ( eq ( menu )) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter , Ġmenu ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest On Options ItemSelected () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( view . on Options ItemSelected ( eq ( menuItem ))). thenReturn ( true ) ĊĠĠĠĠĠĠĠ ĠassertThat ( presenter . on Options ItemSelected ( menuItem ), Ġ` is `( equalTo ( true ))) ĊĠĠĠĠĠĠĠ Ġverify ( view ). show Refresh Animation () ĊĠĠĠĠĠĠĠ Ġverify ( view ). hide Error View () ĊĠĠĠĠĠĠĠ Ġverify ( view ). hide Empty () ĊĠĠĠĠĠĠĠ Ġverify ( view ). on Options ItemSelected ( eq ( menuItem )) ĊĠĠĠĠĠĠĠ Ġverify ( view ). show Data ( any ()) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter , Ġmenu Item ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Load Failed Tests () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( value Extractor . url ). thenReturn (" url ") ĊĠĠĠĠĠĠĠ Ġpresenter . load Failed Tests () ĊĠĠĠĠĠĠĠ Ġverify ( value Extractor ). url ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). load Failed Tests ( eq (" url ")) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Load Success Tests () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( value Extractor . url ). thenReturn (" url ") ĊĠĠĠĠĠĠĠ Ġpresenter . load Success Tests () ĊĠĠĠĠĠĠĠ Ġverify ( value Extractor ). url ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). load Passed Tests ( eq (" url ")) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Load Ignored Tests () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( value Extractor . url ). thenReturn (" url ") ĊĠĠĠĠĠĠĠ Ġpresenter . load Ignored Tests () ĊĠĠĠĠĠĠĠ Ġverify ( value Extractor ). url ĊĠĠĠĠĠĠĠ Ġverify ( data Manager ). load Ignored Tests ( eq (" url ")) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest On Failed Test Click () Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . on Failed Test Click (" url ") ĊĠĠĠĠĠĠĠ Ġverify ( router ). open Failed Test ( eq (" url ")) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( view , Ġdata Manager , Ġtracker , Ġvalue Extractor , Ġrouter ) ĊĠĠĠ Ġ} Ċ } Ċ