package Ġbe . sw sb . eff it . domain . command . 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 Ġbe . sw sb . eff it . domain . core . comp etition . find Challenge Ċ import Ġbe . sw sb . eff it . domain . query . comp etition . Find Comp etition Ċ import Ġbe . sw sb . eff it . messaging . query . Query Executor Ċ 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 . Argument Matchers . any Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġorg . mockito . junit . jupiter . Mockito Extension Ċ Ċ @ Extend With ( Mockito Extension :: class ) Ċ class ĠRemove Challenge CommandHandler Test Ġ{ ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġquery Executor : ĠQuery Executor ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcompetition Repository : ĠComp etition Repository ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġhandler : ĠRemove Challenge CommandHandler ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġhandler Ġ= ĠRemove Challenge CommandHandler ( query Executor , Ġcompetition Repository ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` handle Ġ| Ġshould Ġremove Ġthe Ġgiven Ġchallenge Ġid `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġgiven Comp etition Id Ġ= Ġ" Snow Case 2 0 1 8 " ĊĠĠĠĠĠĠĠ Ġval Ġcompetition Id Ġ= ĠComp etition Id ( given Comp etition Id ) ĊĊĠĠĠĠĠĠĠ Ġval Ġchallenge That Will Get Deleted Ġ= ĠChallenge ToAdd . default Challenge ToAdd For Test ( name Ġ= Ġ" Challenge ToBe Deleted ") ĊĠĠĠĠĠĠĠ Ġval Ġsome Other Challenge Ġ= ĠChallenge ToAdd . default Challenge ToAdd For Test ( name Ġ= Ġ" Pic asso ") ĊĠĠĠĠĠĠĠ Ġval Ġsome Comp etition Ġ= ĠComp etition . default Comp etition For Test ( challenges Ġ= ĠlistOf ( challenge That Will Get Deleted , Ġsome Other Challenge )) ĊĠĠĠĠĠĠĠ Ġval Ġchallenge Expected ToBe Deleted Ġ= Ġsome Comp etition . find Challenge (" Challenge ToBe Deleted ") ĊĠĠĠĠĠĠĠ Ġval Ġgiven Challenge Id Ġ= Ġchallenge Expected ToBe Deleted . id ĊĊĠĠĠĠĠĠĠ Ġ` when ĠfindBy Comp etition Identifier Ġthen Ġreturn `( comp etition Id , Ġsome Comp etition ) ĊĠĠĠĠĠĠĠ Ġ` when `( comp etition Repository . save ( any ( Comp etition :: class . java ))). thenReturn ( some Comp etition ) ĊĊĠĠĠĠĠĠĠ Ġhandler . handle ( Remove Challenge ( comp etition Id , Ġgiven Challenge Id )) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( some Comp etition . challenges ). does Not Contain ( challenge Expected ToBe Deleted ) ĊĠĠĠĠĠĠĠ Ġverify ( comp etition Repository ). save ( some Comp etition ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġ` when ĠfindBy Comp etition Identifier Ġthen Ġreturn `( given Comp etition Id : ĠComp etition Id , Ġsome Comp etition : ĠComp etition ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ` when `( query Executor . execute ( Find Comp etition ( given Comp etition Id ))). thenReturn ( some Comp etition ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ