package Ġcom . one gin i . mobile . sdk Ċ Ċ import Ġcom . one gin i . mobile . sdk . android . client . One gin i Client Ċ import Ġcom . one gin i . mobile . sdk . android . client . User Client Ċ import Ġcom . one gin i . mobile . sdk . android . handlers . One gin i Authenticator Dere gistration Handler Ċ import Ġcom . one gin i . mobile . sdk . android . handlers . error . One gin i Authenticator Dere gistration Error Ċ import Ġcom . one gin i . mobile . sdk . android . model . One gin i Authenticator Ċ import Ġcom . one gin i . mobile . sdk . android . model . entity . UserProfile Ċ import Ġcom . one gin i . mobile . sdk . flutter . One gin i Wrapper Errors Ċ import Ġcom . one gin i . mobile . sdk . flutter . use Cases . Dere gister Authenticator UseCase Ċ import Ġio . flutter . plugin . common . MethodCall Ċ import Ġio . flutter . plugin . common . Method Channel Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Spy Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ import Ġorg . mockito . kotlin . any Ċ import Ġorg . mockito . kotlin . eq Ċ import Ġorg . mockito . kotlin . verify Ċ import Ġorg . mockito . kotlin . wh enever ĊĊ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠD ere gister Authenticator UseCase Tests Ġ{ ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġclient Mock : ĠOne gin i Client ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġuser Client Mock : ĠUser Client ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġcall Mock : ĠMethod Call ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġone gin i Authenticator Mock : ĠOne gin i Authenticator ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġone gin i Authenticator Dere gistration Error Mock : ĠOne gin i Authenticator Dere gistration Error ĊĊĠĠĠ Ġ@ Spy ĊĠĠĠ Ġlateinit Ġvar Ġresult Spy : ĠMethod Channel . Result ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġattach () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( client Mock . user Client ). thenReturn ( user Client Mock ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġerror Ġwhen ĠUser Profiles Ġmethod Ġreturns Ġempty Ġset Ġ` () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . user Profiles ). thenReturn ( empty Set ()) ĊĊĠĠĠĠĠĠĠ ĠD ere gister Authenticator UseCase ( client Mock )( call Mock , Ġresult Spy ) ĊĊĠĠĠĠĠĠĠ Ġverify ( result Spy ). error ( One gin i Wrapper Errors . USER _ PROFILE _ IS _ NULL . code , ĠOne gin i Wrapper Errors . USER _ PROFILE _ IS _ NULL . message , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġerror Ġwhen Ġgiven Ġauth enticator Ġid Ġis Ġnull `() Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . user Profiles ). thenReturn ( set Of ( UserProfile (" Q WER TY "))) ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . get Registered Auth entic ators ( eq ( UserProfile (" Q WER TY ")) )). thenReturn ( set Of ( one gin i Authenticator Mock )) ĊĠĠĠĠĠĠĠ Ġwhenever ( one gin i Authenticator Mock . id ). thenReturn (" test ") ĊĊĠĠĠĠĠĠĠ ĠD ere gister Authenticator UseCase ( client Mock )( call Mock , Ġresult Spy ) ĊĊĠĠĠĠĠĠĠ Ġverify ( result Spy ). error ( One gin i Wrapper Errors . AUTHENT IC ATOR _ IS _ NULL . code , ĠOne gin i Wrapper Errors . AUTHENT IC ATOR _ IS _ NULL . message , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġerror Ġwhen Ġget Registered Auth entic ators Ġmethod Ġreturns Ġempty Ġset `() Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( call Mock . argument < String >(" auth enticator Id ")). thenReturn (" test ") ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . user Profiles ). thenReturn ( set Of ( UserProfile (" Q WER TY "))) ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . get Registered Auth entic ators ( eq ( UserProfile (" Q WER TY ")) )). thenReturn ( empty Set ()) ĊĊĠĠĠĠĠĠĠ ĠD ere gister Authenticator UseCase ( client Mock )( call Mock , Ġresult Spy ) ĊĊĠĠĠĠĠĠĠ Ġverify ( result Spy ). error ( One gin i Wrapper Errors . AUTHENT IC ATOR _ IS _ NULL . code , ĠOne gin i Wrapper Errors . AUTHENT IC ATOR _ IS _ NULL . message , Ġnull ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġtrue Ġwhen Ġgiven Ġauth enticator Ġid Ġfound Ġin Ġget Registered Auth entic ators Ġmethod `() Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( call Mock . argument < String >(" auth enticator Id ")). thenReturn (" test ") ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . user Profiles ). thenReturn ( set Of ( UserProfile (" Q WER TY "))) ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . get Registered Auth entic ators ( eq ( UserProfile (" Q WER TY ")) )). thenReturn ( set Of ( one gin i Authenticator Mock )) ĊĠĠĠĠĠĠĠ Ġwhenever ( one gin i Authenticator Mock . id ). thenReturn (" test ") ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . dere gister Authenticator ( eq ( one gin i Authenticator Mock ), Ġany ())). then Answer Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . get Argument < One gin i Authenticator Dere gistration Handler >( 1 ). on Success () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠD ere gister Authenticator UseCase ( client Mock )( call Mock , Ġresult Spy ) ĊĊĠĠĠĠĠĠĠ Ġverify ( result Spy ). success ( eq ( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġerror Ġwhen Ġdere gister Authenticator Ġmethod Ġreturns Ġerror `() Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( call Mock . argument < String >(" auth enticator Id ")). thenReturn (" test ") ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . user Profiles ). thenReturn ( set Of ( UserProfile (" Q WER TY "))) ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . get Registered Auth entic ators ( eq ( UserProfile (" Q WER TY ")) )). thenReturn ( set Of ( one gin i Authenticator Mock )) ĊĠĠĠĠĠĠĠ Ġwhenever ( one gin i Authenticator Mock . id ). thenReturn (" test ") ĊĠĠĠĠĠĠĠ Ġwhenever ( one gin i Authenticator Dere gistration Error Mock . error Type ). thenReturn ( One gin i Authenticator Dere gistration Error . GENERAL _ ERROR ) ĊĠĠĠĠĠĠĠ Ġwhenever ( one gin i Authenticator Dere gistration Error Mock . message ). thenReturn (" General Ġerror ") ĊĠĠĠĠĠĠĠ Ġwhenever ( user Client Mock . dere gister Authenticator ( eq ( one gin i Authenticator Mock ), Ġany ())). then Answer Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . get Argument < One gin i Authenticator Dere gistration Handler >( 1 ). onError ( one gin i Authenticator Dere gistration Error Mock ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠD ere gister Authenticator UseCase ( client Mock )( call Mock , Ġresult Spy ) ĊĊĠĠĠĠĠĠĠ Ġverify ( result Spy ). error ( one gin i Authenticator Dere gistration Error Mock . error Type . toString (), Ġone gin i Authenticator Dere gistration Error Mock . message , Ġnull ) ĊĠĠĠ Ġ} ĊĊ Ċ }