package Ġcom . cat en ax . gp dm . controller Ċ Ċ import Ġcom . cat en ax . gp dm . Application Ċ import Ġcom . cat en ax . gp dm . component . elastic . impl . service . Elastic Sync Starter Service Ċ import Ġcom . cat en ax . gp dm . dto . request . Site Properties Search Request Ċ import Ġcom . cat en ax . gp dm . dto . response . Business Partner Search Response Ċ import Ġcom . cat en ax . gp dm . dto . response . Page Response Ċ import Ġcom . cat en ax . gp dm . service . Business Partner Build Service Ċ import Ġcom . cat en ax . gp dm . util .* Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . web . reactive . server . Web Test Client Ċ import Ġorg . springframework . test . web . reactive . server . return Result Ċ Ċ /** Ċ Ġ* ĠIntegration Ġtests Ġfor Ġthe Ġsearch Ġendpoint Ġof Ġthe Ġbusiness Ġpartner Ġcontroller Ċ Ġ*/ Ċ @ SpringBootTest ( ĊĠĠĠ Ġweb Environment Ġ= ĠSpring Boot Test . Web Environment . RANDOM _ PORT , Ġclasses Ġ= Ġ[ Application :: class , ĠTest Helpers :: class ] Ċ ) Ċ @ Active Profiles ( value Ġ= Ġ[" test "]) Ċ @ Context Configuration ( initial izers Ġ= Ġ[ PostgreSQL Context Initializer :: class , ĠElasticsearch Context Initializer :: class ]) Ċ class ĠBusiness Partner Controller Search IT Ġ@ Autowired Ġconstructor ( ĊĠĠĠ Ġval Ġweb Test Client : ĠWeb Test Client , ĊĠĠĠ Ġval Ġelastic Sync Service : ĠElastic Sync Starter Service , ĊĠĠĠ Ġval Ġtest Helpers : ĠTest Helpers , ĊĠĠĠ Ġval Ġbusiness Partner Build Service : ĠBusiness Partner Build Service Ċ ) Ġ{ ĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠbeforeEach () Ġ{ ĊĠĠĠĠĠĠĠ Ġtest Helpers . truncate Db Tables () ĊĠĠĠĠĠĠĠ Ġelastic Sync Service . clear Elastic () ĊĊĠĠĠĠĠĠĠ Ġbusiness Partner Build Service . upsert Business Part ners ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( Request Values . business Partner Request 1 , ĠRequest Values . business Partner Request 2 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġelastic Sync Service . export () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠGiven Ġpart ners Ġin ĠElasticsearch ĊĠĠĠĠ Ġ* ĠWhen Ġsearching Ġby Ġsite Ġname ĊĠĠĠĠ Ġ* ĠThen Ġbusiness Ġpartner Ġis Ġfound ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` search Ġbusiness Ġpartner Ġby Ġsite Ġname , Ġresult Ġfound `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfound Part ners Ġ= Ġsearch Business Partner By Site Name ( Request Values . business Partner Request 1 . sites . first (). name !! ). content ĊĠĠĠĠĠĠĠ ĠassertThat ( found Part ners ). has Size ( 1 ) ĊĠĠĠĠĠĠĠ ĠassertThat ( found Part ners . single (). business Partner . sites . first (). name ). isEqualTo ( Request Values . business Partner Request 1 . sites . first (). name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠGiven Ġpart ners Ġin ĠElasticsearch ĊĠĠĠĠ Ġ* ĠWhen Ġsearching Ġby Ġnon existent Ġsite Ġname ĊĠĠĠĠ Ġ* ĠThen Ġno Ġbusiness Ġpartner Ġis Ġfound ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` search Ġbusiness Ġpartner Ġby Ġsite Ġname , Ġno Ġresult Ġfound `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfound Part ners Ġ= Ġsearch Business Partner By Site Name (" non existent Ġname "). content ĊĠĠĠĠĠĠĠ ĠassertThat ( found Part ners ). isEmpty () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsearch Business Partner By Site Name ( site Name : ĠString ): ĠPage Response < Business Partner Search Response > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġweb Test Client . get (). uri Ġ{ Ġbuilder Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuilder . path ( Endpoint Values . CAT ENA _ BUS INESS _ PART NER _ PATH ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. query Param ( Site Properties Search Request :: site Name . name , Ġsite Name ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. expect Status (). is 2 xx Successful ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. return Result < Page Response < Business Partner Search Response >>() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. response Body ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. block First () !! ĊĠĠĠ Ġ} Ċ }