package Ġcom . box . android sdk . share . utils ; Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġcom . box . android sdk . content . Box Exception Ċ import Ġcom . box . android sdk . content . models . Box Collabor ation Ċ import Ġcom . box . android sdk . content . models . Box Collabor ation Item Ċ import Ġcom . box . android sdk . content . models . Box Error Ċ import Ġcom . box . android sdk . content . requests . Box Requests Share Ċ import Ġcom . box . android sdk . content . requests . Box Response Ċ import Ġcom . box . android sdk . content . requests . Box Response Batch Ċ import Ġcom . box . android sdk . share . R Ċ import Ġcom . box . android sdk . share . internal . models . Box Iterator Invite es Ċ import Ġcom . box . android sdk . share . utils . Responses Creator . Companion . create Box Response Batch Ċ import Ġcom . box . android sdk . share . utils . Responses Creator . Companion . create Failure Response Ċ import Ġcom . box . android sdk . share . utils . Responses Creator . Companion . create Success Response Ċ 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 Ġjunit . framework . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test ; Ċ import Ġorg . junit . rules . Test Rule Ċ import Ġjavax . net . ssl . Https URLConnection Ċ Ċ class ĠShare SDK Transformer Test Ġ{ ĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġrule : ĠTest Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġprivate Ġval Ġmock Failed ToAdd Exception : ĠBox Exception Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġmock Http Forbidden Exception : ĠBox Exception Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġmock Box Network ErrorException : ĠBox Exception Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġmock Already Col lab Exception : ĠBox Exception Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġmock BadRequest Exception : ĠBox Exception Ġ= Ġmock () ĊĊĠĠĠ Ġprivate Ġval Ġmock Get Invite e Response : ĠBox Response < Box Iterator Invite es > Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġmock Fetch Roles Response : ĠBox Response < Box Collabor ation Item > Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġmock Invite Coll abs Response : ĠBox Response < Box Response Batch > Ġ= Ġmock () ĊĊĠĠĠ Ġprivate Ġval Ġmock Get Invite es Result : ĠBox Iterator Invite es Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġval Ġmock Fetch Role Item Result : ĠBox Collabor ation Item Ġ= Ġmock () ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock Invite Coll abs Result : ĠBox Response Batch ĊĠĠĠĠĊĠĠĠ Ġprivate Ġval Ġinvite Coll abs Transformer Ġ= ĠShare SDK Transformer () ĊĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate Exceptions () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Exceptions () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġwhenever ( mock Http Forbidden Exception . response Code ). thenReturn ( Https URLConnection . HTTP _ FOR BID DEN ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Box Network ErrorException . error Type ). thenReturn ( Box Exception . ErrorType . NETWORK _ ERROR ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbox Error Already Added : ĠBox Error Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( box Error Already Added . code ). thenReturn ( Box Requests Share . Add Collabor ation . ERROR _ CODE _ USER _ AL READY _ COLL AB OR ATOR ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Already Col lab Exception . as Box Error ). thenReturn ( box Error Already Added ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Already Col lab Exception . response Code ). thenReturn ( Https URLConnection . HTTP _ BAD _ REQUEST ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbox Error Failed ToAdd : ĠBox Error Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( box Error Failed ToAdd . code ). thenReturn ("") ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Failed ToAdd Exception . as Box Error ). thenReturn ( box Error Failed ToAdd ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Failed ToAdd Exception . response Code ). thenReturn ( Https URLConnection . HTTP _ BAD _ REQUEST ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock BadRequest Exception . response Code ). thenReturn ( Https URLConnection . HTTP _ BAD _ REQUEST ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġfetch Ġrole Ġsuccess `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Fetch Roles Response . is Success ). thenReturn ( true ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Fetch Roles Response . result ). thenReturn ( mock Fetch Role Item Result ) ĊĊĠĠĠĠĠĠĠ Ġ// make Ġa Ġnetwork Ġcall Ġto Ġfetch Ġroles ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Fetch Roles Item Presenter Data ( mock Fetch Roles Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult ?. is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( mock Fetch Role Item Result , Ġresult ?. data ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġfetch Ġrole Ġfailure `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Fetch Roles Response . is Success ). thenReturn ( false ) ĊĠĠĠĠĠĠĠ Ġval Ġexception : ĠBox Exception Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Fetch Roles Response . exception ). thenReturn ( exception ) ĊĠĠĠĠĠĠĠ Ġ// make Ġa Ġnetwork Ġcall Ġto Ġfetch Ġroles ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Fetch Roles Item Presenter Data ( mock Fetch Roles Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult ?. is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ network _ error , Ġresult ?. str Code ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite es Ġsuccess `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Get Invite e Response . is Success ). thenReturn ( true ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Get Invite e Response . result ). thenReturn ( mock Get Invite es Result ) ĊĊĠĠĠĠĠĠĠ Ġ// make Ġa Ġnetwork Ġcall Ġto Ġfetch Ġroles ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite es Presenter Data ( mock Get Invite e Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult ?. is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( mock Get Invite es Result , Ġresult ?. data ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite es Ġfailure Ġhttp Ġforbidden `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Get Invite e Response . is Success ). thenReturn ( false ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Get Invite e Response . exception ). thenReturn ( mock Http Forbidden Exception ) ĊĊĠĠĠĠĠĠĠ Ġ// make Ġa Ġnetwork Ġcall Ġto Ġfetch Ġroles ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite es Presenter Data ( mock Get Invite e Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult ?. is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ ins ufficient _ permissions , Ġresult ?. str Code ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite es Ġfailure Ġbox Ġnetwork Ġerror `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Get Invite e Response . is Success ). thenReturn ( false ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Get Invite e Response . exception ). thenReturn ( mock Box Network ErrorException ) ĊĊĠĠĠĠĠĠĠ Ġ// make Ġa Ġnetwork Ġcall Ġto Ġfetch Ġroles ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite es Presenter Data ( mock Get Invite e Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult ?. is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ network _ error , Ġresult ?. str Code ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġcoll abs Ġpresenter Ġdata Ġfor Ġsuccessful Ġrequest Ġwhere Ġresponse Ġsize Ġis Ġ 1 Ġand Ġaccessible Ġby Ġis Ġnot Ġnull `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" Box ĠUser " ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response ( dummy Name ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbox Responses Ġ= Ġcreate Box Response Batch ( box Response ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Presenter Data For Successful Request ( box Responses ) ĊĊĠĠĠĠĠĠĠ Ġ// compare Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ coll aborator _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( dummy Name , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġcoll abs Ġpresenter Ġdata Ġfor Ġsuccessful Ġrequest Ġwhere Ġresponse Ġsize Ġis Ġ 1 Ġand Ġaccessible Ġby Ġis Ġnull `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response ( dummy Name ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbox Responses Ġ= Ġcreate Box Response Batch ( box Response ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Presenter Data For Successful Request ( box Responses ) ĊĊĊĠĠĠĠĠĠĠ Ġ// compare Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ a _ coll aborator _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġcoll abs Ġpresenter Ġdata Ġfor Ġsuccessful Ġrequest Ġwhere Ġresponse Ġsize Ġis Ġgreater Ġthan Ġ 1 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" Box ĠUser " ĊĠĠĠĠĠĠĠ Ġval Ġbox Response : ĠBox Response < Box Collabor ation > Ġ= Ġcreate Success Response ( dummy Name ) ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 2 : ĠBox Response < Box Collabor ation > Ġ= Ġcreate Success Response ( dummy Name +" 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġbox Responses Ġ= Ġcreate Box Response Batch ( box Response , Ġbox Response 2 ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Presenter Data For Successful Request ( box Responses ) ĊĊĠĠĠĠĠĠĠ Ġ// compare Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ collabor ators _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġcoll abs Ġpresenter Ġdata Ġfor Ġfailed Ġrequest Ġwhere Ġfailed Coll abs List Ġis Ġnot Ġempty `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" already Ġadded Ġuser " ĊĠĠĠĠĠĠĠ Ġval Ġalready Added Count Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġval Ġfailed Coll abs Ġ= Ġarray ListOf < String >() ĊĠĠĠĠĠĠĠ Ġfailed Coll abs . add (" failure Ġ 1 ") ĊĠĠĠĠĠĠĠ Ġfailed Coll abs . add (" failure Ġ 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġres Ġ= Ġ" failure Ġ 1 Ġfailure Ġ 2 " ĊĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Presenter Data For Failed Request ( failed Coll abs , Ġdummy Name , Ġalready Added Count ) ĊĊĠĠĠĠĠĠĠ Ġ// compare Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ following _ collabor ators _ error , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( res , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġresult . already Add ded Count ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġcoll abs Ġpresenter Ġdata Ġfor Ġfailed Ġrequest Ġwhere Ġfailed Coll abs List Ġis Ġempty Ġand Ġalready Added Count Ġis Ġ 1 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" already Ġadded Ġuser " ĊĠĠĠĠĠĠĠ Ġval Ġalready Added Count Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġval Ġfailed Coll abs Ġ= Ġarray ListOf < String >() ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Presenter Data For Failed Request ( failed Coll abs , Ġdummy Name , Ġalready Added Count ) ĊĊĠĠĠĠĠĠĠ Ġ// compare Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ has _ already _ been _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( dummy Name , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) Ġ// request Ġfailing Ġonly Ġdue Ġto Ġadding Ġalready Ġadded Ġcoll abs Ġis Ġstill Ġconsidered Ġa Ġsuccess ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġresult . already Add ded Count ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġcoll abs Ġpresenter Ġdata Ġfor Ġfailed Ġrequest Ġwhere Ġfailed Coll abs List Ġis Ġempty Ġalready Added Count Ġis Ġgreater Ġthan Ġ 1 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" already Ġadded Ġuser " ĊĠĠĠĠĠĠĠ Ġval Ġalready Added Count Ġ= Ġ 2 ĊĠĠĠĠĠĠĠ Ġval Ġfailed Coll abs Ġ= Ġarray ListOf < String >() ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Presenter Data For Failed Request ( failed Coll abs , Ġdummy Name , Ġalready Added Count ) ĊĊĠĠĠĠĠĠĠ Ġ// compare Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ num _ has _ already _ been _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 2 ", Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) Ġ// request Ġfailing Ġonly Ġdue Ġto Ġadding Ġalready Ġadded Ġcoll abs Ġis Ġstill Ġconsidered Ġa Ġsuccess ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġresult . already Add ded Count ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġcoll abs Ġpresenter Ġdata Ġfor Ġfailed Ġrequest Ġwhere Ġfailed Coll abs List Ġis Ġempty Ġalready Added Count Ġis Ġ 0 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" already Ġadded Ġuser " ĊĠĠĠĠĠĠĠ Ġval Ġalready Added Count Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġval Ġfailed Coll abs Ġ= Ġarray ListOf < String >() ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Presenter Data For Failed Request ( failed Coll abs , Ġdummy Name , Ġalready Added Count ) ĊĊĠĠĠĠĠĠĠ Ġ// compare Ġvalues ĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ unable _ to _ invite , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . already Add ded Count ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġget Ġinvite Ġpresenter Ġdata Ġwhere Ġall Ġrequests Ġsucceed `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response (" user 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 2 Ġ= Ġcreate Success Response (" user 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 3 Ġ= Ġcreate Success Response (" user 3 ") ĊĠĠĠĠĠĠĠ Ġmock Invite Coll abs Result Ġ= Ġcreate Box Response Batch ( box Response , Ġbox Response 2 , Ġbox Response 3 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Invite Coll abs Response . result ). thenReturn ( mock Invite Coll abs Result ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite Coll abs Presenter Data From Box Response ( mock Invite Coll abs Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ collabor ators _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( null , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġadd Ġcol lab Ġ 1 Ġsucceed Ġno Ġfailure `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" Box ĠUser " ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response ( dummy Name ) ĊĠĠĠĠĠĠĠ Ġmock Invite Coll abs Result Ġ= Ġcreate Box Response Batch ( box Response ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Invite Coll abs Response . result ). thenReturn ( mock Invite Coll abs Result ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite Coll abs Presenter Data From Box Response ( mock Invite Coll abs Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ coll aborator _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( dummy Name , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġadd Ġcol lab Ġsucceed Ġ 1 Ġalready Ġadded Ġ 1 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġdummy Name Ġ= Ġ" user 2 " ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response (" user 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 2 Ġ= Ġcreate Failure Response ( dummy Name , Ġmock Already Col lab Exception ) ĊĠĠĠĠĠĠĠ Ġmock Invite Coll abs Result Ġ= Ġcreate Box Response Batch ( box Response , Ġbox Response 2 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Invite Coll abs Response . result ). thenReturn ( mock Invite Coll abs Result ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite Coll abs Presenter Data From Box Response ( mock Invite Coll abs Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ has _ already _ been _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( dummy Name , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġadd Ġcol lab Ġsucceed Ġ 1 Ġalready Ġadd Ġ 2 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response (" user 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 2 Ġ= Ġcreate Failure Response (" user 2 ", Ġmock Already Col lab Exception ) ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 3 Ġ= Ġcreate Failure Response (" user 3 ", Ġmock Already Col lab Exception ) ĊĠĠĠĠĠĠĠ Ġmock Invite Coll abs Result = Ġcreate Box Response Batch ( box Response , Ġbox Response 2 , Ġbox Response 3 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Invite Coll abs Response . result ). thenReturn ( mock Invite Coll abs Result ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite Coll abs Presenter Data From Box Response ( mock Invite Coll abs Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ num _ has _ already _ been _ inv ited , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals (" 2 ", Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġadd Ġcol lab Ġsucceed Ġ 1 Ġfailed Ġto Ġadd Ġ 1 Ġalready Ġadded Ġ 1 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġfailed Name Ġ= Ġ" user 2 " ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response (" user 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 2 Ġ= Ġcreate Failure Response ( failed Name , Ġmock Failed ToAdd Exception ) ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 3 Ġ= Ġcreate Failure Response (" user 3 ", Ġmock Already Col lab Exception ) ĊĠĠĠĠĠĠĠ Ġmock Invite Coll abs Result Ġ= Ġcreate Box Response Batch ( box Response , Ġbox Response 2 , Ġbox Response 3 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Invite Coll abs Response . result ). thenReturn ( mock Invite Coll abs Result ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite Coll abs Presenter Data From Box Response ( mock Invite Coll abs Response ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ following _ collabor ators _ error , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( failed Name , Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġadd Ġcol lab Ġsucceed Ġ 1 Ġfailed Ġto Ġadd Ġ 2 `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// configs ĊĠĠĠĠĠĠĠ Ġval Ġfailed Name 1 Ġ= Ġ" user 2 " ĊĠĠĠĠĠĠĠ Ġval Ġfailed Name 2 Ġ= Ġ" user 3 " ĊĠĠĠĠĠĠĠ Ġval Ġbox Response Ġ= Ġcreate Success Response (" user 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 2 Ġ= Ġcreate Failure Response ( failed Name 1 , Ġmock Failed ToAdd Exception ) ĊĠĠĠĠĠĠĠ Ġval Ġbox Response 3 Ġ= Ġcreate Failure Response ( failed Name 2 , Ġmock Failed ToAdd Exception ) ĊĠĠĠĠĠĠĠ Ġmock Invite Coll abs Result Ġ= Ġcreate Box Response Batch ( box Response , Ġbox Response 2 , Ġbox Response 3 ) ĊĠĠĠĠĠĠĠ Ġwhenever ( mock Invite Coll abs Response . result ). thenReturn ( mock Invite Coll abs Result ) ĊĊĠĠĠĠĠĠĠ Ġ// process Ġrequest ĊĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġinvite Coll abs Transformer . get Invite Coll abs Presenter Data From Box Response ( mock Invite Coll abs Response ) ĊĊĊĠĠĠĠĠĠĠ ĠassertEquals ( R . string . box _ shares dk _ following _ collabor ators _ error , Ġresult . str Code ) ĊĠĠĠĠĠĠĠ ĠassertEquals ("$ failed Name 1 Ġ$ failed Name 2 ", Ġresult . data ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( false , Ġresult . is Success ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġresult . is Sn ackBar Message ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġresult . already Add ded Count ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ