package Ġlt . code dict ed . eg z amin ai . backend . unit . controller . mat urity Ċ Ċ import Ġio . mock k .* Ċ import Ġio . mock k . impl . annotations . Mock K Ċ import Ġio . mock k . junit 5 . Mock K Extension Ċ import Ġlt . code dict ed . eg z amin ai . backend . controller . mat urity . Mat urity Course Credit Controller Ċ import Ġlt . code dict ed . eg z amin ai . core . model . mat urity . Mat urity Course Credit Ċ import Ġlt . code dict ed . eg z amin ai . core . service . mat urity . Mat urity Course Credit Service Ċ import Ġorg . junit . jupiter . api . Assertions . assertEquals Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ Ċ @ Extend With ( Mock K Extension :: class ) Ċ class ĠMat urity Course Credit Controller Test Ġ{ ĊĊĊĠĠĠ Ġ@ Mock K ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġservice : ĠMat urity Course Credit Service ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcontroller : ĠMat urity Course Credit Controller ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġcontroller Ġ= ĠMat urity Course Credit Controller ( service ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Retrie ves Ġcourse Ġcredits `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Credits Ġ= ĠlistOf ( Mat urity Course Credit (" id ", Ġ" user ", Ġ 2 0 2 0 , Ġ" url ")) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġservice . getC red its () Ġ} Ġreturns Ġexpected Credits ĊĊĠĠĠĠĠĠĠ Ġval Ġactual Credits Ġ= Ġcontroller . getC red its () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( expected Credits , Ġactual Credits ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` S aves Ġcredit `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Credit Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMat urity Course Credit (" id ", Ġ" user ", Ġ 2 0 2 0 , Ġ" url ") ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġservice . save ( any ()) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġcontroller . save ( expected Credit ) ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġservice . save ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Updates Ġcredit `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Credit Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMat urity Course Credit (" id ", Ġ" user ", Ġ 2 0 2 0 , Ġ" url ") ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġservice . update ( expected Credit ) Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġcontroller . update ( expected Credit ) ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġservice . update ( expected Credit ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Deletes Ġcredit `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġservice . delete (" id ") Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġcontroller . delete (" id ") ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġservice . delete (" id ") Ġ} ĊĠĠĠ Ġ} Ċ Ċ } Ċ