package Ġuk . gov . just ice . digital . h mp ps . pec s . j pc . location Ċ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . Assertions . assertThat Thrown By Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . orm . jpa . Data Jpa Test Ċ import Ġorg . springframework . boot . test . autoconfigure . orm . jpa . Test EntityManager Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġjavax . validation . Constraint Violation Exception Ċ Ċ @ Active Profiles (" test ") Ċ @ Data Jpa Test Ċ internal Ġclass ĠLocation Repository Test Ġ{ ĊĊĠ Ġ@ Autowired ĊĠ Ġlateinit Ġvar Ġrepository : ĠLocation Repository ĊĊĠ Ġ@ Autowired ĊĠ Ġlateinit Ġvar Ġentity Manager : ĠTest EntityManager ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` can Ġsave Ġlocation `() Ġ{ ĊĠĠĠ Ġval Ġlocation Ġ= Ġrepository . save ( Location ( Location Type . PR , Ġ" agency Ġid ", Ġ" site Ġname ")) ĊĊĠĠĠ Ġentity Manager . flush () ĊĊĠĠĠ ĠassertThat ( repository . findById ( location . id ). orElse Throw ()). isEqualTo ( location ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġthrow Ġconstraint Ġviolation Ġif Ġfields Ġempty `() Ġ{ ĊĠĠĠ ĠassertThat Thrown By Ġ{ ĊĠĠĠĠĠ Ġrepository . save ( Location ( Location Type . PR , Ġ"", Ġ"")) ĊĠĠĠĠĠ Ġentity Manager . flush () ĊĠĠĠ Ġ}. isInstanceOf ( Constraint Violation Exception :: class . java ) ĊĠ Ġ} Ċ } Ċ