package Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . data . repository Ċ Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . data . Dummy Data Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . data . f akes . Fake Search History Cache Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . data . mapper . Character Entity Mapper Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . data . model . Character Entity Ċ import Ġcom . e zi ke . to ben na . star w ars search . lib _ character _ search . domain . model . Character Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . junit . Test Ċ Ċ class ĠSearch History Repository Impl Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġcharacter Entity Mapper Ġ= ĠCharacter Entity Mapper () ĊĊĠĠĠ Ġprivate Ġval Ġsearch History Repository Ġ= ĊĠĠĠĠĠĠĠ ĠSearch History Repository Impl ( Fake Search History Cache (), Ġcharacter Entity Mapper ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsave Search () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcharacter : ĠCharacter Ġ= ĠDummy Data . character ĊĠĠĠĠĠĠĠ Ġsearch History Repository . save Search ( character ) ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠCharacter Ġ= Ġsearch History Repository . get Search History (). first (). first () ĊĠĠĠĠĠĠĠ ĠassertThat ( character ). isEqualTo ( result ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat Ġsave Search Ġdoes Ġnot Ġsave Ġduplicates `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġname Ġ= Ġ" Mart in " ĊĠĠĠĠĠĠĠ Ġval Ġcharacter : ĠCharacter Ġ= ĠDummy Data . character ĊĠĠĠĠĠĠĠ Ġval Ġcharacter 2 : ĠCharacter Ġ= Ġcharacter . copy ( name Ġ= Ġname ) ĊĠĠĠĠĠĠĠ Ġsearch History Repository . save Search ( character ) ĊĠĠĠĠĠĠĠ Ġsearch History Repository . save Search ( character 2 ) ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠCharacter Ġ= Ġsearch History Repository . get Search History (). first (). first () ĊĠĠĠĠĠĠĠ ĠassertThat ( character ). isNot EqualTo ( result ) ĊĠĠĠĠĠĠĠ ĠassertThat ( character 2 . name ). isEqualTo ( name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat Ġget Search History Ġreturns Ġall Ġsaved Ġitems `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcharacter : ĠCharacter Ġ= ĠDummy Data . character ĊĠĠĠĠĠĠĠ Ġval Ġcharacter 1 : ĠCharacter Ġ= Ġcharacter . copy ( url Ġ= Ġ" https :// swap . dev / people / 2 /") ĊĠĠĠĠĠĠĠ Ġval Ġcharacter 2 : ĠCharacter Ġ= Ġcharacter . copy ( url Ġ= Ġ" https :// swap . dev / people / 2 1 /") ĊĊĠĠĠĠĠĠĠ Ġsearch History Repository . save Search ( character ) ĊĠĠĠĠĠĠĠ Ġsearch History Repository . save Search ( character 1 ) ĊĠĠĠĠĠĠĠ Ġsearch History Repository . save Search ( character 2 ) ĊĊĠĠĠĠĠĠĠ Ġval Ġall Items : ĠList < Character > Ġ= ĠlistOf ( character 2 , Ġcharacter 1 , Ġcharacter ) ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Character > Ġ= Ġsearch History Repository . get Search History (). first () ĊĠĠĠĠĠĠĠ ĠassertThat ( all Items ). contains Exactly Elements In ( result ). in Order () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` check Ġthat Ġclear History Ġclears Ġthe Ġcache `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcharacter : ĠCharacter Entity Ġ= ĠDummy Data . character Entity ĊĠĠĠĠĠĠĠ Ġsearch History Repository . save Search ( character Entity Mapper . map From Entity ( character )) ĊĠĠĠĠĠĠĠ Ġsearch History Repository . clear Search History () ĊĠĠĠĠĠĠĠ Ġval Ġresult : ĠList < Character > Ġ= Ġsearch History Repository . get Search History (). first () ĊĠĠĠĠĠĠĠ ĠassertThat ( result ). isEmpty () ĊĠĠĠ Ġ} Ċ } Ċ