package Ġcom . checkout . android _ sdk . Presenter Ċ Ċ import Ġcom . checkout . android _ sdk . Store . DataStore Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . BDD Mockito . given Ċ import Ġorg . mockito . BDD Mockito . then Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . junit . Mockito JUnit Runner ĊĊ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠC vv Input Presenter Test Ġ{ ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdata Store : ĠData Store ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview Mock : ĠC vv Input Presenter . C vv Input View ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpresenter : ĠC vv Input Presenter ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠinitialState : ĠC vv Input Presenter . C vv Input Ui State ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġon Setup () Ġ{ ĊĠĠĠĠĠĠĠ ĠinitialState Ġ= ĠC vv Input Presenter . C vv Input Ui State (" 1 2 ", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġpresenter Ġ= ĠC vv Input Presenter ( data Store , ĠinitialState ) ĊĠĠĠĠĠĠĠ Ġpresenter . start ( view Mock ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` given Ġcv v Ġupdated Ġshow Ġthe Ġnew Ġvalue `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected State Ġ= ĠC vv Input Presenter . C vv Input Ui State (" 3 4 ", Ġfalse ) ĊĠĠĠĠĠĠĠ Ġpresenter . input StateChanged ( expected State . cv v ) ĊĊĠĠĠĠĠĠĠ Ġthen ( view Mock ). should (). on State Updated ( expected State ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` given Ġcv v Ġfocus Ġupdated Ġand Ġit Ġhas Ġan Ġerror Ġthen Ġerror Ġshould Ġbe Ġshown `() Ġ{ ĊĠĠĠĠĠĠĠ Ġgiven ( data Store . cv v Length ). willReturn ( 3 ) ĊĠĠĠĠĠĠĠ Ġpresenter . focus Changed ( false ) ĊĊĠĠĠĠĠĠĠ Ġthen ( view Mock ). should (). on State Updated ( initialState . copy ( show Error Ġ= Ġtrue )) ĊĠĠĠ Ġ} Ċ Ċ } Ċ