import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġconfig . backend . Pod cast Client Ċ import Ġconfig . backend . R ss Client Ċ import Ġconfig . podcast Client Ċ import Ġconfig . rss Client Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Test Ċ import Ġjava . time . Duration Ċ import Ġkotlin . time . Duration . Companion . minutes Ċ Ċ class ĠFunctional Test { ĊĊĠĠĠ Ġ@ Test Ġfun Ġr ss Genre Type Test () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġr ss Client Ġ= Ġpod cast Client < Pod cast Client > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsearch Term =" History " ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠ Ġval Ġfirst Pod cast = Ġr ss Client . podcast s . first () ĊĠĠĠĠĠĠĠ Ġval Ġexpected Genre Type =" History " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Se ar ched Genre = first Pod cast . data ?. first ()?. podcast Gen res ?. contains ( expected Genre Type ) ĊĠĠĠĠĠĠĠ Ġval Ġfalse Search Genre Ġ= Ġfirst Pod cast . data ?. first ()?. podcast Gen res ?. contains (" Food ") ĊĠĠĠĠĠĠĠ ĠassertThat ( expected Se ar ched Genre ). isEqualTo ( true ) ĊĠĠĠĠĠĠĠ ĠassertThat ( false Search Genre ). isEqualTo ( false ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test Ġfun Ġpod cast Client Properties Test (){ ĊĠĠĠĠĠĠĠ Ġval Ġclient = podcast Client < Pod cast Client > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsearch Term =" History " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġread Timeout = ĠDuration . of Seconds ( 3 0 0 0 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġexpected Search Term Ġ=" History " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Read Time Duration Ġ= ĠDuration . of Seconds ( 3 0 0 0 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Search Term Ġ= Ġclient . search Term ĊĠĠĠĠĠĠĠ Ġval Ġactual Read Time Duration Ġ= Ġclient . read Timeout ĊĠĠĠĠĠĠĠ ĠassertThat ( actual Search Term ). isEqualTo ( expected Search Term ) ĊĠĠĠĠĠĠĠ ĠassertThat ( actual Read Time Duration ). isEqualTo ( expected Read Time Duration ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test Ġfun Ġr ss Client Properties Test (){ ĊĠĠĠĠĠĠĠ Ġval Ġr ss Client Ġ= Ġr ss Client < R ss Client > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġr ss Feed Url =" http :// feeds . feed burn er . com / d anc ar lin / history ? format = xml " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcache Duration = Ġ 2 0 . minutes ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġexpected R ss Feed Url Ġ= Ġ" http :// feeds . feed burn er . com / d anc ar lin / history ? format = xml " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Cache Duration Ġ= 2 0 . minutes ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Cache Duration Ġ= Ġr ss Client . cache Duration ĊĠĠĠĠĠĠĠ Ġval Ġactual R ss Feed Url Ġ= Ġr ss Client . rss Feed Url ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual Cache Duration ). isEqualTo ( expected Cache Duration ) ĊĠĠĠĠĠĠĠ ĠassertThat ( actual R ss Feed Url ). isEqualTo ( expected R ss Feed Url ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test Ġfun Ġblank R ss Feed Url Returns Error Test () Ġ= Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġr ss Client Ġ= Ġr ss Client < R ss Client > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġr ss Feed Url ="" ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġactual JsonResponse = rss Client . json ified R ss Feed s () ĊĠĠĠĠĠĠĠ Ġval Ġexpected JsonResponse Content Ġ= Ġ"{\" error \": true ,\" errorMessage \":\" Ġr ss Ġfeed Ġurl Ġcannot Ġbe Ġempty Ġor Ġblank ! \",\" podcast Title \":\" \",\" podcast Description \":\" \",\" podcast Link \":\" \",\" podcast Image Link \":\" \",\" podcast Episode s \":\" \" }" ĊĠĠĠĠĠĠĠ ĠassertThat ( actual JsonResponse ). contains ( expected JsonResponse Content ) ĊĠĠĠ Ġ} Ċ Ċ }