package Ġbr . com . z up . auto res Ċ Ċ import Ġio . mic ronaut . http . HttpRequest Ċ import Ġio . mic ronaut . http . HttpRequest . POST Ċ import Ġio . mic ronaut . http . HttpResponse Ċ import Ġio . mic ronaut . http . HttpStatus Ċ import Ġio . mic ronaut . http . client . HttpClient Ċ import Ġio . mic ronaut . http . client . annotation . Client Ċ import Ġio . mic ronaut . test . annotation . Mock Bean Ċ import Ġio . mic ronaut . test . extensions . junit 5 . annotation . Mic ronaut Test Ċ import Ġorg . junit . jupiter . api . Assertions Ċ import Ġorg . junit . jupiter . api . Assertions .* Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . Mockito Ċ import Ġjavax . inject . Inject Ċ Ċ @ Mic ronaut Test Ċ internal Ġclass ĠC ada stra Autor Controller Test { ĊĊĠĠĠ Ġ@ field : Inject ĊĠĠĠ Ġlateinit Ġvar Ġendere co Client : ĠEn dere co Client ĊĊĠĠĠ Ġ@ field : Inject ĊĠĠĠ Ġ@ field : Client ("/") ĊĠĠĠ Ġlateinit Ġvar Ġclient : ĠHttpClient ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` de ve Ġcada strar Ġum Ġnovo Ġautor `() Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġc enario ĊĠĠĠĠĠĠĠ Ġval Ġnovo Autor Request Ġ= ĠNov o Autor Request (" R af ael ĠP ont e ", Ġ" raf ael . p ont e @ z up . com . br ", Ġ" O Ġpr ÃŃn cipe Ġdos Ġo cean os ", Ġ" 1 1 2 2 2 - 3 3 3 ", Ġ" 3 7 ") ĊĠĠĠĠĠĠĠ Ġval Ġendere co Response Ġ= ĠEn dere co Response Via C ep (" R ua Ġdas ĠL aran je ir as ", Ġ" R io Ġde ĠJ ane iro ", Ġ" R J ") ĊĠĠĠĠĠĠĠ ĠMockito .` when `( end ere co Client . consult a ( no vo Autor Request . cep )). thenReturn ( end ere co Response ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠHttpRequest . POST ("/ auto res ", Ġnovo Autor Request ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġa cao ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġclient . to Blocking (). exchange ( request , ĠAny :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġcorre t ude ĊĠĠĠĠĠĠĠ ĠassertEquals ( HttpStatus . CREATED , Ġresponse . status ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( response . headers . contains (" Location ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( response . header (" Location ") !!. matches ("/ auto res / \\ d +$ ". to Regex ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Mock Bean ( En dere co Client :: class ) ĊĠĠĠ Ġfun Ġendere co Mock (): ĠEn dere co Client { ĊĠĠĠĠĠĠĠ Ġreturn ĠMockito . mock ( En dere co Client :: class . java ) ĊĠĠĠ Ġ} Ċ }