package Ġorg . simple . clin ic . over due Ċ Ċ import Ġandroid . support . test . runner . Android JUnit 4 Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġio . blo co . faker . F aker Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . simple . clin ic . App Database Ċ import Ġorg . simple . clin ic . Authentication Rule Ċ import Ġorg . simple . clin ic . Test Clin ic App Ċ import Ġorg . simple . clin ic . TestData Ċ import Ġorg . simple . clin ic . bp . Blood Pressure Measurement Ċ import Ġorg . simple . clin ic . patient . Gender Ċ import Ġorg . simple . clin ic . patient . Patient Ċ import Ġorg . simple . clin ic . patient . Patient Address Ċ import Ġorg . simple . clin ic . patient . Patient Status Ċ import Ġorg . simple . clin ic . patient . Sync Status Ċ import Ġorg . simple . clin ic . user . User Session Ċ import Ġorg . th reet en . bp . Clock Ċ import Ġorg . th reet en . bp . Instant Ċ import Ġorg . th reet en . bp . LocalDate Ċ import Ġjava . util . UUID Ċ import Ġjavax . inject . Inject Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠAppointment Repository Android Test Ġ{ ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar Ġrepository : ĠAppointment Repository ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar Ġdatabase : ĠApp Database ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar Ġuser Session : ĠUser Session ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar ĠtestData : ĠTest Data ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar Ġfaker : ĠFaker ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar Ġclock : ĠClock ĊĊĠ Ġ@ get : Rule ĊĠ Ġval Ġauthentication Rule Ġ= ĠAuthentication Rule () ĊĊĠ Ġ@ Before ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ ĠTest Clin ic App . app Component (). inject ( this ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġwhen _ creating _ new _ appointment _ then _ the _ appointment _ should _ be _ saved () Ġ{ ĊĠĠĠ Ġval Ġpatient Id Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġappointment Date Ġ= ĠLocalDate . now () ĊĠĠĠ Ġrepository . schedule ( patient Id , Ġappointment Date ). blocking Await () ĊĊĠĠĠ Ġval Ġsaved Appointment Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get (). first () ĊĠĠĠ Ġsaved Appointment . apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . patient Uuid ). isEqualTo ( patient Id ) ĊĠĠĠĠĠ ĠassertThat ( this . scheduled Date ). isEqualTo ( appointment Date ) ĊĠĠĠĠĠ ĠassertThat ( this . status ). isEqualTo ( Appointment . Status . SCHEDUL ED ) ĊĠĠĠĠĠ ĠassertThat ( this . cancel Reason ). isEqualTo ( null ) ĊĠĠĠĠĠ ĠassertThat ( this . sync Status ). isEqualTo ( Sync Status . PENDING ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġwhen _ creating _ new _ appointment _ then _ all _ old _ app ointments _ for _ that _ patient _ should _ be _ c anceled () Ġ{ ĊĠĠĠ Ġval Ġpatient Id Ġ= ĠUUID . randomUUID () ĊĊĠĠĠ Ġval Ġdate 1 Ġ= ĠLocalDate . now () ĊĠĠĠ Ġrepository . schedule ( patient Id , Ġdate 1 ). blocking Await () ĊĊĠĠĠ Ġval Ġdate 2 Ġ= ĠLocalDate . now (). plus Days ( 1 0 ) ĊĠĠĠ Ġrepository . schedule ( patient Id , Ġdate 2 ). blocking Await () ĊĊĠĠĠ Ġval Ġsaved Appointment Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( saved Appointment ). has Size ( 2 ) ĊĊĠĠĠ Ġsaved Appointment [ 0 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . patient Uuid ). isEqualTo ( patient Id ) ĊĠĠĠĠĠ ĠassertThat ( this . scheduled Date ). isEqualTo ( date 1 ) ĊĠĠĠĠĠ ĠassertThat ( this . status ). isEqualTo ( Appointment . Status . VISIT ED ) ĊĠĠĠĠĠ ĠassertThat ( this . cancel Reason ). isEqualTo ( null ) ĊĠĠĠĠĠ ĠassertThat ( this . sync Status ). isEqualTo ( Sync Status . PENDING ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsaved Appointment [ 1 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . patient Uuid ). isEqualTo ( patient Id ) ĊĠĠĠĠĠ ĠassertThat ( this . scheduled Date ). isEqualTo ( date 2 ) ĊĠĠĠĠĠ ĠassertThat ( this . status ). isEqualTo ( Appointment . Status . SCHEDUL ED ) ĊĠĠĠĠĠ ĠassertThat ( this . cancel Reason ). isEqualTo ( null ) ĊĠĠĠĠĠ ĠassertThat ( this . sync Status ). isEqualTo ( Sync Status . PENDING ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġwhen _ fetch ing _ app ointments _ then _ only _ return _ over due _ app ointments () Ġ{ ĊĠĠĠ Ġval Ġaddress 1 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġdatabase . address Dao (). save ( ĊĠĠĠĠĠĠĠ ĠPatient Address ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . address . city (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . address . state (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" In dia ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġpatient 1 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġdate 1 Ġ= ĠLocalDate . now (). minus Days ( 1 0 0 ) ĊĠĠĠ Ġval Ġbp 1 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġdatabase . patient Dao (). save ( ĊĠĠĠĠĠĠĠ ĠPatient ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatient 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . name . name (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . name . name (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠGender . F EM ALE , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocalDate . parse (" 1 9 4 7 - 0 8 - 1 5 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPatient Status . ACTIVE , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSync Status . DONE ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġdatabase . blood Pressure Dao (). save ( listOf ( ĊĠĠĠĠĠĠĠ ĠB lood Pressure Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuuid Ġ= Ġbp 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsyst olic Ġ= Ġ 1 9 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdi ast olic Ġ= Ġ 1 0 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsync Status Ġ= ĠSync Status . PENDING , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Uuid Ġ= ĠtestData . qa User Uuid (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfacility Uuid Ġ= ĠtestData . qa User Facility Uuid (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatient Uuid Ġ= Ġpatient 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠcreatedAt Ġ= ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠupdatedAt Ġ= ĠInstant . now () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ Ġval Ġpatient 2 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġaddress 2 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġdatabase . address Dao (). save ( ĊĠĠĠĠĠĠĠ ĠPatient Address ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress 2 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . address . city (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . address . state (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" In dia ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġdatabase . patient Dao (). save ( ĊĠĠĠĠĠĠĠ ĠPatient ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuuid Ġ= Ġpatient 2 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress Uuid Ġ= Ġaddress 2 , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠfullName Ġ= Ġfaker . name . name (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsearch able Name Ġ= Ġfaker . name . name (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġgender Ġ= ĠGender . TRAN SG ENDER , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdate OfBirth Ġ= ĠLocalDate . parse (" 1 9 9 7 - 0 8 - 1 5 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġage Ġ= Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstatus Ġ= ĠPatient Status . ACTIVE , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠcreatedAt Ġ= ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠupdatedAt Ġ= ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsync Status Ġ= ĠSync Status . DONE ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġpatient 3 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġaddress 3 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġdate 3 Ġ= ĠLocalDate . now (). minus Days ( 1 0 ) ĊĠĠĠ Ġval Ġbp 3 0 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġbp 3 1 Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġdatabase . address Dao (). save ( ĊĠĠĠĠĠĠĠ ĠPatient Address ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . address . city (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . address . state (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" In dia ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġdatabase . patient Dao (). save ( ĊĠĠĠĠĠĠĠ ĠPatient ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatient 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . name . name (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfaker . name . name (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠGender . M ALE , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocalDate . parse (" 1 9 7 7 - 1 1 - 1 5 "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPatient Status . M IG R ATED , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSync Status . DONE ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġdatabase . blood Pressure Dao (). save ( listOf ( ĊĠĠĠĠĠĠĠ ĠB lood Pressure Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuuid Ġ= Ġbp 3 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsyst olic Ġ= Ġ 1 9 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdi ast olic Ġ= Ġ 1 0 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsync Status Ġ= ĠSync Status . PENDING , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Uuid Ġ= ĠtestData . qa User Uuid (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfacility Uuid Ġ= ĠtestData . qa User Facility Uuid (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatient Uuid Ġ= Ġpatient 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠcreatedAt Ġ= ĠInstant . now (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠupdatedAt Ġ= ĠInstant . now () ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠB lood Pressure Measurement ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuuid Ġ= Ġbp 3 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsyst olic Ġ= Ġ 1 8 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdi ast olic Ġ= Ġ 1 1 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsync Status Ġ= ĠSync Status . PENDING , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser Uuid Ġ= ĠtestData . qa User Uuid (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfacility Uuid Ġ= ĠtestData . qa User Facility Uuid (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpatient Uuid Ġ= Ġpatient 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠcreatedAt Ġ= ĠInstant . now (). minus Seconds ( 1 0 0 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠupdatedAt Ġ= ĠInstant . now (). minus Seconds ( 1 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ Ġrepository . schedule ( patient 1 , Ġdate 1 ) ĊĠĠĠĠĠĠĠ Ġ. and Then ( repository . schedule ( patient 2 , ĠLocalDate . now (). minus Days ( 2 ))) ĊĠĠĠĠĠĠĠ Ġ. and Then ( repository . schedule ( patient 3 , Ġdate 3 )) ĊĠĠĠĠĠĠĠ Ġ. blocking Get () ĊĊĠĠĠ Ġval Ġover due Ap pts Ġ= Ġrepository . over due App ointments (). blocking First () ĊĠĠĠ ĠassertThat ( over due Ap pts ). has Size ( 2 ) ĊĠĠĠ Ġover due Ap pts [ 0 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . appointment . patient Uuid ). isEqualTo ( patient 1 ) ĊĠĠĠĠĠ ĠassertThat ( this . appointment . scheduled Date ). isEqualTo ( date 1 ) ĊĠĠĠĠĠ ĠassertThat ( this . appointment . status ). isEqualTo ( Appointment . Status . SCHEDUL ED ) ĊĠĠĠĠĠ ĠassertThat ( this . appointment . cancel Reason ). isEqualTo ( null ) ĊĠĠĠĠĠ ĠassertThat ( this . blood Pressure . uuid ). isEqualTo ( bp 1 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġover due Ap pts [ 1 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . appointment . patient Uuid ). isEqualTo ( patient 3 ) ĊĠĠĠĠĠ ĠassertThat ( this . appointment . scheduled Date ). isEqualTo ( date 3 ) ĊĠĠĠĠĠ ĠassertThat ( this . appointment . status ). isEqualTo ( Appointment . Status . SCHEDUL ED ) ĊĠĠĠĠĠ ĠassertThat ( this . appointment . cancel Reason ). isEqualTo ( null ) ĊĠĠĠĠĠ ĠassertThat ( this . blood Pressure . uuid ). isEqualTo ( bp 3 0 ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġwhen _ setting _ appointment _ reminder _ then _ reminder _ with _ correct _ date _ should _ be _ set () Ġ{ ĊĠĠĠ Ġval Ġpatient Id Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġappointment Date Ġ= ĠLocalDate . now () ĊĠĠĠ Ġrepository . schedule ( patient Id , Ġappointment Date ). blocking Await () ĊĊĠĠĠ Ġval Ġapp ointments Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( app ointments ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( app ointments . first (). rem ind On ). isNull () ĊĊĠĠĠ Ġval Ġuuid Ġ= Ġapp ointments [ 0 ]. uuid ĊĠĠĠ Ġrepository . set Sync Status ( listOf ( uuid ), ĠSync Status . DONE ). blocking Get () ĊĊĠĠĠ Ġval Ġreminder Date Ġ= ĠLocalDate . now (). plus Days ( 1 0 ) ĊĠĠĠ Ġrepository . create Reminder ( uuid , Ġreminder Date ). blocking Get () ĊĊĠĠĠ Ġval Ġupdated List Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( updated List ). has Size ( 1 ) ĊĠĠĠ Ġupdated List [ 0 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . uuid ). isEqualTo ( uuid ) ĊĠĠĠĠĠ ĠassertThat ( this . rem ind On ). isEqualTo ( reminder Date ) ĊĠĠĠĠĠ ĠassertThat ( this . ag reed To Visit ). isNull () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġwhen _ mark ing _ appointment _ as _ ag reed _ to _ visit _ reminder _ for _ 3 0 _ days _ should _ be _ set () Ġ{ ĊĠĠĠ Ġval Ġpatient Id Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġappointment Date Ġ= ĠLocalDate . now ( clock ) ĊĠĠĠ Ġrepository . schedule ( patient Id , Ġappointment Date ). blocking Await () ĊĊĠĠĠ Ġval Ġapp ointments Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( app ointments ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( app ointments . first (). rem ind On ). isNull () ĊĠĠĠ ĠassertThat ( app ointments . first (). ag reed To Visit ). isNull () ĊĊĠĠĠ Ġval Ġuuid Ġ= Ġapp ointments [ 0 ]. uuid ĊĠĠĠ Ġrepository . set Sync Status ( listOf ( uuid ), ĠSync Status . DONE ). blocking Get () ĊĠĠĠ Ġrepository . mark As Ag reed To Visit ( uuid ). blocking Get () ĊĊĠĠĠ Ġval Ġupdated List Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( updated List ). has Size ( 1 ) ĊĠĠĠ Ġupdated List [ 0 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . uuid ). isEqualTo ( uuid ) ĊĠĠĠĠĠ ĠassertThat ( this . rem ind On ). isEqualTo ( LocalDate . now ( clock ). plus Days ( 3 0 )) ĊĠĠĠĠĠ ĠassertThat ( this . ag reed To Visit ). isTrue () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġwhen _ re moving _ appointment _ from _ list _ then _ appointment _ status _ and _ cancel _ reason _ should _ be _ updated () Ġ{ ĊĠĠĠ Ġval Ġpatient Id Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġappointment Date Ġ= ĠLocalDate . now () ĊĠĠĠ Ġrepository . schedule ( patient Id , Ġappointment Date ). blocking Await () ĊĊĠĠĠ Ġval Ġapp ointments Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( app ointments ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( app ointments . first (). cancel Reason ). isNull () ĊĊĠĠĠ Ġval Ġuuid Ġ= Ġapp ointments [ 0 ]. uuid ĊĠĠĠ Ġrepository . set Sync Status ( listOf ( uuid ), ĠSync Status . DONE ). blocking Get () ĊĠĠĠ Ġrepository . cancel With Reason ( uuid , ĠAppointment . Cancel Reason . PAT IENT _ NOT _ RESP OND ING ). blocking Get () ĊĊĠĠĠ Ġval Ġupdated List Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( updated List ). has Size ( 1 ) ĊĠĠĠ Ġupdated List [ 0 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . uuid ). isEqualTo ( uuid ) ĊĠĠĠĠĠ ĠassertThat ( this . cancel Reason ). isEqualTo ( Appointment . Cancel Reason . PAT IENT _ NOT _ RESP OND ING ) ĊĠĠĠĠĠ ĠassertThat ( this . status ). isEqualTo ( Appointment . Status . CANCEL LED ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġwhen _ re moving _ appointment _ with _ reason _ as _ patient _ already _ visited _ then _ appointment _ should _ be _ marked _ as _ visited () Ġ{ ĊĠĠĠ Ġval Ġpatient Id Ġ= ĠUUID . randomUUID () ĊĠĠĠ Ġval Ġappointment Date Ġ= ĠLocalDate . now () ĊĠĠĠ Ġrepository . schedule ( patient Id , Ġappointment Date ). blocking Await () ĊĊĠĠĠ Ġval Ġapp ointments Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( app ointments ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( app ointments . first (). status ). isEqualTo ( Appointment . Status . SCHEDUL ED ) ĊĊĠĠĠ Ġval Ġuuid Ġ= Ġapp ointments [ 0 ]. uuid ĊĠĠĠ Ġrepository . set Sync Status ( listOf ( uuid ), ĠSync Status . DONE ). blocking Get () ĊĠĠĠ Ġrepository . mark As Vis ited ( uuid ). blocking Get () ĊĊĠĠĠ Ġval Ġupdated List Ġ= Ġrepository . record sWith Sync Status ( Sync Status . PENDING ). blocking Get () ĊĠĠĠ ĠassertThat ( updated List ). has Size ( 1 ) ĊĠĠĠ Ġupdated List [ 0 ]. apply Ġ{ ĊĠĠĠĠĠ ĠassertThat ( this . uuid ). isEqualTo ( uuid ) ĊĠĠĠĠĠ ĠassertThat ( this . cancel Reason ). isNull () ĊĠĠĠĠĠ ĠassertThat ( this . status ). isEqualTo ( Appointment . Status . VISIT ED ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ