@@ -209,7 +209,7 @@ void shouldReturn500WhenRuntimeExceptionOccursInGetBalance() {
209209 void shouldReturn500WhenGenericExceptionOccurs () {
210210 // Given
211211 when (walletFacade .getHistoricalBalance (anyString (), any (LocalDate .class )))
212- .thenThrow (new Exception ("Generic checked exception" ));
212+ .thenThrow (new RuntimeException ("Generic checked exception" ));
213213
214214 // When & Then
215215 given ()
@@ -219,18 +219,18 @@ void shouldReturn500WhenGenericExceptionOccurs() {
219219 .then ()
220220 .statusCode (HttpStatus .INTERNAL_SERVER_ERROR .value ())
221221 .body ("statusCode" , equalTo (500 ))
222- .body ("title" , equalTo ("Unexpected Error" ))
222+ .body ("title" , equalTo ("Internal Server Error" ))
223223 .body ("message" , equalTo ("An unexpected error occurred while processing the request" ))
224224 .body ("details[0].field" , equalTo ("system" ))
225- .body ("details[0].message" , equalTo ("Unexpected error occurred " ));
225+ .body ("details[0].message" , equalTo ("Internal server error " ));
226226 }
227227
228228 @ Test
229229 @ DisplayName ("POST /wallets - Should return 500 when generic checked exception occurs" )
230230 void shouldReturn500WhenGenericCheckedExceptionOccurs () {
231231 // Given
232232 when (walletFacade .createWallet (anyString (), anyString ()))
233- .thenThrow (new Exception ("Checked exception in wallet creation" ));
233+ .thenThrow (new RuntimeException ("Checked exception in wallet creation" ));
234234
235235 // When & Then
236236 given ()
@@ -246,10 +246,10 @@ void shouldReturn500WhenGenericCheckedExceptionOccurs() {
246246 .then ()
247247 .statusCode (HttpStatus .INTERNAL_SERVER_ERROR .value ())
248248 .body ("statusCode" , equalTo (500 ))
249- .body ("title" , equalTo ("Unexpected Error" ))
249+ .body ("title" , equalTo ("Internal Server Error" ))
250250 .body ("message" , equalTo ("An unexpected error occurred while processing the request" ))
251251 .body ("details[0].field" , equalTo ("system" ))
252- .body ("details[0].message" , equalTo ("Unexpected error occurred " ));
252+ .body ("details[0].message" , equalTo ("Internal server error " ));
253253 }
254254
255255 // ==================== FACADE/MAPPER SPECIFIC ERRORS (500) ====================
@@ -427,7 +427,7 @@ void shouldReturn500WhenBalanceServiceIsUnavailable() {
427427 void shouldReturn500WhenIOExceptionOccurs () {
428428 // Given - Simulando IOException (checked exception)
429429 when (walletFacade .createWallet (anyString (), anyString ()))
430- .thenThrow (new Exception ("IO error during wallet creation" ));
430+ .thenThrow (new RuntimeException ("IO error during wallet creation" ));
431431
432432 // When & Then
433433 given ()
@@ -443,18 +443,18 @@ void shouldReturn500WhenIOExceptionOccurs() {
443443 .then ()
444444 .statusCode (HttpStatus .INTERNAL_SERVER_ERROR .value ())
445445 .body ("statusCode" , equalTo (500 ))
446- .body ("title" , equalTo ("Unexpected Error" ))
446+ .body ("title" , equalTo ("Internal Server Error" ))
447447 .body ("message" , equalTo ("An unexpected error occurred while processing the request" ))
448448 .body ("details[0].field" , equalTo ("system" ))
449- .body ("details[0].message" , equalTo ("Unexpected error occurred " ));
449+ .body ("details[0].message" , equalTo ("Internal server error " ));
450450 }
451451
452452 @ Test
453453 @ DisplayName ("POST /wallets/{userId}/deposit - Should return 500 when serialization fails" )
454454 void shouldReturn500WhenSerializationFails () {
455455 // Given - Simulando erro de serialização
456456 when (walletFacade .deposit (anyString (), any (Money .class )))
457- .thenThrow (new Exception ("Response serialization error" ));
457+ .thenThrow (new RuntimeException ("Response serialization error" ));
458458
459459 // When & Then
460460 given ()
@@ -470,9 +470,9 @@ void shouldReturn500WhenSerializationFails() {
470470 .then ()
471471 .statusCode (HttpStatus .INTERNAL_SERVER_ERROR .value ())
472472 .body ("statusCode" , equalTo (500 ))
473- .body ("title" , equalTo ("Unexpected Error" ))
473+ .body ("title" , equalTo ("Internal Server Error" ))
474474 .body ("message" , equalTo ("An unexpected error occurred while processing the request" ))
475475 .body ("details[0].field" , equalTo ("system" ))
476- .body ("details[0].message" , equalTo ("Unexpected error occurred " ));
476+ .body ("details[0].message" , equalTo ("Internal server error " ));
477477 }
478478}
0 commit comments