package Ġcom . azure . data . integration . off lin et ests Ċ Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġcom . azure . core . http . HttpStatusCode Ċ import Ġcom . azure . data . Azure Data Ċ import Ġcom . azure . data . integration . common . Custom Document Ċ import Ġcom . azure . data . integration . common . Document Test Ċ import Ġcom . azure . data . integration . common . Partition ed Custom Doc ment Ċ import Ġcom . azure . data . model . Database Ċ import Ġcom . azure . data . model . service . Data Response Ċ import Ġcom . azure . data . model . service . ListResponse Ċ import Ġcom . azure . data . model . service . Response Ċ import Ġorg . junit . Test Ċ import Ġorg . await ility . Await ility .* Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . Assert .* Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠOff line Write Tests : ĠDocument Test < Partition ed Custom Doc ment >(" Offline Write Tests ", ĠPartition ed Custom Doc ment :: class . java , Ġfalse , Ġfalse ) Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġresources Are Created Loc ally When The Network IsNot Reach able () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġturn Off Internet Connection () ĊĊĠĠĠĠĠĠĠ Ġvar Ġlist Response : ĠList Response < Database >? Ġ= Ġnull ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġtry Create Database () ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( response !!. is Successful ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( response . from Cache ) ĊĊĠĠĠĠĠĠĠ ĠAzure Data . get Databases Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlist Response Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġawait (). until Ġ{ Ġlist Response Ġ!= Ġnull Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( list Response !!. is Successful ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( list Response !!. from Cache ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( list Response !!. resource ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( list Response !!. resource !!. items . any Ġ{ Ġit . id Ġ== Ġdatabase Id Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġconflict Is Returned When The Same Resource Is Created Tw ice Offline () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġturn Off Internet Connection () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġtry Create Database () ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( response !!. is Successful ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( response . from Cache ) ĊĊĠĠĠĠĠĠĠ Ġval Ġconflict Response Ġ= Ġtry Create Database () ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( conflict Response !!. is Er rored ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( conflict Response . from Cache ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( conflict Response . response ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( HttpStatusCode . Conflict . code , Ġconflict Response . response !!. code ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnot Found Is Returned When Trying To Replace AN on Existing Resource While Offline () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġturn Off Internet Connection () ĊĊĠĠĠĠĠĠĠ Ġtry Create Database () ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġtry Create Collection () ĊĠĠĠĠĠĠĠ Ġvar Ġreplace Response : ĠResponse < Custom Document >? Ġ= Ġnull ĊĊĠĠĠĠĠĠĠ Ġcollection Ġ= Ġresponse !!. resource !! ĊĊĠĠĠĠĠĠĠ ĠAzure Data . replace Document ( Custom Document ( document Id ), Ġcollection !! ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreplace Response Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġawait (). until Ġ{ Ġreplace Response Ġ!= Ġnull Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( replace Response !!. is Er rored ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( replace Response !!. from Cache ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( replace Response !!. response ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( HttpStatusCode . NotFound . code , Ġreplace Response !!. response !!. code ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnot Found Is Returned When Trying ToDelete AN on Existing Resource () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġturn Off Internet Connection () ĊĊĠĠĠĠĠĠĠ Ġvar Ġdelete Response : ĠData Response ? Ġ= Ġnull ĊĊĠĠĠĠĠĠĠ ĠAzure Data . delete Database ( database Id ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelete Response Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġawait (). until Ġ{ Ġdelete Response Ġ!= Ġnull Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( delete Response !!. is Er rored ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( delete Response !!. from Cache ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( delete Response !!. response ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( HttpStatusCode . NotFound . code , Ġdelete Response !!. response !!. code ) ĊĠĠĠ Ġ} Ċ }