package Ġcom . jak ew h art on . sdk search . store Ċ Ċ import Ġandroid . support . test . Instrumentation Registry Ċ import Ġcom . jak ew h art on . sdk search . store . item . Db Component Ċ import Ġcom . jak ew h art on . sdk search . store . item . Item Util Ċ import Ġkotlinx . coroutines . experimental . Common Pool Ċ import Ġkotlinx . coroutines . experimental . run Blocking Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Assert . assertFalse Ċ import Ġorg . junit . Assert . assertTrue Ċ import Ġorg . junit . Test Ċ Ċ class ĠItem Store Test Ġ{ ĊĠ Ġprivate Ġval Ġitem Store Ġ= ĠDb Component . builder () ĊĠĠĠĠĠ Ġ. context ( Instrumentation Registry . getContext ()) ĊĠĠĠĠĠ Ġ. filename ( null ) ĊĠĠĠĠĠ Ġ. coroutine Context ( Common Pool ) ĊĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠ Ġ. item Store () ĊĊĠ Ġ@ Test Ġfun Ġquery () Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠ Ġitem Store . update Items ( listOf ( ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . One ", Ġ" one . html ", Ġnull ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ Ġval Ġquery Ġ= Ġitem Store . query Items (" One ") ĊĠĠĠ Ġval Ġitem Ġ= Ġquery . receive (). single () ĊĠĠĠ ĠassertEquals (" com . example ", Ġitem . packageName ) ĊĠĠĠ ĠassertEquals (" One ", Ġitem . className ) ĊĠĠĠ ĠassertFalse ( item . deprecated ) ĊĠĠĠ ĠassertEquals (" one . html ", Ġitem . link ) ĊĠĠĠ Ġquery . cancel () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġupsert () Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠ Ġitem Store . update Items ( listOf ( ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . One ", Ġ" one . html ", Ġnull ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ Ġval Ġquery Ġ= Ġitem Store . query Items (" One ") ĊĊĠĠĠ Ġval Ġitem 1 Ġ= Ġquery . receive (). single () ĊĠĠĠ Ġval Ġid Ġ= Ġitem 1 . id ĊĠĠĠ ĠassertEquals (" com . example ", Ġitem 1 . packageName ) ĊĠĠĠ ĠassertEquals (" One ", Ġitem 1 . className ) ĊĠĠĠ ĠassertEquals (" one . html ", Ġitem 1 . link ) ĊĠĠĠ ĠassertFalse ( item 1 . deprecated ) ĊĊĠĠĠ Ġitem Store . update Items ( listOf ( ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . One ", Ġ" two . html ", Ġ" deprecated ") ĊĠĠĠ Ġ)) ĊĊĠĠĠ Ġval Ġitem 2 Ġ= Ġquery . receive (). single () ĊĠĠĠ ĠassertEquals ( id , Ġitem 2 . id ) ĊĠĠĠ ĠassertEquals (" com . example ", Ġitem 2 . packageName ) ĊĠĠĠ ĠassertEquals (" One ", Ġitem 2 . className ) ĊĠĠĠ ĠassertEquals (" two . html ", Ġitem 2 . link ) ĊĠĠĠ ĠassertTrue ( item 2 . deprecated ) ĊĊĠĠĠ Ġquery . cancel () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġcount () Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠ Ġval Ġquery Ġ= Ġitem Store . count () ĊĊĠĠĠ ĠassertEquals ( 0 , Ġquery . receive ()) ĊĊĠĠĠ Ġitem Store . update Items ( listOf ( ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . One ", Ġ" one . html ", Ġnull ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ ĠassertEquals ( 1 , Ġquery . receive ()) ĊĊĠĠĠ Ġitem Store . update Items ( listOf ( ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . Two ", Ġ" two . html ", Ġnull ), ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . Three ", Ġ" three . html ", Ġnull ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ ĠassertEquals ( 3 , Ġquery . receive ()) ĊĠĠĠ Ġquery . cancel () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġwild cards () Ġ= Ġrun Blocking < Unit > Ġ{ ĊĠĠĠ Ġitem Store . update Items ( listOf ( ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . One % Two ", Ġ" percent . html ", Ġnull ), ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . One _ Two ", Ġ" underscore . html ", Ġnull ), ĊĠĠĠĠĠĠĠ ĠItem Util . create For Insert (" com . example . One \\ Two ", Ġ" escape . html ", Ġnull ) ĊĠĠĠ Ġ)) ĊĊĠĠĠ Ġitem Store . query Items ("% "). also Ġ{ ĊĠĠĠĠĠ ĠassertEquals (" One % Two ", Ġit . receive (). single (). className ) ĊĠĠĠĠĠ Ġit . cancel () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġitem Store . query Items ("_ "). also Ġ{ ĊĠĠĠĠĠ ĠassertEquals (" One _ Two ", Ġit . receive (). single (). className ) ĊĠĠĠĠĠ Ġit . cancel () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġitem Store . query Items ("\ \" ). also Ġ{ ĊĠĠĠĠĠ ĠassertEquals (" One \\ Two ", Ġit . receive (). single (). className ) ĊĠĠĠĠĠ Ġit . cancel () ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ