package Ġcom . fs ck . k 9 . aut od is covery . providers xml Ċ Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġcom . fs ck . k 9 . Ro bo lectric Test Ċ import Ġcom . fs ck . k 9 . aut od is covery . api . Discovery Target Ċ import Ġcom . fs ck . k 9 . backend . Backend Manager Ċ import Ġcom . fs ck . k 9 . backend . imap . I map Store Uri Decoder Ċ import Ġcom . fs ck . k 9 . mail . Auth Type Ċ import Ġcom . fs ck . k 9 . mail . Connection Security Ċ import Ġcom . fs ck . k 9 . mail . transport . smtp . Sm tp Transport Uri Decoder Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . do Answer Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Argument Matchers . any String Ċ Ċ class ĠPro viders Xml Discovery Test Ġ: ĠRo bo lectric Test () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġbackend Manager Ġ= Ġmock < Backend Manager > Ġ{ ĊĠĠĠĠĠĠĠ Ġon Ġ{ Ġdecode Store Uri ( any String ()) Ġ} Ġdo Answer Ġ{ Ġmock Ġ-> ĠI map Store Uri Decoder . decode ( mock . get Argument ( 0 )) Ġ} ĊĠĠĠĠĠĠĠ Ġon Ġ{ Ġdecode Transport Uri ( any String ()) Ġ} Ġdo Answer Ġ{ Ġmock Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSm tp Transport Uri Decoder . decode Sm tp Uri ( mock . get Argument ( 0 )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġxml Provider Ġ= ĠPro viders Xml Provider ( Application Provider . getApplicationContext ()) ĊĠĠĠ Ġprivate Ġval Ġproviders Xml Discovery Ġ= ĠPro viders Xml Discovery ( backend Manager , Ġxml Provider ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdiscover _ with G mail Domain _ should Return Correct Settings () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconnection Settings Ġ= Ġproviders Xml Discovery . discover (" user @ gmail . com ", ĠDiscovery Target . IN COM ING _ AND _ OUT GO ING ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( connection Settings ). isNotNull () ĊĠĠĠĠĠĠĠ Ġwith ( connection Settings !!. incoming . first ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( host ). isEqualTo (" imap . gmail . com ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( security ). isEqualTo ( Connection Security . SSL _ TLS _ REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( auth Type ). isEqualTo ( Auth Type . PLAIN ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( username ). isEqualTo (" user @ gmail . com ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġwith ( connection Settings . outgoing . first ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( host ). isEqualTo (" smtp . gmail . com ") ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( security ). isEqualTo ( Connection Security . SSL _ TLS _ REQUIRED ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( auth Type ). isEqualTo ( Auth Type . PLAIN ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( username ). isEqualTo (" user @ gmail . com ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdiscover _ with Unknown Domain _ should Return Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconnection Settings Ġ= Ġproviders Xml Discovery . discover ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" user @ not . present . in . providers . xml . example ", ĠDiscovery Target . IN COM ING _ AND _ OUT GO ING ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( connection Settings ). isNull () ĊĠĠĠ Ġ} Ċ } Ċ