package Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . processor Ċ Ċ import Ġcom . example . ez ik et ob enna . b aking app . common _ test . Test Post Execution Thread Ċ import Ġcom . example . ez ik et ob enna . b aking app . domain . use case . Fetch Recipes Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . fake . Fake Recipe Repository Error . Companion . ERROR _ MSG Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . fake . Repo Type Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . fake . make Fake Recipe Repository Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Action Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Action . Load Initial Action Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Action . Refresh Recipes Action Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Action . Retry Fetch Action Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Result Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Result . Load Initial Result Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Result . Refresh Recipes Result Ċ import Ġcom . example . ez ik et ob enna . b aking app . recipe . presentation . m vi . Recipe View Result . Retry Fetch Result Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġjava . net . Socket TimeoutException Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . flow . take Ċ import Ġkotlinx . coroutines . flow . toList Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . junit . Test Ċ Ċ class ĠRecipe Action Processor Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġtest Post Execution Thread Ġ= ĠTest Post Execution Thread () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠLoad Initial Action Ġreturns ĠLoaded ĠLoad Initial Result `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Recipe View Result > Ġ= ĠtestData ( Load Initial Action , ĠRepo Type . DATA ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . first ()). isInstanceOf ( Load Initial Result . Loading :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . last ()). isInstanceOf ( Load Initial Result . Loaded :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠLoad Initial Action Ġreturns ĠEmpty ĠLoad Initial Result `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Recipe View Result > Ġ= ĠtestData ( Load Initial Action , ĠRepo Type . EMPTY ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . first ()). isInstanceOf ( Load Initial Result . Loading :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . last ()). isInstanceOf ( Load Initial Result . Empty :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠLoad Initial Action Ġthrows ĠError `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġvalue : ĠRecipe View Result Ġ= ĠtestData ( Load Initial Action , ĠRepo Type . ERROR ). last () ĊĠĠĠĠĠĠĠ ĠassertThat ( value ). isInstanceOf ( Load Initial Result . Error :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat (( value Ġas ĠLoad Initial Result . Error ). cause ). isInstanceOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSocket TimeoutException :: class . java ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertThat ( value . cause . message ). isEqualTo ( ERROR _ MSG ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠRetry Fetch Action Ġreturns ĠLoaded ĠRetry Fetch Result `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Recipe View Result > Ġ= ĠtestData ( Retry Fetch Action , ĠRepo Type . DATA ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . first ()). isInstanceOf ( Retry Fetch Result . Loading :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . last ()). isInstanceOf ( Retry Fetch Result . Loaded :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠRetry Fetch Action Ġreturns ĠEmpty ĠRetry Fetch Result `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Recipe View Result > Ġ= ĠtestData ( Retry Fetch Action , ĠRepo Type . EMPTY ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . first ()). isInstanceOf ( Retry Fetch Result . Loading :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . last ()). isInstanceOf ( Retry Fetch Result . Empty :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠRetry Fetch Action Ġthrows ĠError `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġvalue : ĠRecipe View Result Ġ= ĠtestData ( Retry Fetch Action , ĠRepo Type . ERROR ). last () ĊĠĠĠĠĠĠĠ ĠassertThat ( value ). isInstanceOf ( Retry Fetch Result . Error :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat (( value Ġas ĠRetry Fetch Result . Error ). cause ). isInstanceOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSocket TimeoutException :: class . java ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertThat ( value . cause . message ). isEqualTo ( ERROR _ MSG ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠRefresh Recipes Action Ġreturns ĠLoaded ĠRefresh Recipes Result `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Recipe View Result > Ġ= ĠtestData ( Refresh Recipes Action , ĠRepo Type . DATA ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . first ()). isInstanceOf ( Refresh Recipes Result . Refresh ing :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . last ()). isInstanceOf ( Refresh Recipes Result . Loaded :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠRefresh Recipes Action Ġreturns ĠEmpty ĠRefresh Recipes Result `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Recipe View Result > Ġ= ĠtestData ( Refresh Recipes Action , ĠRepo Type . EMPTY ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . first ()). isInstanceOf ( Refresh Recipes Result . Refresh ing :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat ( result . last ()). isInstanceOf ( Refresh Recipes Result . Empty :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat ĠRefresh Recipes Action Ġthrows ĠError `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġvalue : ĠRecipe View Result Ġ= ĠtestData ( Refresh Recipes Action , ĠRepo Type . ERROR ). last () ĊĠĠĠĠĠĠĠ ĠassertThat ( value ). isInstanceOf ( Refresh Recipes Result . Error :: class . java ) ĊĠĠĠĠĠĠĠ ĠassertThat (( value Ġas ĠRefresh Recipes Result . Error ). cause ). isInstanceOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSocket TimeoutException :: class . java ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ ĠassertThat ( value . cause . message ). isEqualTo ( ERROR _ MSG ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun ĠtestData ( ĊĠĠĠĠĠĠĠ Ġaction : ĠRecipe View Action , ĊĠĠĠĠĠĠĠ Ġtype : ĠRepo Type , ĊĠĠĠĠĠĠĠ Ġemission s : ĠInt Ġ= Ġ 2 ĊĠĠĠ Ġ): ĠList < Recipe View Result > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfetch Recipes Ġ= ĠFetch Recipes ( make Fake Recipe Repository ( type ), Ġtest Post Execution Thread ) ĊĠĠĠĠĠĠĠ Ġval Ġrecipe Action Processor Ġ= ĠRecipe Action Processor ( fetch Recipes ) ĊĠĠĠĠĠĠĠ Ġval Ġflow Result : ĠFlow < Recipe View Result > Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrecipe Action Processor . action To Result ( action ) ĊĠĠĠĠĠĠĠ Ġreturn Ġflow Result . take ( em ission s ). toList () ĊĠĠĠ Ġ} Ċ } Ċ