package Ġbe . sw sb . eff it . domain . query . comp etition Ċ Ċ import Ġbe . sw sb . eff it . adapter . sql . comp etition . Comp etition Repository Ċ import Ġbe . sw sb . eff it . domain . core . comp etition . Comp etition Ċ import Ġbe . sw sb . eff it . domain . core . comp etition . Comp etition Id Ċ import Ġbe . sw sb . eff it . domain . core . comp etition . default Comp etition For Test Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . junit . jupiter . Mockito Extension Ċ Ċ @ Extend With ( Mockito Extension :: class ) Ċ class ĠMaybe Find Comp etition Query Handler Test Ġ{ ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcompetition Repository Mock : ĠComp etition Repository ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġhandler : ĠMaybe Find Comp etition Query Handler ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġhandler Ġ= ĠMaybe Find Comp etition Query Handler ( comp etition Repository Mock ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` handle Ġ| Ġcompetition Ġfound Ġreturn Ġcompetition `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgiven Comp etition Id Ġ= ĠComp etition Id (" Th under cats ") ĊĠĠĠĠĠĠĠ Ġval Ġexpected Comp etition Ġ= ĠComp etition . default Comp etition For Test () ĊĠĠĠĠĠĠĠ Ġ` when `( comp etition Repository Mock . findBy Comp etition Identifier ( given Comp etition Id )). thenReturn ( expected Comp etition ) ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġhandler . handle ( Maybe Find Comp etition ( given Comp etition Id )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual ). isEqualTo ( expected Comp etition ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` handle Ġ| Ġno Ġcompetition Ġfound Ġreturns Ġnull `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgiven Comp etition Id Ġ= ĠComp etition Id (" Th under cats ") ĊĠĠĠĠĠĠĠ Ġ` when `( comp etition Repository Mock . findBy Comp etition Identifier ( given Comp etition Id )). thenReturn ( null ) ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Ġ= Ġhandler . handle ( Maybe Find Comp etition ( given Comp etition Id )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( actual ). isNull () ĊĠĠĠ Ġ} Ċ } Ċ