package Ġcom . z up . edu . controllers Ċ Ċ import Ġcom . z up . C ada stra Ch ave Pix Request Ċ import Ġcom . z up . C ada stra Ch ave Pix Response Ċ import Ġcom . z up . Key manager C ada stra Service Grpc Ċ import Ġcom . z up . Tipo De Ch ave Ċ import Ġcom . z up . edu . dto . Ch ave Pix Request Ċ import Ġcom . z up . edu . dto . Tipo De Ch ave Request Ċ import Ġcom . z up . edu . dto . Tipo De Cont a Request Ċ import Ġcom . z up . edu . grpc . Key Manager Grpc Factory Ċ import Ġio . mic ronaut . context . annotation . Factory Ċ import Ġio . mic ronaut . context . annotation . Re places Ċ import Ġio . mic ronaut . http . HttpRequest Ċ 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 . extensions . junit 5 . annotation . Mic ronaut Test Ċ import Ġjak arta . inject . Inject Ċ import Ġjak arta . inject . Singleton Ċ import Ġorg . junit . jupiter . api . Assertions .* Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . BDD Mockito Ċ import Ġorg . mockito . Mockito Ċ import Ġjava . util .* Ċ Ċ @ Mic ronaut Test Ċ internal Ġclass ĠC ada stra Ch ave Pix Controller Test (){ ĊĊĠĠĠ Ġ@ field : Inject ĊĠĠĠ Ġlateinit Ġvar Ġcada stra Stub : ĠKey manager C ada stra Service Grpc . Key manager C ada stra Service Blocking Stub ĊĊĠĠĠ Ġ@ field : Inject ĊĠĠĠ Ġ@ field : Client ("/") ĊĠĠĠ Ġlateinit Ġvar Ġclient : ĠHttpClient ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġinternal Ġfun Ġ` de ve Ġcada strar Ġuma Ġnova Ġch ave Ġpix ` (){ ĊĠĠĠĠĠĠĠ Ġval Ġcliente Id Ġ= ĠUUID . randomUUID (). toString () ĊĠĠĠĠĠĠĠ Ġval Ġpix Id Ġ= ĠUUID . randomUUID (). toString () ĊĊĠĠĠĠĠĠĠ Ġval Ġresp ost as Grpc Ġ= ĠC ada stra Ch ave Pix Response . newBuilder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Cliente Id ( cliente Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Pix Id ( pix Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ ĠB DD Mockito . given ( c ada stra Stub . c ada stra Ch ave Pix ( Mockito . any ())). willReturn ( resp ost as Grpc ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnova Ch ave Pix Ġ= ĠCh ave Pix Request ( valor Da Ch ave Ġ= Ġ" test e @ email . com ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTipo De Ch ave Request . EMAIL , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTipo De Cont a Request . CONT A _ COR REN TE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠHttpRequest . POST ("/ api / v 1 / client es /$ cliente Id / pix ", Ġnova Ch ave Pix ) ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġclient . to Blocking (). exchange ( request , ĠCh ave Pix Request :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( HttpStatus . CREATED , Ġresponse . status ) ĊĠĠĠĠĠĠĠ ĠassertTrue ( response . headers . contains (" Location ")) ĊĠĠĠĠĠĠĠ ĠassertTrue ( response . header (" Location ") !!. contains ( pix Id )) ĊĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ@ Factory ĊĠĠĠ Ġ@ Re places ( factory Ġ= ĠKey Manager Grpc Factory :: class ) ĊĠĠĠ Ġinternal Ġclass ĠMockito Stub Factory { ĊĊĠĠĠĠĠĠĠ Ġ@ Singleton ĊĠĠĠĠĠĠĠ Ġfun Ġstub Mock () Ġ= ĠMockito . mock ( Key manager C ada stra Service Grpc . Key manager C ada stra Service Blocking Stub :: class . java ) ĊĠĠĠ Ġ} Ċ Ċ }