package Ġf ern and ocs . shopping . articles Ċ Ċ import Ġf ern and ocs . shopping . data . Article Ċ import Ġf ern and ocs . shopping . data . source . Articles Repository Ċ import Ġf ern and ocs . shopping . util . schedul ers . Base Scheduler Provider Ċ import Ġf ern and ocs . shopping . util . schedul ers . Immediate Scheduler Provider Ċ import Ġio . reactivex . Flow able Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġorg . mockito . Mockito Annotations Ċ Ċ class ĠArticles Presenter Test Ġ{ ĊĠĠĠ Ġprivate Ġvar ĠMOCK _ ITEMS : ĠList < Article >? Ġ= Ġnull ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Articles Repository : ĠArticles Repository ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Articles View : ĠArticles Contract . View ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Scheduler Provider : ĠBase Scheduler Provider ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Articles Presenter : ĠArticles Presenter ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup Tasks Presenter () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĊĠĠĠĠĠĠĠ Ġm Scheduler Provider Ġ= ĠIm mediate Scheduler Provider () ĊĊĠĠĠĠĠĠĠ Ġm Articles Presenter Ġ= ĠArticles Presenter ( m Articles Repository , Ġm Articles View , Ġm Scheduler Provider ) ĊĊĠĠĠĠĠĠĠ ĠMOCK _ ITEMS Ġ= Ġarray ListOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠArticle (" Title 1 ", Ġ" Description 1 ", Ġ" Â £ 1 1 . 0 0 ", Ġ" https :// i 2 . ztat . net / thumb _ hd / BE / 8 2 / 4 G / 0 0 / 2 C / 1 1 / BE 8 2 4 G 0 0 2 - C 1 1 @ 8 . jpg "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠArticle (" Title 2 ", Ġ" Description 2 ", Ġ" Â £ 1 2 . 0 0 ", Ġ" https :// i 2 . ztat . net / thumb _ hd / BE / 8 2 / 4 G / 0 0 / 2 C / 1 1 / BE 8 2 4 G 0 0 2 - C 1 1 @ 8 . jpg "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠArticle (" Title 3 ", Ġ" Description 3 ", Ġ" Â £ 1 3 . 0 0 ", Ġ" https :// i 2 . ztat . net / thumb _ hd / BE / 8 2 / 4 G / 0 0 / 2 C / 1 1 / BE 8 2 4 G 0 0 2 - C 1 1 @ 8 . jpg ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate Presenter Sets The Presenter To View () Ġ{ ĊĠĠĠĠĠĠĠ Ġm Articles Presenter Ġ= ĠArticles Presenter ( m Articles Repository , Ġm Articles View , Ġm Scheduler Provider ) ĊĊĠĠĠĠĠĠĠ Ġverify < Articles Contract . View >( m Articles View ). set Presenter ( m Articles Presenter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload All Articles From Repository And Load Into View () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( m Articles Repository . get Articles ()). thenReturn ( Flow able . just < List < Article >>( MOCK _ ITEMS )) ĊĊĠĠĠĠĠĠĠ Ġm Articles Presenter . load Articles () ĊĊĠĠĠĠĠĠĠ Ġverify < Articles Contract . View >( m Articles View ). show Loading Indicator () ĊĠĠĠĠĠĠĠ Ġverify < Articles Contract . View >( m Articles View ). hide Loading Indicator () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload Filtered Articles From Repository And Load Into View () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( m Articles Repository . get Articles (" XXX ", ĠlistOf (" black "), Ġ 1 0 )). thenReturn ( Flow able . just < List < Article >>( MOCK _ ITEMS )) ĊĊĠĠĠĠĠĠĠ Ġm Articles Presenter . load Articles (" XXX ", ĠlistOf (" black "), Ġ 1 0 ) ĊĊĠĠĠĠĠĠĠ Ġverify < Articles Contract . View >( m Articles View ). show Loading Indicator () ĊĠĠĠĠĠĠĠ Ġverify < Articles Contract . View >( m Articles View ). hide Loading Indicator () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġerror Loading Articles Shows Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( m Articles Repository . get Articles ()). thenReturn ( Flow able . error ( Exception ())) ĊĊĠĠĠĠĠĠĠ Ġm Articles Presenter . load Articles () ĊĊĠĠĠĠĠĠĠ Ġverify < Articles Contract . View >( m Articles View ). show Loading Articles Error () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġloading Articles Shows Empty Message () Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( m Articles Repository . get Articles ()). thenReturn ( Flow able . just ( emptyList ())) ĊĊĠĠĠĠĠĠĠ Ġm Articles Presenter . load Articles () ĊĊĠĠĠĠĠĠĠ Ġverify < Articles Contract . View >( m Articles View ). show No Articles () ĊĠĠĠ Ġ} Ċ } Ċ