package Ġbr . com . z up academy . regist ra . controller Ċ Ċ import Ġbr . com . z up academy . Key Manager Regist ra Grpc Service Grpc Ċ import Ġbr . com . z up academy . Regist ra Ch ave Pix Response Ċ import Ġbr . com . z up academy . regist ra . request . Nova Ch ave Pix Request Ċ import Ġbr . com . z up academy . shared . Key Manager Grpc Factory Ċ import Ġbr . com . z up academy . shared . enums . Tipo De Ch ave Request .* Ċ import Ġbr . com . z up academy . shared . enums . Tipo De Cont a Request .* Ċ 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 Ġorg . junit . jupiter . api . Assertions .* Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito .* Ċ import Ġjava . util .* Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Singleton Ċ Ċ @ Mic ronaut Test Ċ internal Ġclass ĠRegist ra Ch ave Pix Controller Test { ĊĊĠĠĠ Ġ@ field : Inject ĊĠĠĠ Ġlateinit Ġvar Ġgrpc Client : ĠKey Manager Regist ra Grpc Service Grpc . Key Manager Regist ra Grpc Service Blocking Stub ĊĊĠĠĠ Ġ@ field : Inject ĊĠĠĠ Ġ@ field : Client ("/") ĊĠĠĠ Ġlateinit Ġvar Ġclient : ĠHttpClient ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` de ve Ġregist rar Ġuma Ġnova Ġch ave ĠP ix `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġ// Ġc en Ã¡rio ĊĠĠĠĠĠĠĠ Ġval ĠclientId Ġ= ĠUUID . randomUUID (). toString () ĊĠĠĠĠĠĠĠ Ġval Ġpix Id Ġ= ĠUUID . randomUUID (). toString () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Grpc Ġ= ĠRegist ra Ch ave Pix Response ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. newBuilder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set ClientId ( clientId ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Pix Id ( pix Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ Ġ` when `( grpc Client . regist ra ( Mockito . any ())). thenReturn ( response Grpc ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnova Ch ave Pix Ġ= ĠN ova Ch ave Pix Request ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtipo De Cont a Ġ= ĠCON TA _ COR REN TE , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġch ave Ġ= Ġ" test e @ z up . com . br ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtipo De Ch ave Ġ= ĠE MAIL ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġa Ã§Ã£o ĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠHttpRequest . POST ("/ api / v 1 / client es /${ clientId }/ pix ", Ġnova Ch ave Pix ) ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġthis . client . to Blocking (). exchange ( request , ĠAny :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġ// Ġvalid aÃ§Ã£o ĊĠĠĠĠĠĠĠ Ġwith ( response ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( HttpStatus . CREATED , Ġthis . 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 Regist ra Grpc Service Grpc . Key Manager Regist ra Grpc Service Blocking Stub :: class . java ) ĊĠĠĠ Ġ} Ċ }