package Ġcom . test with spring . master . user Ċ Ċ import Ġcom . github . spring test db unit . annotation . Database Setup Ċ import Ġcom . github . spring test db unit . annotation . Db Unit Configuration Ċ import Ġcom . github . spring test db unit . dataset . Replacement DataSet Loader Ċ import Ġcom . test with spring . master . Database IntegrationTest Ċ import Ġcom . test with spring . master . Users Ċ import Ġorg . assertj . core . api . Assertions . assertThat Thrown By Ċ import Ġorg . assertj . core . api . Soft Assertions Ċ import Ġorg . assertj . core . api . junit . jupiter . Soft Assertions Extension Ċ import Ġorg . junit . jupiter . api . DisplayName Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . extension . Extend With Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . security . core . authority . Simple Granted Authority Ċ import Ġorg . springframework . security . core . user details . UserDetails Service Ċ import Ġorg . springframework . security . core . user details . Username NotFoundException Ċ Ċ @ Database IntegrationTest Ċ @ Extend With ( Soft Assertions Extension :: class ) Ċ @ Database Setup ( value Ġ= Ġ[ ĊĠĠĠ Ġ"/ com / test with spring / master / users . xml ", ĊĠĠĠ Ġ"/ com / test with spring / master / no - tasks - and - tags . xml " Ċ ]) Ċ @ Db Unit Configuration ( data Set Loader Ġ= ĠRe placement DataSet Loader :: class ) Ċ @ DisplayName (" Load Ġuser Ġby Ġusing Ġusername Ġas Ġsearch Ġcriteria ") Ċ class ĠLoad User By Username Test (@ Autowired Ġprivate Ġval Ġuser Details Service : ĠUser Details Service ) Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Should Ġthrow Ġan Ġexception Ġwhen Ġno Ġuser Ġis Ġfound ") ĊĠĠĠ Ġfun Ġshould Throw Exception When No User Is Found () Ġ{ ĊĠĠĠĠĠĠĠ ĠassertThat Thrown By Ġ{ Ġuser Details Service . load User By Username ( Users . EMAIL _ ADDRESS _ NOT _ FOUND ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. is Exactly InstanceOf ( Username NotFoundException :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ DisplayName (" Should Ġreturn Ġthe Ġcorrect Ġuser Ġwhen Ġuser Ġis Ġfound ") ĊĠĠĠ Ġfun Ġshould Return Correct User When User Is Found ( assertions : ĠSoft Assertions ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfound Ġ= Ġuser Details Service . load User By Username ( Users . John Do e . EMAIL _ ADDRESS ) Ġas ĠLog ged In User ĊĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" id ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqual By Comp aring To ( Users . John Do e . ID ) ĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . username ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" username ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Users . John Do e . EMAIL _ ADDRESS ) ĊĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . author ities ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" author ities ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. contains Exactly ( Simple Granted Authority ( Users . John Do e . ROLE . name )) ĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . role ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" role ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Users . John Do e . ROLE ) ĊĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . is Account Non Expired ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" is Account Non Expired ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isTrue ĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . is Account Non Locked ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" is Account Non Locked ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isTrue ĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . is Credentials Non Expired ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" is Credentials Non Expired ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isTrue ĊĊĠĠĠĠĠĠĠ Ġassertions . assertThat ( found . password ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. ` as ` (" password ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( Users . John Do e . PASSWORD ) ĊĠĠĠ Ġ} Ċ }