package Ġcom . hid dew ier ing a . elev ator . web Ċ Ċ import Ġcom . hid dew ier ing a . elev ator . domain . person . All Query Ċ import Ġcom . hid dew ier ing a . elev ator . domain . person . Person Ar rives Ċ import Ġcom . hid dew ier ing a . elev ator . domain . person . model . Person Id Ċ import Ġcom . hid dew ier ing a . elev ator . projection . entity . person . Person Ċ import Ġorg . ax on framework . command handling . gateway . Command Gateway Ċ import Ġorg . ax on framework . event handling . EventBus Ċ import Ġorg . ax on framework . messaging . respon set ypes . ResponseType Ċ import Ġorg . ax on framework . query handling . Default Subscription QueryResult Ċ import Ġorg . ax on framework . query handling . Query Gateway Ċ import Ġorg . hamcrest . Core Matchers . contains String Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . any Ċ import Ġorg . mockito . Mockito . times Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . autoconfigure . web . reactive . Web Flux Test Ċ import Ġorg . springframework . boot . test . mock . mockito . Mock Bean Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ import Ġorg . springframework . test . web . reactive . server . Web Test Client Ċ import Ġreactor . core . publisher . Flux Ċ import Ġreactor . core . publisher . Mono Ċ import Ġjava . util . UUID Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ @ Web Flux Test ( controllers Ġ= Ġ[ Person Controller :: class ]) Ċ class ĠPerson Controller Test Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġweb Client : ĠWeb Test Client ĊĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcommand Gateway : ĠCommand Gateway ĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġquery Gateway : ĠQuery Gateway ĊĠĠĠ Ġ@ Mock Bean ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġevent Bus : ĠEvent Bus ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġall Pers ons () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Result Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠDefault Subscription QueryResult ( Mono . just ( emptyList < Person > ()), ĠFlux . empty < List < Person >> (), Ġnull ) ĊĠĠĠĠĠĠĠ Ġ` when `( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġquery Gateway . subscription Query ( any ( All Query :: class . java ), Ġany < ResponseType <* >> (), Ġany < ResponseType <* >> ()) ĊĠĠĠĠĠĠĠ Ġ). thenReturn ( query Result ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġthis . web Client . get (). uri ("/ person ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. expect Status (). is Ok ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. expect Header (). contentType (" text / event - stream ; charset = UTF - 8 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. expect Body ( String :: class . java ). return Result () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( body . response Body !! , Ġcontains String (" data : [] ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġar rive () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġthis . web Client . get (). uri ("/ person / ar rive / 0 / 1 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. expect Status (). is Ok ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. expect Body ( UUID :: class . java ). return Result () ĊĊĠĠĠĠĠĠĠ Ġverify ( command Gateway , Ġtimes ( 1 )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. send < Any >( Person Ar rives ( Person Id ( body . response Body !! ), Ġ 0 , Ġ 1 )) ĊĠĠĠ Ġ} Ċ } Ċ