package Ġio . hol unda . poly flow . view . jpa . process Ċ Ċ import Ġio . hol unda . poly flow . view . Process InstanceState Ċ import Ġio . hol unda . poly flow . view . jpa . it est . Mock Query Emitter Configuration Ċ import Ġio . hol unda . poly flow . view . jpa . it est . Test Application Data Jpa Ċ import Ġio . hol unda . poly flow . view . jpa . process . Process Instance Repository . Companion . has States Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . orm . jpa . Data Jpa Test Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ import Ġjava . util .* Ċ import Ġjavax . persistence . EntityManager Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ Data Jpa Test Ċ @ Context Configuration ( classes Ġ= Ġ[ Test Application Data Jpa :: class ]) Ċ @ Active Profiles (" it est ", Ġ" mock - query - emitter ") Ċ class ĠProcess Instance Repository ITest Ġ{ ĊĠ Ġ@ Autowired ĊĠ Ġlateinit Ġvar Ġentity Manager : ĠEntity Manager ĊĠ Ġ@ Autowired ĊĠ Ġlateinit Ġvar Ġprocess Instance Repository : ĠProcess Instance Repository ĊĊĠ Ġlateinit Ġvar Ġprocess Instance : ĠProcess Instance Entity ĊĊĠ Ġ@ Before ĊĠ Ġfun Ġ` insert Ġentity `() Ġ{ ĊĊĠĠĠ Ġval Ġid Ġ= ĠUUID . randomUUID (). toString () ĊĊĠĠĠ Ġprocess Instance Ġ= ĠProcess Instance Entity ( ĊĠĠĠĠĠ Ġprocess InstanceId Ġ= Ġid , ĊĠĠĠĠĠ Ġbusiness Key Ġ= Ġ" business Key ", ĊĠĠĠĠĠ Ġsuper InstanceId Ġ= Ġnull , ĊĠĠĠĠĠ ĠstartActivity Id Ġ= Ġ" start ", ĊĠĠĠĠĠ Ġstart UserId Ġ= Ġ" ker mit ", ĊĠĠĠĠĠ Ġsource Reference Ġ= ĠSource Reference Embed d able ( ĊĠĠĠĠĠĠĠ Ġinstance Id Ġ= Ġid , ĊĠĠĠĠĠĠĠ Ġexecution Id Ġ= ĠUUID . randomUUID (). toString (), ĊĠĠĠĠĠĠĠ Ġdefinition Id Ġ= Ġ" my - process - def - key : 1 3 ", ĊĠĠĠĠĠĠĠ Ġdefinition Key Ġ= Ġ" my - process - def - key ", ĊĠĠĠĠĠĠĠ Ġname Ġ= Ġ" My Ġprocess ", ĊĠĠĠĠĠĠĠ Ġapplication Name Ġ= Ġ" test - application ", ĊĠĠĠĠĠĠĠ Ġtenant Id Ġ= Ġnull , ĊĠĠĠĠĠĠĠ Ġsource Type Ġ= Ġ" PROCESS " ĊĠĠĠĠĠ Ġ), ĊĠĠĠĠĠ Ġstate Ġ= ĠProcess InstanceState . RUNNING , ĊĠĠĠĠĠ Ġdelete Reason Ġ= Ġnull , ĊĠĠĠĠĠ Ġend Activity Id Ġ= Ġnull ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġentity Manager . persist ( process Instance ) ĊĠĠĠ Ġentity Manager . flush () ĊĠ Ġ} ĊĊĠ Ġ@ After ĊĠ Ġfun Ġ` clean Ġup `() Ġ{ ĊĠĠĠ Ġprocess Instance Repository . delete All () ĊĠĠĠ Ġentity Manager . flush () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġfind Ġprocess Ġinstance Ġby Ġid `() Ġ{ ĊĠĠĠ Ġval Ġresponse Ġ= Ġprocess Instance Repository . findById ( process Instance . process InstanceId ) ĊĊĠĠĠ ĠassertThat ( response ). isNotEmpty ĊĠĠĠ ĠassertThat ( response . get ()). isEqualTo ( process Instance ) ĊĊĠĠĠ Ġval Ġempty Ġ= Ġprocess Instance Repository . findById (" not - exists ") ĊĠĠĠ ĠassertThat ( empty ). isEmpty ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġfind Ġprocess Ġinstance Ġby Ġstate `() Ġ{ ĊĠĠĠ Ġval Ġresponse Ġ= Ġprocess Instance Repository . findAll ( has States ( set Of ( Process InstanceState . RUNNING ))) ĊĊĠĠĠ ĠassertThat ( response ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( response [ 0 ]). isEqualTo ( process Instance ) ĊĊĠĠĠ Ġval Ġempty Ġ= Ġprocess Instance Repository . findAll ( has States ( set Of ( Process InstanceState . SUS PEN DED ))) ĊĠĠĠ ĠassertThat ( empty ). isEmpty () ĊĠ Ġ} Ċ Ċ } Ċ