package Ġcom . dou glas . lu as app . module . stop forecast Ċ Ċ import Ġandroid . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġcom . dou glas . lu as app . R Ċ import Ġcom . dou glas . lu as app . Rx Immediate Scheduler Rule Ċ import Ġcom . dou glas . lu as app . Test Observer Ċ import Ġcom . dou glas . lu as app . domain . Get Stop Forecast UseCase Ċ import Ġcom . dou glas . lu as app . domain . exception . Invalid Param Exception Ċ import Ġcom . dou glas . lu as app . domain . exception . No Internet Connection Exception Ċ import Ġcom . dou glas . lu as app . domain . model . Stop Info Ċ import Ġcom . dou glas . lu as app . domain . model . Stop Forecast Ċ import Ġcom . dou glas . lu as app . helper . Log Helper Ċ import Ġcom . dou glas . lu as app . helper . Time Helper Ċ import Ġcom . dou glas . lu as app . module . stop forecast . Stop Forecast ViewModel . Companion . STOP _ MAR LB OR OU GH Ċ import Ġcom . dou glas . lu as app . module . stop forecast . Stop Forecast ViewModel . Companion . STOP _ ST ILL ORG AN Ċ import Ġcom . dou glas . lu as app . test Observer Ċ import Ġio . reactivex . Observable Ċ import Ġjunit . framework . TestCase . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito Annotations Ċ Ċ class ĠStop Info Forecast ViewModel Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġtask Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field Ġvar Ġtest Scheduler Rule Ġ= ĠRx Immediate Scheduler Rule () ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġlog Helper : ĠLog Helper ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġtime Helper : ĠTime Helper ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġget Stop Forecast UseCase : ĠGet Stop Forecast UseCase ĊĊĠĠĠ Ġprivate Ġval Ġforecast Ġ= ĠStop Forecast Ġ( ĊĠĠĠĠĠĠĠ Ġ" direction ", ĊĠĠĠĠĠĠĠ Ġ" due ", ĊĠĠĠĠĠĠĠ Ġ" destination " ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġstop Ġ= ĠStop Info ( ĊĠĠĠĠĠĠĠ Ġ" name ", ĊĠĠĠĠĠĠĠ Ġ" message ", ĊĠĠĠĠĠĠĠ ĠlistOf ( forecast ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtarget : ĠStop Forecast ViewModel ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġloading Status Store : ĠTest Observer < Boolean > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġshow Message Status Store : ĠTest Observer < Int > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġstop Forecast s Store : ĠTest Observer < List < Stop Forecast >> ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġstop Info Store : ĠTest Observer < Stop Info > ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĊĠĠĠĠĠĠĠ Ġtarget Ġ= ĠStop Forecast ViewModel ( log Helper , Ġtime Helper , Ġget Stop Forecast UseCase ) ĊĊĠĠĠĠĠĠĠ Ġloading Status Store Ġ= Ġtarget . loading Status . test Observer () ĊĠĠĠĠĠĠĠ Ġshow Message Status Store Ġ= Ġtarget . show ErrorMessage . test Observer () ĊĠĠĠĠĠĠĠ Ġstop Forecast s Store Ġ= Ġtarget . stop Forecast s LiveData . test Observer () ĊĠĠĠĠĠĠĠ Ġstop Info Store Ġ= Ġtarget . stop LiveData . test Observer () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġit Ġis Ġ 1 0 h 3 0 m `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Hour ()). thenReturn ( 1 0 ) ĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Min ()). thenReturn ( 3 0 ) ĊĠĠĠĠĠĠĠ Ġ` when `( get Stop Forecast UseCase . get Stop Forecast ( STOP _ ST ILL ORG AN )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Observable . just ( stop )) ĊĊĠĠĠĠĠĠĠ Ġtarget . load Stop Forecast s () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġloading Status Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġloading Status Store . observed Values [ 1 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġshow Message Status Store . observed Values . count ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( stop . stop Forecast s , Ġstop Forecast s Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( stop , Ġstop Info Store . observed Values [ 0 ]) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġit Ġis Ġ 1 2 h 0 0 m `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Hour ()). thenReturn ( 1 2 ) ĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Min ()). thenReturn ( 0 ) ĊĠĠĠĠĠĠĠ Ġ` when `( get Stop Forecast UseCase . get Stop Forecast ( STOP _ ST ILL ORG AN )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Observable . just ( stop )) ĊĊĠĠĠĠĠĠĠ Ġtarget . load Stop Forecast s () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġloading Status Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġloading Status Store . observed Values [ 1 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġshow Message Status Store . observed Values . count ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( stop . stop Forecast s , Ġstop Forecast s Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( stop , Ġstop Info Store . observed Values [ 0 ]) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġit Ġis Ġ 1 2 h 0 1 m `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Hour ()). thenReturn ( 1 2 ) ĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Min ()). thenReturn ( 1 ) ĊĠĠĠĠĠĠĠ Ġ` when `( get Stop Forecast UseCase . get Stop Forecast ( STOP _ MAR LB OR OU GH )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Observable . just ( stop )) ĊĊĠĠĠĠĠĠĠ Ġtarget . load Stop Forecast s () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġloading Status Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġloading Status Store . observed Values [ 1 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġshow Message Status Store . observed Values . count ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( stop . stop Forecast s , Ġstop Forecast s Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( stop , Ġstop Info Store . observed Values [ 0 ]) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġget Stop Forecast UseCase Ġthrows ĠNo Internet Connection Exception `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Hour ()). thenReturn ( 1 0 ) ĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Min ()). thenReturn ( 3 0 ) ĊĠĠĠĠĠĠĠ Ġ` when `( get Stop Forecast UseCase . get Stop Forecast ( STOP _ ST ILL ORG AN )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Observable . error ( No Internet Connection Exception ())) ĊĊĠĠĠĠĠĠĠ Ġtarget . load Stop Forecast s () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġloading Status Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġloading Status Store . observed Values [ 1 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . error _ no _ internet _ connection , Ġshow Message Status Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġstop Forecast s Store . observed Values . count ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġget Stop Forecast UseCase Ġthrows ĠInvalid Param Exception `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Hour ()). thenReturn ( 1 0 ) ĊĠĠĠĠĠĠĠ Ġ` when `( time Helper . getCurrent Min ()). thenReturn ( 3 0 ) ĊĠĠĠĠĠĠĠ Ġ` when `( get Stop Forecast UseCase . get Stop Forecast ( STOP _ ST ILL ORG AN )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Observable . error ( Invalid Param Exception ())) ĊĊĠĠĠĠĠĠĠ Ġtarget . load Stop Forecast s () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġloading Status Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġloading Status Store . observed Values [ 1 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . error _ default , Ġshow Message Status Store . observed Values [ 0 ]) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġstop Forecast s Store . observed Values . count ()) ĊĠĠĠ Ġ} Ċ }