package Ġorg . simple . clin ic . user . register user Ċ Ċ import Ġcom . f 2 pr ate ek . rx . preferences 2 . Preference Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . do Return Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . wh enever Ċ import Ġio . reactivex . Single Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Test Ċ import Ġorg . simple . shared Test Code . TestData Ċ import Ġorg . simple . clin ic . analytics . Mock Analytics Reporter Ċ import Ġorg . simple . clin ic . login . Users Api Ċ import Ġorg . simple . clin ic . platform . analytics . Analytics Ċ import Ġorg . simple . clin ic . platform . analytics . Analytics User Ċ import Ġorg . simple . clin ic . registration . Registration Request Ċ import Ġorg . simple . clin ic . registration . Registration Response Ċ import Ġorg . simple . clin ic . user . User Ċ import Ġorg . simple . clin ic . user . User . LoggedIn Status . LOG GED _ IN Ċ import Ġorg . simple . shared Test Code . util . to Payload Ċ import Ġjava . util . Optional Ċ import Ġjava . util . UUID Ċ Ċ class ĠRegister User Test Ġ{ ĊĊĠ Ġ@ After ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ ĠAnalytics . clear Report ers () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` when Ġuser Ġregisters , Ġset Ġthe Ġregistered Ġuser Ġin Ġanalytics `() Ġ{ ĊĠĠĠ Ġ// Ġgiven ĊĠĠĠ Ġval Ġuser Uuid Ġ= ĠUUID . fromString (" 0 e 7 b 2 b 0 9 - dbb 0 - 4 de 6 - b 6 6 d - 6 afe 8 3 4 c 1 4 ed ") ĊĠĠĠ Ġval Ġfacility Uuid Ġ= ĠUUID . fromString (" 2 aa 4 ccc 3 - 5 e 4 f - 4 c 3 2 - 8 df 3 - 1 3 0 4 a 5 6 ae 8 b 3 ") ĊĠĠĠ Ġval Ġfacility Ġ= ĠTest Data . facility ( facility Uuid ) ĊĠĠĠ Ġval Ġuser Ġ= ĠTest Data . logged In User ( user Uuid , Ġregistration Facility Uuid Ġ= Ġfacility Uuid , Ġcurrent Facility Uuid Ġ= Ġfacility Uuid ) ĊĊĠĠĠ Ġval Ġusers Api Ġ= Ġmock < Users Api >() ĊĠĠĠ Ġval Ġuser Dao Ġ= Ġmock < User . Room Dao >() ĊĠĠĠ Ġval ĠaccessToken Preference Ġ= Ġmock < Preference < Optional < String >> >() ĊĊĠĠĠ Ġval Ġpayload Ġ= Ġuser . to Payload ( facility Uuid ) ĊĠĠĠ Ġval Ġsaved User Ġ= Ġuser . copy ( logged In Status Ġ= ĠLOG GED _ IN ) ĊĠĠĠ Ġwhenever ( users Api . createUser ( Registration Request ( payload ))) Ġdo Return ĠSingle . just ( Registration Response (" accessToken ", Ġpayload )) ĊĊĠĠĠ Ġval Ġreporter Ġ= ĠMock Analytics Reporter () ĊĠĠĠ ĠAnalytics . add Reporter ( reporter ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġval Ġregister User Ġ= ĠRegister User ( users Api , Ġuser Dao , ĠaccessToken Preference ) ĊĊĠĠĠ Ġ// Ġwhen ĊĠĠĠ Ġregister User . register User At Facility ( user ). blocking Get () ĊĊĠĠĠ Ġ// Ġthen ĊĠĠĠ ĠassertThat ( reporter . user ). isEqualTo ( Analytics User ( saved User . uuid )) ĊĠĠĠ ĠassertThat ( reporter . is AN ew Registration ). isTrue () ĊĠ Ġ} Ċ } Ċ