package Ġcom . s rg . c iti box . post _ list . domain . use case Ċ Ċ import Ġcom . s rg . c iti box . common . TestData Ċ import Ġcom . s rg . c iti box . common . data . model . Post Ċ import Ġcom . s rg . c iti box . common . data . network . ret rofit . Client Api Ċ import Ġcom . s rg . c iti box . post _ list . data . datasource . Cloud Post List DataSource Ċ import Ġcom . s rg . c iti box . post _ list . data . repository . Post List Data Repository Ċ import Ġcom . s rg . c iti box . post _ list . domain . repository . Post List Repository Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito Ċ import Ġretrofit 2 . Response Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠSeb ast i Ã¡n ĠRod r ÃŃ gue z Ġon Ġ 1 8 , January , 2 0 2 0 Ċ Ġ*/ Ċ Ċ class ĠGetAll Post List Test : ĠTest Data () Ġ{ ĊĊĠĠĠ Ġlateinit Ġvar Ġcloud Post List DataSource : ĠCloud Post List DataSource ĊĠĠĠ Ġlateinit Ġvar Ġpost List Repository : ĠPost List Repository ĊĊĠĠĠ Ġlateinit Ġvar ĠgetAll Post List : ĠGetAll Post List ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġexpected Response : ĠResponse < List < Post >> ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit () Ġ{ ĊĠĠĠĠĠĠĠ Ġcloud Post List DataSource Ġ= ĠCloud Post List DataSource ( client Api ) ĊĠĠĠĠĠĠĠ Ġpost List Repository Ġ= ĠPost List Data Repository ( cloud Post List DataSource ) ĊĊĠĠĠĠĠĠĠ ĠgetAll Post List Ġ= ĠGetAll Post List ( post List Repository ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` get Ġpost Ġlist Ġsuccessful Ġresponse `() Ġ= Ġrun Blocking Ġ{ ĊĊĠĠĠĠĠĠĠ Ġexpected Response Ġ= ĠResponse . success ( 2 0 0 , Ġmock Post List ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( client Api . getAll Posts ()). thenReturn ( expected Response ) ĊĊĠĠĠĠĠĠĠ ĠgetAll Post List . getAll Post List Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals ( it . is Failure , Ġfalse ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals ( it . is Success , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` get Ġpost Ġlist Ġerror Ġresponse `() Ġ= Ġrun Blocking Ġ{ ĊĊĠĠĠĠĠĠĠ Ġexpected Response Ġ= Ġresponse Error Post ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( client Api . getAll Posts ()). thenReturn ( expected Response ) ĊĊĠĠĠĠĠĠĠ ĠgetAll Post List . getAll Post List Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals ( it . is Failure , Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals ( it . is Success , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ċ Ċ }