package Ġcom . shop app . shop ify . api Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin .* Ċ import Ġcom . shop app . gateway . Api Callback Ċ import Ġcom . shop app . gateway . entity . Address Ċ import Ġcom . shop app . gateway . entity . Country Ċ import Ġcom . shop app . gateway . entity . Customer Ċ import Ġcom . shop app . gateway . entity . Error Ċ import Ġcom . shop app . shop ify . Sto refront Mock Instanti ator Ċ import Ġcom . shop app . shop ify . api . entity . Api Country Ċ import Ġcom . shop app . shop ify . api . entity . Api Country Response Ċ import Ġcom . shop app . shop ify . api . ret rofit . Countries Service Ċ import Ġcom . shop app . shop ify . constant . Constant Ċ import Ġcom . shop ify . buy 3 . Sto refront Ċ import Ġokhttp 3 . ResponseBody Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Test Ċ import Ġretrofit 2 . Call Ċ import Ġretrofit 2 . Callback Ċ import Ġretrofit 2 . Response Ċ Ċ class ĠShop ify Api Auth Test Ġ: ĠBase Shop ify Api Test () Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign Up Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Create Payload : ĠSto refront . Customer Create Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Create ). willReturn ( customer Create Payload ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Create Payload . customer ). willReturn ( customer ) ĊĊĠĠĠĠĠĠĠ Ġmock Success Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . sign Up ("", Ġ"", Ġ"", Ġ"", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign Up Should Return Non Critical Error When Token Request Failed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Create Payload : ĠSto refront . Customer Create Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Create ). willReturn ( customer Create Payload ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Create Payload . customer ). willReturn ( customer ) ĊĊĠĠĠĠĠĠĠ Ġmock Failure Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . sign Up ("", Ġ"", Ġ"", Ġ"", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign Up Should Return Non Critical Error When SignUp Failed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Create Payload : ĠSto refront . Customer Create Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Create ). willReturn ( customer Create Payload ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Create Payload . customer ). willReturn ( customer ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error : Ġcom . shop ify . graphql . support . Error Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( user Error . message ()). willReturn ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE ) ĊĠĠĠĠĠĠĠ Ġgiven ( graph Response . errors ()). willReturn ( listOf ( user Error )) ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . sign Up ("", Ġ"", Ġ"", Ġ"", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign Up Should Return Content Error When SignUp Failed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Create Payload : ĠSto refront . Customer Create Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Create ). willReturn ( customer Create Payload ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Create Payload . customer ). willReturn ( customer ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . sign Up ("", Ġ"", Ġ"", Ġ"", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign In Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġmock Success Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . signIn ("", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign In Should Return Non Critical Error When Token Request Failed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġmock Failure Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . signIn ("", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign In Should Return Content Error When Token Request Failed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġ_) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġgiven ( mutation Graph Call . execute ()). willReturn ( graph Response ) ĊĠĠĠĠĠĠĠ Ġgiven ( graph Response . data ()). willReturn ( null ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . signIn ("", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsign Out Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . sign Out ( callback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( shared Preferences . edit (), Ġtimes ( 3 )). remove ( any ()) ĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis LoggedIn Should Return True When Session Valid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Boolean > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . is LoggedIn ( callback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( true ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġis LoggedIn Should Return False When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Boolean > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . is LoggedIn ( callback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( false ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġforgot Password Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġmock Success Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . signIn ("", Ġ"", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġforgot Password Should Return Non Critical Error With ErrorResponse () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġ_) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error : Ġcom . shop ify . graphql . support . Error Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( user Error . message ()). willReturn ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE ) ĊĠĠĠĠĠĠĠ Ġgiven ( graph Response . errors ()). willReturn ( listOf ( user Error )) ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . forgot Password ("", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġforgot Password Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġ_) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Recover Payload : ĠSto refront . Customer Recover Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Recover Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( graph Response . data ()?. customer Recover ). willReturn ( customer Recover Payload ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . forgot Password ("", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġforgot Password Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . forgot Password ("", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Customer Should Return Customer () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Query Root ) Ġ= Ġmock Data Response () ĊĠĠĠĠĠĠĠ Ġmock Query Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Query Root . customer ). willReturn ( customer ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer ?> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . get Customer ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Customer >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( first Value ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( customer . id . toString (), Ġfirst Value . id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Customer Should Return Content Error And Clean Session () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġ_) Ġ= Ġmock Data Response () ĊĠĠĠĠĠĠĠ Ġmock Query Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer ?> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . get Customer ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( shared Preferences . edit (), Ġtimes ( 3 )). remove ( any ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Customer Should Return Non Critical When User Not Authorized () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer ?> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . get Customer ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Customer Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Query Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer ?> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . get Customer ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate Customer Address Should Return CustomerId () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġst o refront Address Ġ= ĠSto refront Mock Instanti ator . new Address () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Address Create Payload : ĠSto refront . Customer Address Create Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Address Create Payload . customer Address ). willReturn ( sto refront Address ) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Address Create ). willReturn ( customer Address Create Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġstub Address () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < String > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . create Customer Address ( address , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < String >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( sto refront Address . id . toString (), Ġfirst Value ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate Customer Address Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Address Create Payload : ĠSto refront . Customer Address Create Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Address Create Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Address Create ). willReturn ( customer Address Create Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġstub Address () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < String > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . create Customer Address ( address , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate Customer Address Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġstub Address () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < String > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . create Customer Address ( address , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcreate Customer Address Should Return Content Error When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress : ĠAddress Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < String > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . create Customer Address ( address , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Address Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġst o refront Address Ġ= ĠSto refront Mock Instanti ator . new Address () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Address Update Payload : ĠSto refront . Customer Address Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Address Update Payload . customer Address ). willReturn ( sto refront Address ) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Address Update ). willReturn ( customer Address Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġstub Address () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġaddress , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Address Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Address Update Payload : ĠSto refront . Customer Address Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Address Update Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Address Update ). willReturn ( customer Address Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġstub Address () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġaddress , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Address Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress Ġ= Ġstub Address () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġaddress , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Address Should Return Content Error When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġaddress : ĠAddress Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġaddress , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Customer Address Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Address Delete Payload : ĠSto refront . Customer Address Delete Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Address Delete Payload . deleted Customer Address Id ). willReturn ( Sto refront Mock Instanti ator . DEFAULT _ ID ) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Address Delete ). willReturn ( customer Address Delete Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . delete Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Customer Address Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Address Delete Payload : ĠSto refront . Customer Address Delete Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Address Delete Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Address Delete ). willReturn ( customer Address Delete Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . delete Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Customer Address Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . delete Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġdelete Customer Address Should Return Content Error When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . delete Customer Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠsetDefault Shipping Address Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcustomer Default Address Update Payload : ĠSto refront . Customer Default Address Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Default Address Update ). willReturn ( customer Default Address Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . setDefault Shipping Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠsetDefault Shipping Address Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Default Address Update Payload : ĠSto refront . Customer Default Address Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Default Address Update Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Default Address Update ). willReturn ( customer Default Address Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . setDefault Shipping Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠsetDefault Shipping Address Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . setDefault Shipping Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠsetDefault Shipping Address Should Return Content Error When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . setDefault Shipping Address ( Sto refront Mock Instanti ator . DEFAULT _ ID , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Info Should Return Customer () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġst o refront Customer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Update Payload : ĠSto refront . Customer Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Update Payload . customer ). willReturn ( sto refront Customer ) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Update ). willReturn ( customer Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Info (" firstName ", Ġ" lastName ", Ġ" phone ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Customer >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( sto refront Customer . id . toString (), Ġfirst Value . id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Info Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Update Payload : ĠSto refront . Customer Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Update Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Update ). willReturn ( customer Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Info (" firstName ", Ġ" lastName ", Ġ" phone ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Info Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Info (" firstName ", Ġ" lastName ", Ġ" phone ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġedit Customer Info Should Return Content Error When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Customer > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . edit Customer Info (" firstName ", Ġ" lastName ", Ġ" phone ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchange Password Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġst o refront Customer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Update Payload : ĠSto refront . Customer Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Update Payload . customer ). willReturn ( sto refront Customer ) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Update ). willReturn ( customer Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġmock Success Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . change Password (" password ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchange Password Should Return User Error When Session Request Failed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġst o refront Customer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Update Payload : ĠSto refront . Customer Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Update Payload . customer ). willReturn ( sto refront Customer ) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Update ). willReturn ( customer Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġmock Failure Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . change Password (" password ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchange Password Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġval Ġmutation Graph Call Ġ= Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Update Payload : ĠSto refront . Customer Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Update Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Update ). willReturn ( customer Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġmock Success Request Token ( graph Response , Ġmutation Graph Call , Ġst o refront Mutation ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . change Password (" password ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchange Password Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . change Password (" password ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchange Password Should Return Content Error When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . change Password (" password ", Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Countries Should Return Countries List From Api () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountries Service : ĠCount ries Service Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġcall : ĠCall < Api Country Response > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( countries Service . getCount ries ()). willReturn ( call ) ĊĠĠĠĠĠĠĠ Ġgiven ( ret rofit . create ( Countries Service :: class . java )). willReturn ( countries Service ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse : ĠResponse < Api Country Response > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( response . is Successful ). willReturn ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġapi Country Ġ= ĠApi Country ( 1 2 3 , Ġ" code ", Ġ" name ", ĠlistOf ()) ĊĠĠĠĠĠĠĠ Ġval Ġapi Response Ġ= ĠApi Country Response ( listOf ( api Country )) ĊĠĠĠĠĠĠĠ Ġgiven ( response . body ()). willReturn ( api Response ) ĊĊĠĠĠĠĠĠĠ Ġgiven ( call . enqueue ( any ())). will Answer ({ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcallback Ġ= Ġit . get Argument < Callback < Api Country Response >>( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcallback . on Response ( call , Ġresponse ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < List < Country >> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . getCount ries ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < List < Country >> (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( api Response . countries . size , Ġfirst Value . size ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Countries Should Return Countries List FromJson () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountries Service : ĠCount ries Service Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġcall : ĠCall < Api Country Response > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( countries Service . getCount ries ()). willReturn ( call ) ĊĠĠĠĠĠĠĠ Ġgiven ( ret rofit . create ( Countries Service :: class . java )). willReturn ( countries Service ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse : ĠResponse < Api Country Response > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( response . is Successful ). willReturn ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġapi Country Ġ= ĠApi Country ( 1 2 3 , Ġ" code ", ĠConstant . REST _ OF _ WORLD , ĠlistOf ()) ĊĠĠĠĠĠĠĠ Ġval Ġapi Response Ġ= ĠApi Country Response ( listOf ( api Country )) ĊĠĠĠĠĠĠĠ Ġgiven ( response . body ()). willReturn ( api Response ) ĊĊĠĠĠĠĠĠĠ Ġgiven ( call . enqueue ( any ())). will Answer ({ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcallback Ġ= Ġit . get Argument < Callback < Api Country Response >>( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcallback . on Response ( call , Ġresponse ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġval Ġcountry Id Ġ= Ġ 3 8 0 9 7 9 1 1 8 5 7 L ĊĠĠĠĠĠĠĠ Ġval Ġcountry Name Ġ= Ġ" Af gh an istan " ĊĠĠĠĠĠĠĠ Ġgiven ( assets Reader . read ( any (), Ġany ())). willReturn ("[ \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ{\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" id \": Ġ$ country Id ,\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" name \": Ġ\"$ country Name \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" tax \": Ġ 0 ,\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" code \": Ġ\" AF \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" tax _ name \": Ġ\" V AT \",\ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ĠĠĠ Ġ\" pro vin ces \": Ġ[] \ n " Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ġ Ġ}" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ"] ") ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < List < Country >> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . getCount ries ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < List < Country >> (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value . isNotEmpty ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( country Id , Ġfirst Value . first (). id ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( country Name , Ġfirst Value . first (). name ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Countries Should Return Content Error When Response IsNot Successful () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountries Service : ĠCount ries Service Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġcall : ĠCall < Api Country Response > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( countries Service . getCount ries ()). willReturn ( call ) ĊĠĠĠĠĠĠĠ Ġgiven ( ret rofit . create ( Countries Service :: class . java )). willReturn ( countries Service ) ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse : ĠResponse < Api Country Response > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( response . is Successful ). willReturn ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġresponse Body : ĠResponse Body Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( response . error Body ()). willReturn ( response Body ) ĊĊĠĠĠĠĠĠĠ Ġgiven ( call . enqueue ( any ())). will Answer ({ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcallback Ġ= Ġit . get Argument < Callback < Api Country Response >>( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcallback . on Response ( call , Ġresponse ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < List < Country >> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . getCount ries ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Countries Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountries Service : ĠCount ries Service Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġcall : ĠCall < Api Country Response > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( countries Service . getCount ries ()). willReturn ( call ) ĊĠĠĠĠĠĠĠ Ġgiven ( ret rofit . create ( Countries Service :: class . java )). willReturn ( countries Service ) ĊĊĠĠĠĠĠĠĠ Ġgiven ( call . enqueue ( any ())). will Answer ({ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcallback Ġ= Ġit . get Argument < Callback < Api Country Response >>( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcallback . on Failure ( call , ĠThrowable ()) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < List < Country >> Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . getCount ries ( callback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Customer Settings Should Return Unit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġst o refront Customer Ġ= ĠSto refront Mock Instanti ator . new Customer () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Update Payload : ĠSto refront . Customer Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Update Payload . customer ). willReturn ( sto refront Customer ) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Update ). willReturn ( customer Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . update Customer Settings ( true , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġverify ( callback ). on Result ( Unit ) ĊĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Failure ( any ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Customer Settings Should Return Non Critical Error With User Errors Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( graph Response , Ġst o refront Mutation ) Ġ= Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Response ( graph Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġuser Error Ġ= ĠSto refront Mock Instanti ator . new User Error () ĊĠĠĠĠĠĠĠ Ġval Ġcustomer Update Payload : ĠSto refront . Customer Update Payload Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġgiven ( customer Update Payload . user Errors ). willReturn ( listOf ( user Error )) ĊĠĠĠĠĠĠĠ Ġgiven ( sto refront Mutation . customer Update ). willReturn ( customer Update Payload ) ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . update Customer Settings ( true , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Sto refront Mock Instanti ator . DEFAULT _ ERROR _ MESSAGE , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Customer Settings Should Return Content Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Mutation Data Response () ĊĠĠĠĠĠĠĠ Ġmock Mutation Graph Call With On Failure () ĊĊĠĠĠĠĠĠĠ Ġmock Session ( true ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . update Customer Settings ( true , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Customer Settings Should Return Content Error When Session Invalid () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Session ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback : ĠApi Callback < Unit > Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġapi . update Customer Settings ( true , Ġcallback ) ĊĊĠĠĠĠĠĠĠ Ġargument Captor < Error >(). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback , Ġnever ()). on Result ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( callback ). on Failure ( capture ()) ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertTrue ( first Value Ġis ĠError . Non Critical ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( Constant . UN AUTHORIZ ED _ ERROR , Ġfirst Value . message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }