package Ġcom . alex styl . special dates . up coming Ċ Ċ import Ġcom . alex styl . special dates . date . Date Ċ import Ġcom . alex styl . special dates . date . Months Ċ import Ġcom . alex styl . special dates . date . Time Period Ċ import Ġcom . alex styl . special dates . events . people events . Up coming Events Settings Ċ import Ġcom . alex styl . special dates . permissions . Mem ento Permissions Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . BDD Mockito . given Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . internal . verification . Times Ċ import Ġorg . mockito . runners . Mockito JUnit Runner ĊĊ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠUp coming Events Presenter Test Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠSTART ING _ DATE Ġ= ĠDate . on ( 1 , ĠMonth s . AP R IL , Ġ 2 0 1 7 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġmock View Ġ= ĠMockito . mock ( Up coming List M VP View :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġmock Permissions Ġ= ĠMockito . mock ( Mem ento Permissions :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġmock Provider Ġ= ĠMockito . mock ( Up coming Events Provider :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġmock Settings Ġ= ĠMockito . mock ( Up coming Events Settings :: class . java ) ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġupcoming Events Presenter : ĠUp coming Events Presenter ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġupcoming Events Presenter Ġ= ĠUp coming Events Presenter ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSTART ING _ DATE , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmock Permissions , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmock Provider , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠS chedulers . tr amp oline (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠS chedulers . tr amp oline () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġgiven ( mock Settings . has Been Initial ised ()). willReturn ( true ) ĊĠĠĠĠĠĠĠ Ġgiven ( mock View . is Showing No Events ). willReturn ( true ) Ġ// Ġstart Ġeach Ġtest Ġwith Ġfrom Ġscratch ĊĠĠĠĠĠĠĠ Ġgiven ( mock Permissions . can Read And Write Contacts ()). willReturn ( true ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Start Present ing Without Permission _ shows Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven ( mock Permissions . can Read And Write Contacts ()). willReturn ( false ) ĊĊĠĠĠĠĠĠĠ Ġupcoming Events Presenter . start Present ing Into ( mock View ) ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( mock View ). show Loading () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Start Present ing With Permission _ show Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven ( mock Permissions . can Read And Write Contacts ()). willReturn ( true ) ĊĊĠĠĠĠĠĠĠ Ġupcoming Events Presenter . start Present ing Into ( mock View ) ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( mock View ). show Loading () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Start Present ing With Permission _ show Events After Done Loading () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġthe Date Ġ= ĠDate . on ( 1 , ĠMonth s . M ARCH , Ġ 2 0 1 7 ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected Events Ġ= Ġarray ListOf < Up coming Row ViewModel >() ĊĠĠĠĠĠĠĠ Ġgiven ( mock Provider . calculate Events Between ( Time Period . a Year From ( the Date ))). willReturn ( expected Events ) ĊĊĠĠĠĠĠĠĠ Ġupcoming Events Presenter . start Present ing Into ( mock View ) ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( mock View ). show Loading () ĊĠĠĠĠĠĠĠ ĠMockito . verify ( mock View ). display ( expected Events ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Events W ere Updated _ when Ask ed ToUpdate _ then New Events Are P ushed To The View () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinitial Events Ġ= Ġarray ListOf < Up coming Row ViewModel >() ĊĠĠĠĠĠĠĠ Ġgiven ( mock Provider . calculate Events Between ( Time Period . a Year From ( START ING _ DATE ))). willReturn ( initial Events ) ĊĊĠĠĠĠĠĠĠ Ġupcoming Events Presenter . start Present ing Into ( mock View ) ĊĊĠĠĠĠĠĠĠ Ġval Ġupdated Events Ġ= Ġarray ListOf < Up coming Row ViewModel >( Date Header ViewModel (" Fe bruary Ġ 2 0 1 7 ", Ġ 2 )) ĊĠĠĠĠĠĠĠ Ġgiven ( mock Provider . calculate Events Between ( Time Period . a Year From ( START ING _ DATE ))). willReturn ( updated Events ) ĊĠĠĠĠĠĠĠ Ġupcoming Events Presenter . refresh Events () ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( mock View , ĠTimes ( 1 )). display ( initial Events ) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( mock View , ĠTimes ( 1 )). display ( updated Events ) ĊĠĠĠ Ġ} Ċ } ĊĊĊ