package Ġio . github . reactive circ us . stream lined . home Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġcom . dropbox . android . external . store 4 . Response Origin Ċ import Ġcom . dropbox . android . external . store 4 . Store Response Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġio . github . reactive circ us . coroutines . test . ext . Cor outines Test Rule Ċ import Ġio . github . reactive circ us . coroutines . test . ext . Flow Recorder Ċ import Ġio . github . reactive circ us . coroutines . test . ext . record With Ċ import Ġio . github . reactive circ us . li ved ata . test . ext . Test Observer Ċ import Ġio . github . reactive circ us . stream lined . domain . inter actor . Fetch Head line St ories Ċ import Ġio . github . reactive circ us . stream lined . domain . inter actor . Fetch Personal ized St ories Ċ import Ġio . github . reactive circ us . stream lined . domain . inter actor . Stream Head line St ories Ċ import Ġio . github . reactive circ us . stream lined . domain . inter actor . Stream Personal ized St ories Ċ import Ġio . github . reactive circ us . stream lined . domain . model . Story Ċ import Ġio . mock k . co Every Ċ import Ġio . mock k . co Verify All Ċ import Ġio . mock k . every Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify All Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . Flow Preview Ċ import Ġkotlinx . coroutines . channels . Broadcast Channel Ċ import Ġkotlinx . coroutines . channels . Channel Ċ import Ġkotlinx . coroutines . flow . as Flow Ċ import Ġkotlinx . coroutines . flow . empty Flow Ċ import Ġkotlinx . coroutines . flow . flow Of Ċ import Ġkotlinx . coroutines . test . Test Coroutine Scope Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġjava . io . IOException Ċ Ċ @ Flow Preview Ċ @ Experimental Std lib Api Ċ @ Experimental Cor outines Api Ċ class ĠHome ViewModel Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġval Ġcor outines Test Rule Ġ= ĠCor outines Test Rule () ĊĊĠĠĠ Ġprivate Ġval Ġheadline St ories Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠStory ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġ 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsource Ġ= Ġ" source 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtitle Ġ= Ġ" Article Ġ 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġauthor Ġ= Ġ" Y ang ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdescription Ġ= Ġ" Description ...", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġurl Ġ= Ġ" url ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠimageUrl Ġ= Ġ" image - url ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpublished Time Ġ= Ġ 1 0 0 0 L ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠStory ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġ 2 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsource Ġ= Ġ" source 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtitle Ġ= Ġ" Article Ġ 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġauthor Ġ= Ġ" Y ang ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdescription Ġ= Ġ" Description ...", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġurl Ġ= Ġ" url ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠimageUrl Ġ= Ġ" image - url ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpublished Time Ġ= Ġ 2 0 0 0 L ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġpersonal ized St ories Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠStory ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġ 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsource Ġ= Ġ" source 3 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtitle Ġ= Ġ" Article Ġ 3 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġauthor Ġ= Ġ" Y ang ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdescription Ġ= Ġ" Description ...", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġurl Ġ= Ġ" url ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠimageUrl Ġ= Ġ" image - url ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpublished Time Ġ= Ġ 3 0 0 0 L ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠStory ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġid Ġ= Ġ 4 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsource Ġ= Ġ" source 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtitle Ġ= Ġ" Article Ġ 4 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġauthor Ġ= Ġ" Y ang ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdescription Ġ= Ġ" Description ...", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġurl Ġ= Ġ" url ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠimageUrl Ġ= Ġ" image - url ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpublished Time Ġ= Ġ 4 0 0 0 L ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġstream Head line St ories Ġ= Ġmock k < Stream Head line St ories >() ĊĊĠĠĠ Ġprivate Ġval Ġstream Personal ized St ories Ġ= Ġmock k < Stream Personal ized St ories >() ĊĊĠĠĠ Ġprivate Ġval Ġfetch Head line St ories Ġ= Ġmock k < Fetch Head line St ories >() ĊĊĠĠĠ Ġprivate Ġval Ġfetch Personal ized St ories Ġ= Ġmock k < Fetch Personal ized St ories >() ĊĊĠĠĠ Ġprivate Ġval Ġstate Observer Ġ= ĠTest Observer < Home State >() ĊĊĠĠĠ Ġprivate Ġval Ġeffect Flow Recorder Ġ= ĠFlow Recorder < Home Effect >( Test Coroutine Scope ()) ĊĊĠĠĠ Ġprivate Ġval ĠviewModel : ĠHome ViewModel Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ ĠHome ViewModel ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHome StateMachine ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstream Head line St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstream Personal ized St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Head line St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Personal ized St ories ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` starts Ġstreaming Ġheadline Ġand Ġpersonal ized Ġstories Ġand Ġemits ĠIn Flight # First Time Ġstate Ġwhen Ġinitialized `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġempty Flow () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġempty Flow () ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ Ġverify All Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstream Head line St ories . build Flow ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstream Personal ized St ories . build Flow ( any ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( null ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠId le Ġstate Ġwith Ġgenerated Ġfeed Ġitems Ġwhen Ġheadline Ġand Ġpersonal ized Ġstories Ġstreams Ġemit ĠData Ġresponses `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( headline St ories , ĠResponse Origin . Pers ister ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( personal ized St ories , ĠResponse Origin . Pers ister ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( expected Feed Items ( headline St ories , Ġpersonal ized St ories )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠError Ġstate Ġwhen Ġheadline Ġstories Ġstream Ġemits ĠData Ġresponse Ġand Ġpersonal ized Ġstories Ġstream Ġemits ĠError Ġresponse `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( headline St ories , ĠResponse Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Error ( IOException (), ĠResponse Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Error ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠError Ġstate Ġwhen Ġheadline Ġstories Ġstream Ġemits ĠError Ġresponse Ġand Ġpersonal ized Ġstories Ġstream Ġemits ĠData Ġresponse `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Error ( IOException (), ĠResponse Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( personal ized St ories , ĠResponse Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Error ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠIn Flight # First Time Ġstate Ġwhen Ġeither Ġstories Ġstream Ġemits ĠLoading Ġresponse Ġwhile Ġnot Ġalready Ġin ĠIn Flight Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheadline St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĠĠĠĠĠĠĠ Ġval Ġpersonal ized St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġheadline St ories Response Emitter . as Flow () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġpersonal ized St ories Response Emitter . as Flow () ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcached Ġdata Ġis Ġemitted Ġfirst ĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġheadline St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Origin . Pers ister ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpersonal ized St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Origin . Pers ister ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġthen Ġloading Ġresponses Ġare Ġemitted Ġwhile Ġfetching Ġdata Ġfrom Ġnetwork ĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Loading ( Response Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Loading ( Response Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( expected Feed Items ( headline St ories , Ġpersonal ized St ories )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġheadline St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpersonal ized St ories ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠError Ġstate Ġwhen Ġboth Ġheadline Ġand Ġpersonal ized Ġstories Ġstreams Ġemit ĠError Ġresponses `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Error ( IOException (), ĠResponse Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Error ( IOException (), ĠResponse Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Error ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠShow Transient Error Ġeffect Ġwithout Ġemit ting Ġnew Ġstate Ġwhen Ġeither Ġstories Ġstream Ġemits ĠError Ġresponse Ġwith Ġexisting Ġcached Ġdata Ġin Ġthe Ġcurrent Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheadline St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĠĠĠĠĠĠĠ Ġval Ġpersonal ized St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġheadline St ories Response Emitter . as Flow () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġpersonal ized St ories Response Emitter . as Flow () ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . effect . record With ( effect Flow Recorder ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcached Ġdata Ġis Ġemitted Ġfirst ĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġheadline St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Origin . Pers ister ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpersonal ized St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Origin . Pers ister ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġthen Ġloading Ġresponses Ġare Ġemitted Ġwhile Ġfetching Ġdata Ġfrom Ġnetwork ĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Loading ( Response Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Loading ( Response Origin . Fetcher ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġthen Ġerror Ġreturned Ġwhen Ġfetching Ġdata Ġfrom Ġnetwork ĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Data ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġheadline St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Origin . Fetcher ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . offer ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStore Response . Error ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠIOException (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠResponse Origin . Fetcher ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġheadline St ories , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpersonal ized St ories ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( effect Flow Recorder . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( Home Effect . Show Transient Error ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠId le Ġstate Ġwith Ġupdated Ġfeed Ġitems Ġwhen Ġrefresh Ġis Ġsuccessful Ġwhile Ġin ĠId le Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheadline St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĠĠĠĠĠĠĠ Ġval Ġpersonal ized St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġheadline St ories Response Emitter . as Flow () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġpersonal ized St ories Response Emitter . as Flow () ĊĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Head line St ories . execute ( any ()) Ġ} Ġreturns Ġheadline St ories . sub List ( 0 , Ġ 1 ) ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Personal ized St ories . execute ( any ()) Ġ} Ġreturns Ġempty List () ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( headline St ories , ĠResponse Origin . Pers ister )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( personal ized St ories , ĠResponse Origin . Pers ister )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . refresh Home Feed s () ĊĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( headline St ories . sub List ( 0 , Ġ 1 ), ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( emptyList (), ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġco Verify All Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Head line St ories . execute ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Personal ized St ories . execute ( any ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . Sub sequent ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories . sub List ( 0 , Ġ 1 ), Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories . sub List ( 0 , Ġ 1 ), Ġempty List ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠShow Transient Error Ġeffect Ġand ĠId le Ġstate Ġwith Ġexisting Ġdata Ġwhen Ġrefresh Ġis Ġun successful Ġwhile Ġin ĠId le Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheadline St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĠĠĠĠĠĠĠ Ġval Ġpersonal ized St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġheadline St ories Response Emitter . as Flow () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġpersonal ized St ories Response Emitter . as Flow () ĊĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Head line St ories . execute ( any ()) Ġ} Ġco Answers Ġ{ Ġthrow ĠIOException () Ġ} ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Personal ized St ories . execute ( any ()) Ġ} Ġreturns Ġempty List () ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . effect . record With ( effect Flow Recorder ) ĊĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( headline St ories , ĠResponse Origin . Pers ister )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( personal ized St ories , ĠResponse Origin . Pers ister )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . refresh Home Feed s () ĊĊĠĠĠĠĠĠĠ Ġ// Ġonly Ġrefresh Ġfor Ġpersonal ized Ġstories Ġwas Ġsuccessfully ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( emptyList (), ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġco Verify All Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Head line St ories . execute ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Head line St ories . execute ( any ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . Sub sequent ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġpersonal ized St ories ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( headline St ories , Ġempty List ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( effect Flow Recorder . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( Home Effect . Show Transient Error ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠId le Ġstate Ġwith Ġfetched Ġfeed Ġitems Ġwhen Ġretry Ġis Ġsuccessful Ġwhile Ġin ĠError Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheadline St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĠĠĠĠĠĠĠ Ġval Ġpersonal ized St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġheadline St ories Response Emitter . as Flow () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġpersonal ized St ories Response Emitter . as Flow () ĊĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Head line St ories . execute ( any ()) Ġ} Ġreturns Ġheadline St ories ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Personal ized St ories . execute ( any ()) Ġ} Ġreturns Ġpersonal ized St ories ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( headline St ories , ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Error ( IOException (), ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . refresh Home Feed s () ĊĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( headline St ories . sub List ( 0 , Ġ 1 ), ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( personal ized St ories . sub List ( 0 , Ġ 1 ), ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġco Verify All Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Head line St ories . execute ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Personal ized St ories . execute ( any ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Error , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . Sub sequent ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Idle ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexpected Feed Items ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġheadline St ories . sub List ( 0 , Ġ 1 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpersonal ized St ories . sub List ( 0 , Ġ 1 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` em its ĠError Ġstate Ġwithout Ġemit ting ĠShow Transient Error Ġeffect Ġwhen Ġretry Ġis Ġun successful Ġwhile Ġin ĠError Ġstate `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġheadline St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĠĠĠĠĠĠĠ Ġval Ġpersonal ized St ories Response Emitter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠBroadcast Channel < Store Response < List < Story >> >( Channel . BUFFER ED ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Head line St ories . build Flow ( any ()) Ġ} Ġreturns Ġheadline St ories Response Emitter . as Flow () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġstream Personal ized St ories . build Flow ( any ()) Ġ} Ġreturns Ġpersonal ized St ories Response Emitter . as Flow () ĊĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Head line St ories . execute ( any ()) Ġ} Ġreturns Ġempty List () ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġfetch Personal ized St ories . execute ( any ()) Ġ} Ġco Answers Ġ{ Ġthrow ĠIOException () Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . state . observe Fore ver ( state Observer ) ĊĠĠĠĠĠĠĠ ĠviewModel . effect . record With ( effect Flow Recorder ) ĊĊĠĠĠĠĠĠĠ Ġheadline St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Error ( IOException (), ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġpersonal ized St ories Response Emitter . run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffer ( Store Response . Data ( personal ized St ories , ĠResponse Origin . Fetcher )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . refresh Home Feed s () ĊĊĠĠĠĠĠĠĠ Ġco Verify All Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Head line St ories . execute ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Personal ized St ories . execute ( any ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertThat ( state Observer . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . First Time ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Error , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . In Flight . Sub sequent ( null ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Error ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( effect Flow Recorder . take All ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEmpty () ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġexpected Feed Items ( ĊĠĠĠ Ġheadline St ories : ĠList < Story >, ĊĠĠĠ Ġpersonal ized St ories : ĠList < Story > Ċ ) Ġ= Ġgenerate Feed Items ( ĊĠĠĠ ĠNUMBER _ OF _ HEAD LINES _ DISPLAY ED , ĊĠĠĠ Ġheadline St ories , ĊĠĠĠ Ġpersonal ized St ories Ċ ) Ċ