package Ġcom . pre z . it Ċ Ċ import Ġcom . github . tom ake hur st . wire mock . Wire Mock Server Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . a Response Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . configure For Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . get Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . get Requested For Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . reset All Requests Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . stub For Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . url EqualTo Ċ import Ġcom . github . tom ake hur st . wire mock . client . Wire Mock . verify Ċ import Ġcom . github . tom ake hur st . wire mock . core . Wire Mock Configuration Ċ import Ġcom . github . tom ake hur st . wire mock . http . Fault Ċ import Ġcom . github . tom ake hur st . wire mock . matching . EqualTo Pattern Ċ import Ġcom . pre z . Using MongoDB And Redis Ċ import Ġcom . pre z . model . Customer Ċ import Ġcom . pre z . model . Lo y alty Program Ċ import Ġcom . pre z . model . Lo y alty Status . B 0 B 0 B 0 Ċ import Ġcom . pre z . model . Lo y alty Status . E 0 E 0 E 0 Ċ import Ġcom . pre z . model . Pass Type Ċ import Ġcom . pre z . model . Pass Type . Y OUT H Ċ import Ġcom . pre z . model . R ail Pass Ċ import Ġcom . pre z . utils . Fake Token Generator Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . assertj . core . api . recursive . comparison . Recursive Comparison Configuration Ċ import Ġorg . junit . jupiter . api . After All Ċ import Ġorg . junit . jupiter . api . Before All Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Tag Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . boot . test . context . SpringBootTest Ċ import Ġorg . springframework . context . ApplicationContext Initializer Ċ import Ġorg . springframework . context . Configurable ApplicationContext Ċ import Ġorg . springframework . data . redis . core . Reactive Redis Template Ċ import Ġorg . springframework . http . HttpStatus . INTERNAL _ SERVER _ ERROR Ċ import Ġorg . springframework . http . MediaType . APPLICATION _ JSON Ċ import Ġorg . springframework . test . context . Active Profiles Ċ import Ġorg . springframework . test . context . Context Configuration Ċ import Ġorg . springframework . test . context . support . Test Property Source Utils Ċ import Ġorg . springframework . test . web . reactive . server . Web Test Client Ċ import Ġjava . time . Duration Ċ import Ġjava . time . Instant Ċ import Ġjava . time . LocalDate Ċ import Ġjava . time . Period Ċ import Ġjava . util . Date Ċ Ċ @ Tag (" docker ") Ċ @ Suppress (" RECE IVER _ NULL ABILITY _ MIS MATCH _ BASE D _ ON _ JAVA _ AN NOT ATIONS ") Ċ @ SpringBootTest ( web Environment Ġ= ĠSpring Boot Test . Web Environment . RANDOM _ PORT ) Ċ @ Active Profiles ( profiles Ġ= Ġ[" test "]) Ċ @ Context Configuration ( initial izers Ġ= Ġ[ Get Customer IntegrationTest . Companion . Initializer :: class ]) Ċ internal Ġclass ĠGet Customer IntegrationTest ( ĊĠ Ġ@ Autowired Ġval Ġclient : ĠWeb Test Client , ĊĠ Ġ@ Autowired Ġval Ġcustomer Info Redis Template : ĠReactive Redis Template < String , ĠCustomer > Ċ ) Ġ: ĠUsing MongoDB And Redis () Ġ{ ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠ Ġlateinit Ġvar Ġwire Mock Server : ĠWire Mock Server ĊĊĠĠĠ Ġprivate Ġval Ġfake Token Generator : ĠFake Token Generator Ġ= ĠFake Token Generator (" test - authorization - server ") ĊĠĠĠ Ġprivate Ġval Ġvalid Token Ġ= ĊĠĠĠĠĠ Ġfake Token Generator . generate Not Expired Signed Token (" sub zero ", Ġ 3 6 0 0 , Ġ" customer . read Ġcustomer . write ") ĊĊĠĠĠ Ġ@ Before All ĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġfun Ġbefore All () Ġ{ ĊĠĠĠĠĠ Ġwire Mock Server Ġ= ĠWire Mock Server ( ĊĠĠĠĠĠĠĠ ĠWire Mock Configuration . options () ĊĠĠĠĠĠĠĠĠĠ Ġ. dynamic Port () ĊĠĠĠĠĠĠĠĠĠ Ġ. using Files Under Classpath (" com / dev ox x / ws ") ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġwire Mock Server . start () ĊĠĠĠĠĠ Ġconfigure For (" localhost ", Ġwire Mock Server . port ()) Ġ// Ġin dis pens able Ġen Ġreact if ĊĊĠĠĠĠĠ Ġ// Ġpart ie ĠCustomer Ġweb Ġservice ĊĠĠĠĠĠ Ġ// ok ĊĠĠĠĠĠ Ġstub For ( ĊĠĠĠĠĠĠĠ Ġget ("/ customers / sub zero ") ĊĠĠĠĠĠĠĠĠĠ Ġ. willReturn ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġa Response () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Status ( 2 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Header (" Content - Type ", Ġ" application / json ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Body File (" full Customer . json ") ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġ// bad Ġrequest ĊĠĠĠĠĠ Ġstub For ( ĊĠĠĠĠĠĠĠ Ġget ("/ customers / bad Request ") ĊĠĠĠĠĠĠĠĠĠ Ġ. willReturn ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġa Response () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Status ( 4 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Header (" Content - Type ", Ġ" application / json ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Body (""" {" code ":" 2 0 1 2 "," message ":" Error "} """) ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġ// 4 0 4 ĊĠĠĠĠĠ Ġstub For ( ĊĠĠĠĠĠĠĠ Ġget ("/ customers / unknown Customer ") ĊĠĠĠĠĠĠĠĠĠ Ġ. willReturn ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġa Response () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Status ( 4 0 4 ) ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġ// Ġconnection Ġreset Ġby Ġpeer ĊĠĠĠĠĠ Ġstub For ( ĊĠĠĠĠĠĠĠ Ġget ("/ customers / connection Lost ") ĊĠĠĠĠĠĠĠĠĠ Ġ. willReturn ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġa Response () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Fault ( Fault . CONNECTION _ RESET _ BY _ PEER ) ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After All ĊĠĠĠ Ġ@ Jvm Static ĊĠĠĠ Ġfun Ġafter All () Ġ{ ĊĠĠĠĠĠ Ġwire Mock Server . stop () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinternal Ġclass ĠInitial izer Ġ: ĠApplication Context Initializer < Configurable ApplicationContext > Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġinitialize ( application Context : ĠConfigur able ApplicationContext ) Ġ{ ĊĠĠĠĠĠĠĠ ĠTest Property Source Utils . add In lined Properties To Environment ( ĊĠĠĠĠĠĠĠĠĠ Ġapplication Context , ĊĠĠĠĠĠĠĠĠĠ Ġ" customer . ws . url = http :// localhost :" Ġ+ Ġwire Mock Server . port () Ġ+ Ġ"/ customers " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ BeforeEach ĊĠ Ġinternal Ġfun ĠbeforeEach () Ġ{ ĊĠĠĠ Ġcustomer Info Redis Template . delete ( customer Info Redis Template . keys (" Customer :* ")). block () ĊĠĠĠ Ġreset All Requests () Ġ// reset Ġall Ġrequests Ġregistered Ġby Ġwire mock Ġto Ġbe Ġisolate Ġeach Ġfull Customer . json ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` GET Ġcustomers Ġshould Ġreturn Ġ 4 0 1 Ġif Ġnot Ġauth ent ified `() Ġ{ ĊĠĠĠ Ġ// When , ĠTest Ġ& ĠAssert ĊĠĠĠ Ġclient ĊĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠ Ġ. uri ("/ customers ") ĊĠĠĠĠĠ Ġ. accept ( APPLICATION _ JSON ) ĊĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠ Ġ. expect Status (). is Unauthorized ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` GET Ġcustomers Ġshould Ġreturn Ġ 4 0 1 Ġif Ġid Token Ġis Ġexpired `() Ġ{ ĊĠĠĠ Ġ// When ĊĠĠĠ Ġval Ġexpired Ġ= Ġfake Token Generator . generate Signed Token ( ĊĠĠĠĠĠ Ġ" expired ", ĊĠĠĠĠĠ ĠDate . from ( Instant . now (). minus Seconds ( 3 0 0 )), ĊĠĠĠĠĠ Ġ" customer . read " ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ// Test Ġ& ĠAssert ĊĠĠĠ Ġclient ĊĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠ Ġ. uri ("/ customers ") ĊĠĠĠĠĠ Ġ. header (" Authorization ", Ġ" Bearer Ġ$ expired ") ĊĠĠĠĠĠ Ġ. accept ( APPLICATION _ JSON ) ĊĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠ Ġ. expect Status (). is Unauthorized ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` GET Ġcustomers Ġshould Ġreturn Ġcustomer Ġinfo Ġwith Ġboth Ġlo y alty Program Ġand Ġr ail passes Ġif Ġit Ġis Ġcached `() Ġ{ ĊĠĠĠ Ġ// When ĊĠĠĠ Ġval Ġbirth Date Ġ= ĠLocalDate . of ( 1 9 5 2 , Ġ 2 , Ġ 2 9 ) ĊĠĠĠ Ġcustomer Info Redis Template . ops ForValue (). set ( ĊĠĠĠĠĠ Ġ" Customer : sub zero ", ĠCustomer ( ĊĠĠĠĠĠĠĠ Ġcustomer Id Ġ= Ġ" sub zero ", ĊĠĠĠĠĠĠĠ Ġemail Ġ= Ġ" mission . imp ossible @ connect . fr ", ĊĠĠĠĠĠĠĠ ĠfirstName Ġ= Ġ" Jim ", ĊĠĠĠĠĠĠĠ ĠlastName Ġ= Ġ" P hel ps ", ĊĠĠĠĠĠĠĠ Ġbirth Date Ġ= Ġbirth Date , ĊĠĠĠĠĠĠĠ ĠphoneNumber Ġ= Ġnull , ĊĠĠĠĠĠĠĠ Ġlo y alty Program Ġ= ĠLo y alty Program ( ĊĠĠĠĠĠĠĠĠĠ Ġnumber Ġ= Ġ" 2 9 0 9 0 1 0 9 6 2 5 0 8 8 0 8 2 ", ĊĠĠĠĠĠĠĠĠĠ Ġstatus Ref Label Ġ= Ġ" Grey ", ĊĠĠĠĠĠĠĠĠĠ Ġstatus Ġ= ĠE 0 E 0 E 0 , ĊĠĠĠĠĠĠĠĠĠ Ġvalidity StartDate Ġ= ĠLocalDate . of ( 2 0 1 9 , Ġ 8 , Ġ 1 2 ), ĊĠĠĠĠĠĠĠĠĠ Ġvalidity EndDate Ġ= ĠLocalDate . of ( 2 0 1 9 , Ġ 8 , Ġ 1 3 ) ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ Ġr ail P asses Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠ ĠR ail Pass ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnumber Ġ= Ġ" 2 9 0 9 0 1 0 2 4 2 0 4 1 2 7 5 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtype Ref Label Ġ= Ġ" So ĠYo ung !", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtype Ġ= ĠY OUT H , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvalidity StartDate Ġ= ĠLocalDate . of ( 2 0 2 0 , Ġ 4 , Ġ 1 8 ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvalidity EndDate Ġ= ĠLocalDate . of ( 2 0 2 0 , Ġ 3 , Ġ 1 4 ) ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ). block () ĊĊĠĠĠ Ġ// ĠTest Ġ& ĠAssert ĊĠĠĠ Ġclient ĊĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠ Ġ. uri ("/ customers ") ĊĠĠĠĠĠ Ġ. header (" Authorization ", Ġ" Bearer Ġ$ valid Token ") ĊĠĠĠĠĠ Ġ. accept ( APPLICATION _ JSON ) ĊĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠ Ġ. expect Status (). is Ok ĊĠĠĠĠĠ Ġ. expect Body () ĊĠĠĠĠĠ Ġ. json (""" ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġ" customer Id ":" sub zero ", ĊĠĠĠĠĠĠĠĠĠ Ġ" firstName ":" Jim ", ĊĠĠĠĠĠĠĠĠĠ Ġ" lastName ":" P hel ps ", ĊĠĠĠĠĠĠĠĠĠ Ġ" age ": ${ Period . between ( birth Date , ĠLocalDate . now ()). years }, ĊĠĠĠĠĠĠĠĠĠ Ġ" email ":" mission . imp ossible @ connect . fr ", ĊĠĠĠĠĠĠĠĠĠ Ġ" loy alty Program ": Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" number ":" 2 9 0 9 0 1 0 9 6 2 5 0 8 8 0 8 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" label ":" Grey ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" validity StartDate ":" 2 0 1 9 - 0 8 - 1 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" validity EndDate ":" 2 0 1 9 - 0 8 - 1 3 " ĊĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠ Ġ" rail P asses ": [{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" number ":" 2 9 0 9 0 1 0 2 4 2 0 4 1 2 7 5 5 ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" label ":" So ĠYo ung !", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" validity StartDate ":" 2 0 2 0 - 0 4 - 1 8 ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" validity EndDate ":" 2 0 2 0 - 0 3 - 1 4 " ĊĠĠĠĠĠĠĠĠĠ Ġ}] ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĊĠĠĠ Ġverify ( ĊĠĠĠĠĠĠ 0 , Ġget Requested For ( url EqualTo ("/ customers / sub zero ")) ĊĠĠĠĠĠĠĠ Ġ. with Header (" Accept ", ĠEqual To Pattern (" application / json ")) ĊĠĠĠĠĠĠĠ Ġ. with Header (" Content - Type ", ĠEqual To Pattern (" application / json ")) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` GET Ġcustomers Ġshould Ġreturn Ġcustomer Ġinfo Ġif Ġit Ġis Ġnot Ġcached , Ġretrieve Ġit Ġand Ġcached Ġit `() Ġ{ ĊĠĠĠ Ġ// Test Ġ& ĠAssert ĊĠĠĠ Ġclient ĊĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠ Ġ. uri ("/ customers ") ĊĠĠĠĠĠ Ġ. header (" Authorization ", Ġ" Bearer Ġ$ valid Token ") ĊĠĠĠĠĠ Ġ. accept ( APPLICATION _ JSON ) ĊĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠ Ġ. expect Status (). is Ok ĊĠĠĠĠĠ Ġ. expect Body () ĊĠĠĠĠĠ Ġ. json (""" ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġ" customer Id ":" 7 2 f 0 2 8 e 2 - fbb 8 - 4 8 b 3 - b 9 4 3 - bf 4 da ad 9 6 1 ed ", ĊĠĠĠĠĠĠĠĠĠ Ġ" firstName ":" El liot ", ĊĠĠĠĠĠĠĠĠĠ Ġ" lastName ":" A ld erson ", ĊĠĠĠĠĠĠĠĠĠ Ġ" phoneNumber ":" 0 0 1 2 1 2 5 5 5 0 1 7 9 ", ĊĠĠĠĠĠĠĠĠĠ Ġ" email ":" elli otal d erson @ pro ton mail . com " ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĊĊĠĠĠ Ġ// wire mock ĊĠĠĠ Ġverify ( ĊĠĠĠĠĠ Ġget Requested For ( url EqualTo ("/ customers / sub zero ")) ĊĠĠĠĠĠĠĠ Ġ. with Header (" Accept ", ĠEqual To Pattern (" application / json ")) ĊĠĠĠĠĠĠĠ Ġ. with Header (" Content - Type ", ĠEqual To Pattern (" application / json ")) ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ// redis ĊĠĠĠ Ġval Ġttl Ġ= Ġcustomer Info Redis Template . get Expire (" Customer : 7 2 f 0 2 8 e 2 - fbb 8 - 4 8 b 3 - b 9 4 3 - bf 4 da ad 9 6 1 ed "). block () ĊĠĠĠ Ġval Ġsaved Customer Ġ= Ġcustomer Info Redis Template . ops ForValue (). get (" Customer : 7 2 f 0 2 8 e 2 - fbb 8 - 4 8 b 3 - b 9 4 3 - bf 4 da ad 9 6 1 ed "). block () ĊĠĠĠ ĠassertThat ( ttl ). is GreaterThan OrEqualTo ( Duration . of Seconds ( 3 )) ĊĠĠĠ ĠassertThat ( ttl ). is LessThan OrEqualTo ( Duration . of Seconds ( 1 0 )) ĊĠĠĠ Ġval Ġcomp Config Ġ= ĠRecursive Comparison Configuration () ĊĠĠĠ ĠassertThat ( saved Customer ). using Recursive Comparison ( comp Config ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isEqualTo ( ĊĠĠĠĠĠ ĠCustomer ( ĊĠĠĠĠĠĠĠ Ġcustomer Id Ġ= Ġ" 7 2 f 0 2 8 e 2 - fbb 8 - 4 8 b 3 - b 9 4 3 - bf 4 da ad 9 6 1 ed ", ĊĠĠĠĠĠĠĠ Ġemail Ġ= Ġ" elli otal d erson @ pro ton mail . com ", ĊĠĠĠĠĠĠĠ ĠfirstName Ġ= Ġ" El liot ", ĊĠĠĠĠĠĠĠ ĠlastName Ġ= Ġ" A ld erson ", ĊĠĠĠĠĠĠĠ Ġbirth Date Ġ= ĠLocalDate . of ( 1 9 8 6 , 9 , 1 7 ), ĊĠĠĠĠĠĠĠ ĠphoneNumber Ġ= Ġ" 0 0 1 2 1 2 5 5 5 0 1 7 9 ", ĊĠĠĠĠĠĠĠ Ġlo y alty Program Ġ= ĠLo y alty Program (" ER 2 8 - 0 6 5 2 ", ĠB 0 B 0 B 0 , Ġ" PL AT IN IUM ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLocalDate . of ( 2 0 1 9 , Ġ 1 1 , Ġ 1 0 ), ĠLocalDate . of ( 2 0 2 0 , 1 1 , 9 )), ĊĠĠĠĠĠĠĠ Ġr ail P asses Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR ail Pass (" 0 7 2 3 9 1 0 7 / 2 3 / 9 1 ", ĠPass Type . FAMILY , Ġ" FAMILY ĠPASS ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLocalDate . of ( 2 0 1 9 , 1 2 , 2 3 ), ĠLocalDate . of ( 2 0 2 1 , 1 2 , 2 3 )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR ail Pass (" 2 9 0 9 0 1 1 3 6 0 0 3 1 1 5 2 7 ", ĠPass Type . FAMILY , Ġ" FAMILY ĠPASS ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLocalDate . of ( 2 0 1 8 , 1 2 , 2 3 ), ĠLocalDate . of ( 2 0 1 9 , 1 2 , 2 3 )) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` GET Ġcustomers Ġshould Ġreturn Ġ 4 0 4 Ġif Ġcustomer Ġinfo Ġhas Ġnot Ġbeen Ġfound Ġanywhere `() Ġ{ ĊĠĠĠ Ġval Ġunknown Ġ= Ġfake Token Generator . generate Not Expired Signed Token (" unknown Customer ", Ġ 3 6 0 0 , Ġ" customer . read ") ĊĠĠĠ Ġclient ĊĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠ Ġ. uri ("/ customers ") ĊĠĠĠĠĠ Ġ. header (" Authorization ", Ġ" Bearer Ġ$ unknown ") ĊĠĠĠĠĠ Ġ. accept ( APPLICATION _ JSON ) ĊĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠ Ġ. expect Status (). is NotFound ĊĠĠĠĠĠ Ġ. expect Body (). json (""" ĊĠĠĠĠĠĠĠ Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġ" code ":" NOT _ FOUND ", ĊĠĠĠĠĠĠĠĠĠ Ġ" message ":" No Ġresult Ġfor Ġthe Ġgiven Ġcustomer Ġid = unknown Customer " ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ""" . trim Indent ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` GET Ġcustomers Ġshould Ġreturn Ġ 5 0 0 Ġif Ġthe Ġline Ġwas Ġcut Ġby Ġcustomer Ġweb Ġservice `() Ġ{ ĊĠĠĠ Ġ// When ĊĠĠĠ Ġval ĠaccessToken Ġ= Ġfake Token Generator . generate Not Expired Signed Token (" connection Lost ", Ġ 3 6 0 0 , Ġ" customer . read ") ĊĊĠĠĠ Ġ// Test Ġ& ĠAssert ĊĠĠĠ Ġval Ġreturned Result Ġ= Ġclient ĊĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠ Ġ. uri ("/ customers ") ĊĠĠĠĠĠ Ġ. header (" Authorization ", Ġ" Bearer Ġ$ accessToken ") ĊĠĠĠĠĠ Ġ. accept ( APPLICATION _ JSON ) ĊĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠ Ġ. expect Status (). isEqualTo ( INTERNAL _ SERVER _ ERROR ) ĊĠĠĠĠĠ Ġ. expect Body (). return Result () ĊĊĠĠĠ Ġ// because Ġdepending Ġon Ġyour ĠOS , Ġthe Ġmessage Ġis Ġnot Ġalways Ġthe Ġsame ... Ġ... {" code ":" CUSTOMER _ WS _ GET _ CUSTOMER _ ERROR "," message ":" Unexpected Ġresponse Ġfrom Ġthe Ġserver Ġwhile Ġretrieving Ġcustomer Ġfor Ġcustomer Id = connection Lost ĊĠĠĠ ĠassertThat ( String ( returned Result . response Body )) ĊĠĠĠĠĠĠĠ Ġ. contains (""" {" code ":" CUSTOMER _ WS _ GET _ CUSTOMER _ ERROR "," message ":" Unexpected """, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" for Ġcustomer Id = connection Lost ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` GET Ġcustomers Ġshould Ġreturn Ġ 4 0 0 Ġif Ġthere Ġis Ġan Ġexception Ġwhen Ġcalling ĠCustomer Ġweb Ġservice `() Ġ{ ĊĠĠĠ Ġval ĠaccessToken Ġ= Ġfake Token Generator . generate Not Expired Signed Token (" bad Request ", Ġ 3 6 0 0 , Ġ" customer . read ") ĊĊĠĠĠ Ġ// Test Ġ& ĠAssert ĊĠĠĠ Ġclient ĊĠĠĠĠĠĠĠ Ġ. get () ĊĠĠĠĠĠĠĠ Ġ. uri ("/ customers ") ĊĠĠĠĠĠĠĠ Ġ. header (" Authorization ", Ġ" Bearer Ġ$ accessToken ") ĊĠĠĠĠĠĠĠ Ġ. accept ( APPLICATION _ JSON ) ĊĠĠĠĠĠĠĠ Ġ. exchange () ĊĠĠĠĠĠĠĠ Ġ. expect Status (). is BadRequest ĊĠĠĠĠĠĠĠ Ġ// Ġhttps :// dis cuss . kotlin lang . org / t / type - inter ference - issue - with - the - web flux - web test client - and - kotlin / 3 8 8 0 ĊĠĠĠĠĠĠĠ Ġ. expect Body (). json ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ"{\" code \":\" CUSTOMER _ WS _ GET _ CUSTOMER _ ERROR \",\" message \":\" Unexpected Ġresponse Ġfrom Ġthe Ġserver Ġwhile Ġretrieving Ġcustomer Ġfor Ġcustomer Id = bad Request , Ġresponse ={ \\\" code \\ \": \\\" 2 0 1 2 \\ \", \\\" message \\ \": \\\" Error \\\" }\" }" ĊĠĠĠĠĠĠĠ Ġ) ĊĠ Ġ} Ċ }