package Ġorg . simple . clin ic . home . pat ients Ċ Ċ import Ġcom . f 2 pr ate ek . rx . preferences 2 . Preference Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . do Return Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify No More Interactions Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Zero Interactions Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . wh enever Ċ import Ġio . reactivex . Observable Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Test Ċ import Ġorg . simple . clin ic . app update . App Update Notification Scheduler Ċ import Ġorg . simple . clin ic . app update . App Update N udge Priority . CRITICAL Ċ import Ġorg . simple . clin ic . app update . App Update State . Show App Update Ċ import Ġorg . simple . clin ic . app update . Check App Update Availability Ċ import Ġorg . simple . clin ic . drug stock rem inders . Dr ug Stock Reminder Ċ import Ġorg . simple . clin ic . drug stock rem inders . Dr ug Stock Reminder . Result . NotFound Ċ import Ġorg . simple . clin ic . mob ius . Effect Handler TestCase Ċ import Ġorg . simple . clin ic . user . User Session Ċ import Ġorg . simple . clin ic . user . refresh user . Refresh CurrentUser Ċ import Ġorg . simple . shared Test Code . util . Test User Clock Ċ import Ġorg . simple . shared Test Code . util . Test Utc Clock Ċ import Ġorg . simple . clin ic . util . scheduler . Test Schedulers Provider Ċ import Ġorg . simple . clin ic . util . to Utc Instant Ċ import Ġjava . time . Instant Ċ import Ġjava . time . LocalDate Ċ import Ġjava . util . Optional Ċ Ċ class ĠPat ients Effect Handler Test Ġ{ ĊĠ Ġprivate Ġval Ġui Actions Ġ= Ġmock < Pat ients Tab Ui Actions >() ĊĠ Ġprivate Ġval Ġuser Session Ġ= Ġmock < User Session >() ĊĠ Ġprivate Ġval Ġapproval Status Approved At Preference Ġ= Ġmock < Preference < Instant >>() ĊĠ Ġprivate Ġval Ġhas User Dis missed Approved Status Preference Ġ= Ġmock < Preference < Boolean >>() ĊĠ Ġprivate Ġval Ġcheck App Update Ġ= Ġmock < Check App Update Availability >() ĊĠ Ġprivate Ġval Ġapp Update Dialog Shown Pref Ġ= Ġmock < Preference < Instant >>() ĊĠ Ġprivate Ġval Ġapp Update Notification Scheduler Ġ= Ġmock < App Update Notification Scheduler >() ĊĠ Ġprivate Ġval Ġdrug Stock Reminder Ġ= Ġmock < Dr ug Stock Reminder >() ĊĠ Ġprivate Ġval Ġdrug Stock Report Last Checked At Ġ= Ġmock < Preference < Instant >>() ĊĠ Ġprivate Ġval Ġis Dr ug Stock Report Filled Ġ= Ġmock < Preference < Optional < Boolean >> >() ĊĊĠ Ġprivate Ġval Ġdate Ġ= ĠLocalDate . parse (" 2 0 1 8 - 0 1 - 0 1 ") ĊĠ Ġprivate Ġval Ġut c Clock Ġ= ĠTest Utc Clock ( date ) ĊĠ Ġprivate Ġval Ġuser Clock Ġ= ĠTest User Clock ( date ) ĊĊĠ Ġprivate Ġval ĠnumberOf Pat ients Registered Preference Ġ= Ġmock < Preference < Int >>() ĊĠ Ġprivate Ġval Ġrefresh CurrentUser Ġ= Ġmock < Refresh CurrentUser >() ĊĊĠ Ġprivate Ġval Ġview Effect Handler Ġ= ĠPat ients Tab View Effect Handler ( ui Actions ) ĊĊĠ Ġprivate Ġval Ġeffect Handler Ġ= ĠPat ients Effect Handler ( ĊĠĠĠĠĠ Ġs chedulers Ġ= ĠTest Schedulers Provider . tr amp oline (), ĊĠĠĠĠĠ Ġrefresh CurrentUser Ġ= Ġrefresh CurrentUser , ĊĠĠĠĠĠ Ġuser Session Ġ= Ġuser Session , ĊĠĠĠĠĠ Ġut c Clock Ġ= Ġut c Clock , ĊĠĠĠĠĠ Ġuser Clock Ġ= Ġuser Clock , ĊĠĠĠĠĠ Ġcheck App Update Ġ= Ġcheck App Update , ĊĠĠĠĠĠ Ġapp Update Notification Scheduler Ġ= Ġapp Update Notification Scheduler , ĊĠĠĠĠĠ Ġhas User Dis missed Approved Status Pref Ġ= Ġhas User Dis missed Approved Status Preference , ĊĠĠĠĠĠ ĠnumberOf Pat ients Registered Pref Ġ= ĠnumberOf Pat ients Registered Preference , ĊĠĠĠĠĠ Ġapp Update Dialog Shown At Pref Ġ= Ġapp Update Dialog Shown Pref , ĊĠĠĠĠĠ Ġapproval Status UpdatedAt Pref Ġ= Ġapproval Status Approved At Preference , ĊĠĠĠĠĠ Ġdrug Stock Reminder Ġ= Ġdrug Stock Reminder , ĊĠĠĠĠĠ Ġdrug Stock Report Last Checked At Ġ= Ġdrug Stock Report Last Checked At , ĊĠĠĠĠĠ Ġis Dr ug Stock Report Filled Ġ= Ġis Dr ug Stock Report Filled , ĊĠĠĠĠĠ Ġview Effects Consumer Ġ= Ġview Effect Handler :: handle ĊĠ Ġ). build () ĊĊĠ Ġprivate Ġval Ġeffect Handler TestCase Ġ= ĠEffect Handler TestCase ( effect Handler ) ĊĊĠ Ġ@ After ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ Ġeffect Handler TestCase . dispose () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġopen Ġsimple Ġon Ġplay Ġstore Ġeffect Ġis Ġreceived , Ġthen Ġopen Ġsimple Ġon Ġplay Ġstore `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Open Simple On Play Store ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġverify ( ui Actions ). open Simple On Play store () ĊĠĠĠ Ġeffect Handler TestCase . assert No Outgoing Events () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġschedule Ġapp Ġupdate Ġnotification Ġeffect Ġis Ġreceived , Ġthen Ġschedule Ġapp Ġupdate Ġnotification `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Schedule App Update Notification ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġverify ( app Update Notification Scheduler ). schedule () ĊĠĠĠ Ġverify No More Interactions ( app Update Notification Scheduler ) ĊĠĠĠ Ġeffect Handler TestCase . assert No Outgoing Events () ĊĠĠĠ Ġverify Zero Interactions ( ui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġshow Ġcritical Ġapp Ġupdate Ġdialog Ġeffect Ġis Ġreceived , Ġthen Ġshow Ġcritical Ġapp Ġupdate Ġdialog `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġapp Update N udge Priority Ġ= ĠCR ITICAL ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Show Critical App Update Dialog ( app Update N udge Priority )) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġverify ( ui Actions ). show Critical App Update Dialog ( app Update N udge Priority ) ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠĠĠ Ġeffect Handler TestCase . assert No Outgoing Events () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġload Ġinfo Ġfor Ġshowing Ġapp Ġupdate Ġmessage Ġeffect Ġis Ġreceived , Ġthen Ġload Ġinfo Ġfor Ġshowing Ġapp Ġupdate Ġmessage `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġapp Update N udge Priority Ġ= ĠCR ITICAL ĊĠĠĠ Ġval Ġapp Update Last Shown On Ġ= ĠLocalDate . of ( 2 0 2 2 , Ġ 3 , Ġ 2 2 ) ĊĠĠĠ Ġwhenever ( check App Update . listen ()). do Return ( Observable . just ( Show App Update ( app Update N udge Priority , Ġ 1 8 1 ))) ĊĠĠĠ Ġwhenever ( app Update Dialog Shown Pref . get ()). thenReturn ( app Update Last Shown On . to Utc Instant ( user Clock )) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Load Info For Showing App Update Message ) ĊĊĠĠĠ Ġ// Ġthen ĊĊĠĠĠ Ġeffect Handler TestCase . assert Outgoing Events ( Required Info For Showing App Update Loaded ( ĊĠĠĠĠĠĠĠ Ġis App Update Available Ġ= Ġtrue , ĊĠĠĠĠĠĠĠ Ġapp Update Last Shown On Ġ= Ġapp Update Last Shown On , ĊĠĠĠĠĠĠĠ Ġcurrent Date Ġ= ĠLocalDate . of ( 2 0 1 8 , Ġ 1 , Ġ 1 ), ĊĠĠĠĠĠĠĠ Ġapp Update N udge Priority Ġ= Ġapp Update N udge Priority , ĊĠĠĠĠĠĠĠ Ġapp St al eness Ġ= Ġ 1 8 1 ĊĠĠĠ Ġ)) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġload Ġdrug Ġstock Ġreminder Ġstatus Ġeffect Ġis Ġreceived , Ġthen Ġload Ġthe Ġdrug Ġstock Ġreminder Ġstatus `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġwhenever ( drug Stock Reminder . reminder For Dr ug Stock (" 2 0 2 2 - 0 3 - 0 2 ")) Ġdo Return ĠNotFound ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Load Dr ug Stock Report Status ( date Ġ= Ġ" 2 0 2 2 - 0 3 - 0 2 ")) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġeffect Handler TestCase . assert Outgoing Events ( Dr ug Stock Report Loaded ( result Ġ= ĠNotFound )) ĊĊĠĠĠ Ġverify Zero Interactions ( ui Actions ) ĊĊĠĠĠ Ġverify ( drug Stock Reminder ). reminder For Dr ug Stock ( date Ġ= Ġ" 2 0 2 2 - 0 3 - 0 2 ") ĊĠĠĠ Ġverify No More Interactions ( drug Stock Reminder ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġload Ġinfo Ġfor Ġshowing Ġdrug Ġstock Ġreminder Ġeffect Ġis Ġreceived , Ġthen Ġload Ġthe Ġinfo `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġwhenever ( drug Stock Report Last Checked At . get ()) Ġdo Return ĠLocalDate . parse (" 2 0 2 2 - 0 4 - 1 9 "). to Utc Instant ( user Clock ) ĊĠĠĠ Ġwhenever ( is Dr ug Stock Report Filled . get ()) Ġdo Return ĠOptional . of ( true ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Load Info For Showing Dr ug Stock Reminder ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġeffect Handler TestCase . assert Outgoing Events ( Required Info For Showing Dr ug Stock Reminder Loaded ( ĊĠĠĠĠĠĠĠ Ġcurrent Date Ġ= ĠLocalDate . parse (" 2 0 1 8 - 0 1 - 0 1 "), ĊĠĠĠĠĠĠĠ Ġdrug Stock Report Last Checked At Ġ= ĠLocalDate . parse (" 2 0 2 2 - 0 4 - 1 9 "), ĊĠĠĠĠĠĠĠ Ġis Dr ug Stock Report Filled Ġ= ĠOptional . of ( true ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ Ġverify Zero Interactions ( ui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġtouch Ġdrug Ġstock Ġreport Ġlast Ġchecked Ġat Ġpreference Ġeffect Ġis Ġreceived , Ġthen Ġupdate Ġdrug Ġstock Ġreport Ġlast Ġchecked Ġat Ġpreference `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Touch Dr ug Stock Report Last Checked At ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġeffect Handler TestCase . assert No Outgoing Events () ĊĊĠĠĠ Ġverify Zero Interactions ( ui Actions ) ĊĊĠĠĠ Ġverify ( drug Stock Report Last Checked At ). set ( Instant . parse (" 2 0 1 8 - 0 1 - 0 1 T 0 0 : 0 0 : 0 0 Z ")) ĊĠĠĠ Ġverify No More Interactions ( drug Stock Report Last Checked At ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġtouch Ġis Ġdrug Ġstock Ġreport Ġfilled Ġeffect Ġis Ġreceived , Ġthen Ġupdate Ġdrug Ġstock Ġreport Ġfilled Ġstatus Ġin Ġpreference `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Touch Is Dr ug Stock Report Filled ( is Dr ug Stock Report Filled Ġ= Ġtrue )) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġeffect Handler TestCase . assert No Outgoing Events () ĊĊĠĠĠ Ġverify Zero Interactions ( ui Actions ) ĊĊĠĠĠ Ġverify ( is Dr ug Stock Report Filled ). set ( Optional . of ( true )) ĊĠĠĠ Ġverify No More Interactions ( drug Stock Report Last Checked At ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġopen Ġenter Ġdrug Ġstock Ġscreen Ġeffect Ġis Ġreceived , Ġthen Ġopen Ġenter Ġdrug Ġstock Ġscreen `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Open Enter Dr ug Stock Screen ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġeffect Handler TestCase . assert No Outgoing Events () ĊĠĠĠ Ġverify ( ui Actions ). open Enter Dr ug Stock Screen () ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġshow Ġno Ġactive Ġnetwork Ġconnection Ġdialog Ġeffect Ġis Ġreceived , Ġthen Ġshow Ġno Ġactive Ġnetwork Ġconnection Ġdialog `() Ġ{ ĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġeffect Handler TestCase . dispatch ( Show No Active Network Connection Dialog ) ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ Ġeffect Handler TestCase . assert No Outgoing Events () ĊĠĠĠ Ġverify ( ui Actions ). show No Active Network Connection Dialog () ĊĠĠĠ Ġverify No More Interactions ( ui Actions ) ĊĠ Ġ} Ċ } Ċ