package Ġuk . gov . just ice . digital . h mp ps . manager ec alls api . integration . documents Ċ Ċ import Ġcom . nat pr y ce . ham k rest . assertion . assertThat Ċ import Ġcom . nat pr y ce . ham k rest . equalTo Ċ import Ġorg . junit . jupiter . api . After All Ċ import Ġorg . junit . jupiter . api . Before All Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . Test Instance Ċ import Ġorg . junit . jupiter . api . Test Instance . Lifecycle . PER _ CLASS Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . boot . test . context . SpringBootTest . Web Environment . RANDOM _ PORT Ċ import Ġorg . springframework . core . io . Class Path Resource Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġuk . gov . just ice . digital . h mp ps . manager ec alls api . documents . ImageData . Companion . recall Image Ċ import Ġuk . gov . just ice . digital . h mp ps . manager ec alls api . documents . Pdf Document Generation Service Ċ import Ġuk . gov . just ice . digital . h mp ps . manager ec alls api . documents . Re call Image . Rev ocation Order Logo Ċ import Ġuk . gov . just ice . digital . h mp ps . manager ec alls api . integration . mock servers . Got en berg Mock Server Ċ import Ġuk . gov . just ice . digital . h mp ps . manager ec alls api . random . random String Ċ Ċ @ SpringBootTest ( web Environment Ġ= ĠR AN DOM _ PORT ) Ċ @ Active Profiles (" test ") Ċ @ Test Instance ( PER _ CLASS ) Ċ class ĠPdf Document Generator Mock Server IntegrationTest Ġ{ ĊĊĠ Ġ@ Autowired ĊĠ Ġlateinit Ġvar Ġgot en berg Mock Server : ĠGot en berg Mock Server ĊĊĠ Ġ@ Autowired ĊĠ Ġlateinit Ġvar Ġpdf Document Generation Service : ĠPdf Document Generation Service ĊĊĠ Ġ@ Before All ĊĠ Ġfun Ġstart Mocks () Ġ{ ĊĠĠĠ Ġgot en berg Mock Server . start () ĊĠ Ġ} ĊĊĠ Ġ@ After All ĊĠ Ġfun Ġstop Mocks () Ġ{ ĊĠĠĠ Ġgot en berg Mock Server . stop () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġreturn Ġbyte Ġarray Ġwhen Ġgenerating Ġpdf Ġfrom Ġhtml `() Ġ{ ĊĠĠĠ Ġval Ġexpected Generated Pdf Ġ= Ġrandom String () ĊĠĠĠ Ġval Ġhtml Ġ= Ġ"< body >< span >${ random String () }</ span ></ body >" ĊĠĠĠ Ġgot en berg Mock Server . stub Generate Rev ocation Order ( expected Generated Pdf . toByteArray (), Ġhtml ) ĊĊĠĠĠ Ġval Ġgenerated Pdf Ġ= Ġpdf Document Generation Service . generate Pdf ( ĊĠĠĠĠĠ Ġhtml , ĊĠĠĠĠĠ Ġrecall Image ( Rev ocation Order Logo ) ĊĠĠĠ Ġ). block () !! ĊĊĠĠĠ ĠassertThat ( String ( generated Pdf ), ĠequalTo ( expected Generated Pdf )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` should Ġreturn Ġbyte Ġarray Ġwhen Ġmerging Ġmany Ġp dfs Ġto Ġone `() Ġ{ ĊĠĠĠ Ġval Ġexpected Merged Pdf Ġ= Ġrandom String () ĊĠĠĠ Ġgot en berg Mock Server . stub Merge P dfs ( ĊĠĠĠĠĠ Ġexpected Merged Pdf . toByteArray (), ĊĠĠĠĠĠ ĠClass Path Resource ("/ document / licence . pdf "). file . read Text (), ĊĠĠĠĠĠ ĠClass Path Resource ("/ document / rev ocation - order . pdf "). file . read Text () ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġdetails Ġ= ĠlistOf ( ĊĠĠĠĠĠ ĠClass Path Document Data ("/ document / licence . pdf "), ĊĠĠĠĠĠ ĠClass Path Document Data ("/ document / rev ocation - order . pdf ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġval Ġmerged Pdf Ġ= Ġpdf Document Generation Service . merge P dfs ( details ). block () !! ĊĊĠĠĠ ĠassertThat ( String ( merged Pdf ), ĠequalTo ( expected Merged Pdf )) ĊĠ Ġ} Ċ } Ċ