package Ġcom . pr ash an th . sample app . presenter Ċ Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . argument Captor Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Ċ import Ġcom . pr ash an th . sample app . contracts . API Contract Ċ import Ġcom . pr ash an th . sample app . model . User Model Ċ import Ġjunit . framework . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito . times Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġorg . mockito . junit . Mockito JUnit Runner Ċ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠUser Model Search Presenter Impl Test Ġ{ ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview : ĠAPI Contract . User Model Search Filter View ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġ@ Before ĊĠĠĠĠĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠĠĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Search String Is Present InThe List () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpresenter Ġ= ĠUser Model Search Presenter Impl (" title 1 ") ĊĠĠĠĠĠĠĠ Ġpresenter . filter Title Results (" title 1 ", Ġuser Model List (), Ġview ) ĊĠĠĠĠĠĠĠ Ġargument Captor < ArrayList < User Model >> (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( view , Ġtimes ( 1 )). on Filter Applied ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( 1 , Ġall Values . size ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals (" Some Ġrandom Ġtitle 1 ", Ġall Values [ 0 ][ 0 ]. title ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Search String IsNot Present InThe List () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpresenter Ġ= ĠUser Model Search Presenter Impl (" ok ") ĊĠĠĠĠĠĠĠ Ġpresenter . filter Title Results (" ok ", Ġuser Model List (), Ġview ) ĊĠĠĠĠĠĠĠ Ġargument Captor < ArrayList < User Model >> (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġverify ( view , Ġtimes ( 1 )). on Filter Applied ( capture ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( 0 , Ġall Values [ 0 ]. size ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġprivate Ġfun Ġuser Model List (): ĠArrayList < User Model > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmodel 1 Ġ= ĠUser Model ( 1 , Ġ 1 2 3 4 , Ġ" Some Ġrandom Ġtitle 1 ", Ġ" Some Ġrandom Ġbody 1 ") ĊĠĠĠĠĠĠĠ Ġval Ġmodel 2 Ġ= ĠUser Model ( 2 , Ġ 1 2 3 4 5 , Ġ" Some Ġrandom Ġtitle 2 ", Ġ" Some Ġrandom Ġbody 2 ") ĊĠĠĠĠĠĠĠ Ġval Ġmodel List Ġ= ĠArrayList < User Model >() ĊĠĠĠĠĠĠĠ Ġmodel List . add ( model 1 ) ĊĠĠĠĠĠĠĠ Ġmodel List . add ( model 2 ) ĊĠĠĠĠĠĠĠ Ġreturn Ġmodel List ĊĠĠĠ Ġ} Ċ }