package Ġde . kor ov in . countries . services Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . times Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify No More Interactions Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġde . kor ov in . countries . models . Country Ċ import Ġde . kor ov in . countries . persistence . Country Repository Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Inject Mocks Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . runners . Mockito JUnit Runner Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġaw 3 s 0 Ġon Ġ 1 0 / 1 0 / 2 0 1 7 . Ċ Ġ*/ Ċ @ RunWith ( Mockito JUnit Runner :: class ) Ċ class ĠCountry Service Test Ġ{ ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġrepository : ĠCountry Repository ĊĊĠĠĠ Ġ@ Inject Mocks ĊĠĠĠ Ġlateinit Ġvar Ġservice : ĠCountry Service ĊĊĠĠĠ Ġval Ġmany : ĠIterable < Country > Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCountry (" Country 1 ", Ġ" CT 1 "), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCountry (" Country 2 ", Ġ" CT 2 ") ĊĠĠĠ Ġ). as Iterable () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġfind Ġall Ġcountries `() Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( repository . findAll ()). thenReturn ( many ) ĊĠĠĠĠĠĠĠ Ġval Ġres Ġ= Ġservice . getAll () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( res ). has Size ( 2 ). contains ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmany . elementAt ( 0 ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmany . elementAt ( 1 )) ĊĠĠĠĠĠĠĠ Ġverify ( repository , Ġtimes ( 1 )). findAll () ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġempty Ġlist Ġwhen Ġrepository Ġis Ġempty `() Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( repository . findAll ()). thenReturn ( emptyList ()) ĊĠĠĠĠĠĠĠ Ġval Ġres Ġ= Ġservice . getAll () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( res ). isEmpty () ĊĠĠĠĠĠĠĠ Ġverify ( repository , Ġtimes ( 1 )). findAll () ĊĠĠĠĠĠĠĠ Ġverify No More Interactions ( repository ) ĊĠĠĠ Ġ} Ċ }