package Ġco . nim ble hq . sms for warder . domain . repository Ċ Ċ import Ġco . nim ble hq . sms for warder . data . service . ApiService Ċ import Ġco . nim ble hq . sms for warder . domain . test . Mock Util Ċ import Ġio . reactivex . Single Ċ import Ġorg . am sh ove . k lu ent .* Ċ import Ġorg . junit . Test Ċ import Ġretrofit 2 . Response Ċ Ċ class ĠApi Repository Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġexecute Ġforward Ġrequest Ġsuccessfully , Ġit Ġreturns Ġsuccess Ġresponse `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmock Service Ġ= Ġmock < ApiService >() ĊĠĠĠĠĠĠĠ ĠWhen Ġcalling Ġmock Service . forward ( any ()) Ġit Returns ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠSingle . just ( Response . success ( Mock Util . forward Response )) ĊĠĠĠĠĠĠĠ Ġval Ġrepository Ġ= ĠApi Repository Impl ( mock Service ) ĊĊĠĠĠĠĠĠĠ Ġval Ġtest Subscriber Ġ= Ġrepository . forward ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" incoming Number ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" message Body ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" email " ĊĠĠĠĠĠĠĠ Ġ). test () ĊĠĠĠĠĠĠĠ Ġtest Subscriber ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert No Errors () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Complete () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` When Ġexecute Ġforward Ġrequest Ġfailed , Ġit Ġreturns Ġwrapped Ġerror `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmock Service Ġ= Ġmock < ApiService >() ĊĠĠĠĠĠĠĠ ĠWhen Ġcalling Ġmock Service . forward ( any ()) Ġit Returns ĠSingle . error ( Throwable ()) ĊĠĠĠĠĠĠĠ Ġval Ġrepository Ġ= ĠApi Repository Impl ( mock Service ) ĊĊĠĠĠĠĠĠĠ Ġval Ġtest Subscriber Ġ= Ġrepository . forward ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" incoming Number ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" message Body ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" email " ĊĠĠĠĠĠĠĠ Ġ). test () ĊĠĠĠĠĠĠĠ Ġtest Subscriber ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Error ( Throwable :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Value Count ( 0 ) ĊĠĠĠ Ġ} Ċ } Ċ