package Ġio . horizontal systems . bank wallet . core . managers Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin .* Ċ import Ġio . horizontal systems . bank wallet . core . I Adapter Ċ import Ġio . horizontal systems . bank wallet . core . I Adapter Manager Ċ import Ġio . horizontal systems . bank wallet . core . IC urrency Manager Ċ import Ġio . horizontal systems . bank wallet . entities . Coin Ċ import Ġio . horizontal systems . bank wallet . entities . Currency Ċ import Ġio . horizontal systems . bank wallet . modules . Rx Base Test Ċ import Ġio . reactivex . subjects . Behavior Subject Ċ import Ġio . reactivex . subjects . Publish Subject Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito . mock Ċ Ċ class ĠRate Sync er Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrate Sync er : ĠRate Sync er ĊĊĠĠĠ Ġprivate Ġval Ġrate Manager Ġ= Ġmock ( Rate Manager :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġadapter Manager Ġ= Ġmock ( I Adapter Manager :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġcurrency Manager Ġ= Ġmock ( IC urrency Manager :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġnetwork Availability Manager Ġ= Ġmock ( Network Availability Manager :: class . java ) ĊĊĠĠĠ Ġprivate Ġval Ġcoin Codes 1 Ġ= ĠlistOf (" BTC ", Ġ" ETH ", Ġ" B CH ") ĊĠĠĠ Ġprivate Ġval Ġcoin Codes 2 Ġ= ĠlistOf (" BTC ", Ġ" X RP ") ĊĊĠĠĠ Ġprivate Ġval Ġcurrency Code 1 Ġ= Ġ" EUR " ĊĠĠĠ Ġprivate Ġval Ġcurrency Code 2 Ġ= Ġ" USD " ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapters 1 : ĠList < I Adapter > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapters 2 : ĠList < I Adapter > ĊĠĠĠ Ġprivate Ġval Ġbase Currency 1 Ġ= Ġmock ( Currency :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġbase Currency 2 Ġ= Ġmock ( Currency :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġadapters Updated Signal Ġ= ĠPublish Subject . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġbase Currency Updated Signal Ġ= ĠPublish Subject . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġtimer Signal Ġ= ĠBehavior Subject . create Default ( Unit ) ĊĠĠĠ Ġprivate Ġval Ġnetwork Availability Signal Ġ= ĠPublish Subject . create < Unit >() ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ ĠRx Base Test . setup () ĊĊĠĠĠĠĠĠĠ Ġadapters 1 Ġ= Ġcoin Codes 1 . map Ġ{ Ġcoin Code Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcoin Ġ= Ġmock ( Coin :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= Ġmock ( I Adapter :: class . java ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( coin . code ). thenReturn ( coin Code ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( adapter . coin ). thenReturn ( coin ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġadapters 2 Ġ= Ġcoin Codes 2 . map Ġ{ Ġcoin Code Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcoin Ġ= Ġmock ( Coin :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= Ġmock ( I Adapter :: class . java ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( coin . code ). thenReturn ( coin Code ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhenever ( adapter . coin ). thenReturn ( coin ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġwhenever ( base Currency 1 . code ). thenReturn ( currency Code 1 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( base Currency 2 . code ). thenReturn ( currency Code 2 ) ĊĊĠĠĠĠĠĠĠ Ġwhenever ( adapter Manager . adapters Updated Signal ). thenReturn ( adapters Updated Signal ) ĊĠĠĠĠĠĠĠ Ġwhenever ( currency Manager . base Currency Updated Signal ). thenReturn ( base Currency Updated Signal ) ĊĠĠĠĠĠĠĠ Ġwhenever ( network Availability Manager . network Availability Signal ). thenReturn ( network Availability Signal ) ĊĊĠĠĠĠĠĠĠ Ġwhenever ( network Availability Manager . isConnected ). thenReturn ( true ) ĊĠĠĠĠĠĠĠ Ġwhenever ( adapter Manager . adapters ). thenReturn ( adapters 1 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( currency Manager . base Currency ). thenReturn ( base Currency 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinit () Ġ{ ĊĠĠĠĠĠĠĠ Ġrate Sync er Ġ= ĠRate Sync er ( rate Manager , Ġadapter Manager , Ġcurrency Manager , Ġnetwork Availability Manager , Ġtimer Signal ) ĊĊĠĠĠĠĠĠĠ Ġverify ( rate Manager ). refresh Latest Rates ( coin Codes 1 , Ġcurrency Code 1 ) ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( rate Manager ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinit _ no Internet Connection () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( network Availability Manager . isConnected ). thenReturn ( false ) ĊĊĠĠĠĠĠĠĠ Ġrate Sync er Ġ= ĠRate Sync er ( rate Manager , Ġadapter Manager , Ġcurrency Manager , Ġnetwork Availability Manager , Ġtimer Signal ) ĊĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( rate Manager ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Connection Est ab lished () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( network Availability Manager . isConnected ). thenReturn ( false , Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġrate Sync er Ġ= ĠRate Sync er ( rate Manager , Ġadapter Manager , Ġcurrency Manager , Ġnetwork Availability Manager , Ġtimer Signal ) ĊĊĠĠĠĠĠĠĠ Ġnetwork Availability Signal . onNext ( Unit ) ĊĊĠĠĠĠĠĠĠ Ġverify ( rate Manager ). refresh Latest Rates ( coin Codes 1 , Ġcurrency Code 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Internet Disconnected () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( network Availability Manager . isConnected ). thenReturn ( true , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġrate Sync er Ġ= ĠRate Sync er ( rate Manager , Ġadapter Manager , Ġcurrency Manager , Ġnetwork Availability Manager , Ġtimer Signal ) ĊĊĠĠĠĠĠĠĠ Ġverify ( rate Manager ). refresh Latest Rates ( coin Codes 1 , Ġcurrency Code 1 ) ĊĊĠĠĠĠĠĠĠ Ġnetwork Availability Signal . onNext ( Unit ) ĊĠĠĠĠĠĠĠ Ġtimer Signal . onNext ( Unit ) ĊĠĠĠĠĠĠĠ Ġadapters Updated Signal . onNext ( Unit ) ĊĠĠĠĠĠĠĠ Ġbase Currency Updated Signal . onNext ( Unit ) ĊĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( rate Manager ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Time Passed () Ġ{ ĊĠĠĠĠĠĠĠ Ġrate Sync er Ġ= ĠRate Sync er ( rate Manager , Ġadapter Manager , Ġcurrency Manager , Ġnetwork Availability Manager , Ġtimer Signal ) ĊĊĠĠĠĠĠĠĠ Ġtimer Signal . onNext ( Unit ) ĊĊĠĠĠĠĠĠĠ Ġverify ( rate Manager , Ġtimes ( 2 )). refresh Latest Rates ( coin Codes 1 , Ġcurrency Code 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Coins Update () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( adapter Manager . adapters ). thenReturn ( adapters 1 , Ġadapters 2 ) ĊĊĠĠĠĠĠĠĠ Ġrate Sync er Ġ= ĠRate Sync er ( rate Manager , Ġadapter Manager , Ġcurrency Manager , Ġnetwork Availability Manager , Ġtimer Signal ) ĊĊĠĠĠĠĠĠĠ Ġadapters Updated Signal . onNext ( Unit ) ĊĊĠĠĠĠĠĠĠ Ġval Ġin Order Ġ= Ġin Order ( rate Manager ) ĊĠĠĠĠĠĠĠ Ġin Order . verify ( rate Manager ). refresh Latest Rates ( coin Codes 1 , Ġcurrency Code 1 ) ĊĠĠĠĠĠĠĠ Ġin Order . verify ( rate Manager ). refresh Latest Rates ( coin Codes 2 , Ġcurrency Code 1 ) ĊĠĠĠĠĠĠĠ Ġin Order . verify No More Interactions () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġon Base Currency Update () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( currency Manager . base Currency ). thenReturn ( base Currency 1 , Ġbase Currency 2 ) ĊĊĠĠĠĠĠĠĠ Ġrate Sync er Ġ= ĠRate Sync er ( rate Manager , Ġadapter Manager , Ġcurrency Manager , Ġnetwork Availability Manager , Ġtimer Signal ) ĊĊĠĠĠĠĠĠĠ Ġbase Currency Updated Signal . onNext ( Unit ) ĊĊĠĠĠĠĠĠĠ Ġval Ġin Order Ġ= Ġin Order ( rate Manager ) ĊĠĠĠĠĠĠĠ Ġin Order . verify ( rate Manager ). refresh Latest Rates ( coin Codes 1 , Ġcurrency Code 1 ) ĊĠĠĠĠĠĠĠ Ġin Order . verify ( rate Manager ). refresh Latest Rates ( coin Codes 1 , Ġcurrency Code 2 ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ