package Ġfr . sample . hex ag onal architecture . core _ characters . adapter . input Ċ Ċ import Ġfr . sample . hex ag onal architecture . commons _ io . Input Adapter Scope Ċ import Ġfr . sample . hex ag onal architecture . commons _ lang . Resource Ċ import Ġfr . sample . hex ag onal architecture . core _ characters . application . port . input . Get Character Detail UseCase Ċ import Ġfr . sample . hex ag onal architecture . core _ characters . application . port . input . Get Characters UseCase Ċ import Ġfr . sample . hex ag onal architecture . core _ characters . domain .* Ċ import Ġio . mock k . co Every Ċ import Ġio . mock k . mock k Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . test . Standard Test Dispatcher Ċ import Ġkotlinx . coroutines . test . reset Main Ċ import Ġkotlinx . coroutines . test . run Test Ċ import Ġkotlinx . coroutines . test . set Main Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ class ĠChar acters Input Adapter Test Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġget Characters UseCase : ĠGet Characters UseCase ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġget Character Detail UseCase : ĠGet Character Detail UseCase ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcharacters Input Adapter : ĠChar acters Input Adapter ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdispatcher Ġ= ĠStandard Test Dispatcher () ĊĠĠĠĠĠĠĠ ĠDispatch ers . set Main ( dispatcher ) ĊĠĠĠĠĠĠĠ Ġget Characters UseCase Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġget Character Detail UseCase Ġ= Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġcharacters Input Adapter Ġ= ĠChar acters Input Adapter ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInput Adapter Scope ( dispatcher ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Characters UseCase , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Character Detail UseCase ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ ĠDispatch ers . reset Main () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġfetch Ġnew Ġcharacters `() Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġget Characters UseCase . get Characters () Ġ} Ġreturns ĠResource . Success ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter ( id Ġ= ĠCharacter Id (" id 1 "), Ġname Ġ= ĠCharacter Name (" bob ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter ( id Ġ= ĠCharacter Id (" id 2 "), Ġname Ġ= ĠCharacter Name (" p ame la ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter ( id Ġ= ĠCharacter Id (" id 3 "), Ġname Ġ= ĠCharacter Name (" g aga ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertThat ( characters Input Adapter . get Characters (). data OrNull ()). contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter ( id Ġ= ĠCharacter Id (" id 1 "), Ġname Ġ= ĠCharacter Name (" bob ")), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter ( id Ġ= ĠCharacter Id (" id 2 "), Ġname Ġ= ĠCharacter Name (" p ame la ")), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter ( id Ġ= ĠCharacter Id (" id 3 "), Ġname Ġ= ĠCharacter Name (" g aga ")) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġpropagate Ġerror Ġwhen Ġf etches Ġnew Ġcharacters `() Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġget Characters UseCase . get Characters () Ġ} Ġreturns ĠResource . Error ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠException (" Unable Ġto Ġfetch Ġcharacters ") ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( characters Input Adapter . get Characters (). exception OrNull ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. is Exactly InstanceOf ( Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Message (" Unable Ġto Ġfetch Ġcharacters ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġfetch Ġcharacter 's Ġdetail `() Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġget Character Detail UseCase . get Character Detail With ( Character Id ( any ())) Ġ} Ġreturns ĠResource . Success ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter Detail ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= ĠCharacter Id (" id 1 "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= ĠCharacter Name (" bob "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstatus Ġ= ĠCharacter Status . Dead ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertThat ( characters Input Adapter . get Character Detail With ( Character Id (" id ")). data OrNull ()). isEqualTo ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCharacter Detail ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= ĠCharacter Id (" id 1 "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġname Ġ= ĠCharacter Name (" bob "), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstatus Ġ= ĠCharacter Status . Dead ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġpropagate Ġerror Ġwhen Ġf etches Ġcharacter Ġdetail `() Ġ= Ġrun Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġget Character Detail UseCase . get Character Detail With ( Character Id ( any ())) Ġ} Ġreturns ĠResource . Error ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠException (" Unable Ġto Ġfetch Ġcharacters Ġdetail ") ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( characters Input Adapter . get Character Detail With ( Character Id (" id ")). exception OrNull ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. is Exactly InstanceOf ( Exception :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Message (" Unable Ġto Ġfetch Ġcharacters Ġdetail ") ĊĠĠĠ Ġ} Ċ }