package Ġcom . merc ad ol iv ro . events . listener čĊč Ċ import Ġcom . merc ad ol iv ro . events . Purchase Event č Ċ import Ġcom . merc ad ol iv ro . helper . build Purchase č Ċ import Ġcom . merc ad ol iv ro . service . Purchase Service č Ċ import Ġio . mock k .* č Ċ import Ġio . mock k . impl . annotations . Inject Mock Ks č Ċ import Ġio . mock k . impl . annotations . Mock K č Ċ import Ġio . mock k . junit 5 . Mock K Extension č Ċ import Ġorg . junit . jupiter . api . Assertions .* č Ċ import Ġorg . junit . jupiter . api . Test č Ċ import Ġorg . junit . jupiter . api . extension . Extend With č Ċ import Ġjava . util .* čĊč Ċ @ Extend With ( Mock K Extension :: class ) č Ċ class ĠGenerate N fe Listener Test Ġ{ čĊčĊĠĠĠ Ġ@ Mock K čĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpurchase Service : ĠPurchase Service čĊčĊĠĠĠ Ġ@ Inject Mock Ks čĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġgenerate N fe Listener : ĠGenerate N fe Listener čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġ` should Ġgenerate Ġn fe `() Ġ{ čĊĠĠĠĠĠĠĠ Ġval Ġpurchase Ġ= Ġbuild Purchase ( n fe Ġ= Ġnull ) čĊĠĠĠĠĠĠĠ Ġval Ġfake N fe Ġ= ĠUUID . randomUUID () čĊĠĠĠĠĠĠĠ Ġval Ġpurchase Expected Ġ= Ġpurchase . copy ( n fe Ġ= Ġfake N fe . toString ()) čĊĠĠĠĠĠĠĠ Ġmock k Static ( UUID :: class ) čĊčĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠUUID . randomUUID () Ġ} Ġreturns Ġfake N fe čĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġpurchase Service . update ( purchase Expected ) Ġ} Ġjust Ġruns čĊčĊĠĠĠĠĠĠĠ Ġgenerate N fe Listener . listen ( Purchase Event ( this , Ġpurchase )) čĊčĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġpurchase Service . update ( purchase Expected ) Ġ} čĊĠĠĠ Ġ} čĊč Ċ }