package Ġcom . app ify hub . mon ol ith . repository . geo Ċ Ċ import Ġassert k . assertThat Ċ import Ġassert k . assertions . is Data Class EqualTo Ċ import Ġassert k . assertions . isNotNull Ċ import Ġassert k . assertions . isNull Ċ import Ġcom . app ify hub . mon ol ith . storage . dao . Geo location Dao Ċ import Ġcom . app ify hub . mon ol ith . util . Stub s Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . kotlin . any Ċ import Ġorg . mockito . kotlin . do Return Ċ import Ġorg . mockito . kotlin . do Throw Ċ import Ġorg . mockito . kotlin . mock Ċ import Ġorg . mockito . kotlin . stub Ċ Ċ class ĠGeo location Repository Impl Test Ġ{ ĊĊĠ Ġprivate Ġval Ġgeo location Dao Ġ= Ġmock < Geo location Dao >() ĊĊĠ Ġprivate Ġval Ġrepository : ĠGeo location Repository Ġ= ĠGeo location Repository Impl ( ĊĠĠĠ Ġgeo location Dao Ġ= Ġgeo location Dao , ĊĠ Ġ) ĊĊĠ Ġ@ Test Ġfun Ġ` repository Ġreturns Ġnull Ġwhen ĠIP Ġis Ġnull `() Ġ{ ĊĠĠĠ ĠassertThat ( repository . fetch Geo location For Ip ( null )) ĊĠĠĠĠĠ Ġ. isNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` repository Ġreturns Ġnull Ġwhen Ġdao Ġthrows `() Ġ{ ĊĠĠĠ Ġgeo location Dao . stub Ġ{ ĊĠĠĠĠĠ Ġon Ġ{ Ġfetch Geo location For Ip ( any ()) Ġ} Ġdo Throw ĠIllegalArgumentException (" failed ") ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠassertThat ( repository . fetch Geo location For Ip (" 5 . 4 . 3 . 2 ")) ĊĠĠĠĠĠ Ġ. isNull () ĊĠ Ġ} ĊĊĠ Ġ@ Test Ġfun Ġ` repository Ġreturns Ġnull Ġwhen Ġdao Ġhas Ġa Ġresult `() Ġ{ ĊĠĠĠ Ġgeo location Dao . stub Ġ{ ĊĠĠĠĠĠ Ġon Ġ{ Ġfetch Geo location For Ip ( any ()) Ġ} Ġdo Return ĠStub s . geo ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠassertThat ( repository . fetch Geo location For Ip (" 5 . 4 . 3 . 2 ")) ĊĠĠĠĠĠ Ġ. isNotNull () ĊĠĠĠĠĠ Ġ. is Data Class EqualTo ( Stub s . geo ) ĊĠ Ġ} Ċ Ċ } Ċ