Added tests for all services and controller
Build, Test & Push Auth Service / quality-check (push) Successful in 19s
Build, Test & Push Auth Service / docker (push) Successful in 1m18s

This commit is contained in:
lobo committed 2026-04-04 16:01:05 +02:00
1 parent f4b7ae75a9
commit dbc76e6158
7 files changed
+367 -21

No files matched your search

@@ -6,6 +6,7 @@ import auth_service.domain.login.exception.UserNotFoundException;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -14,15 +15,8 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
@Order(value = 1)
@Slf4j
public class LoginExceptionController {
private static @NonNull ResponseEntity<ErrorResponse> response500(ErrorResponse body) {
log.error(body.message(), body.code());
return ResponseEntity.status(500)
.contentType(org.springframework.http.MediaType.APPLICATION_JSON)
.body(body);
}
private static @NonNull ResponseEntity<ErrorResponse> response400(ErrorResponse body) {
return ResponseEntity.status(400)
private static @NonNull ResponseEntity<ErrorResponse> response(ErrorResponse body, HttpStatus status) {
return ResponseEntity.status(status.value())
.contentType(org.springframework.http.MediaType.APPLICATION_JSON)
.body(body);
}
@@ -37,12 +31,12 @@ public class LoginExceptionController {
@ExceptionHandler(UserNotFoundException.class)
public ResponseEntity<ErrorResponse> clientError(UserNotFoundException ex) {
var body = new ErrorResponse("USER_NOT_FOUND", ex.getMessage());
return response400(body);
return response(body, HttpStatus.NOT_ACCEPTABLE);
}
@ExceptionHandler(InvalidCredentialsException.class)
public ResponseEntity<ErrorResponse> clientError(InvalidCredentialsException ex) {
var body = new ErrorResponse("INVALID_CREDENTIALS", ex.getMessage());
return response400(body);
return response(body, HttpStatus.UNAUTHORIZED);
}
}
@@ -5,6 +5,7 @@ import auth_service.domain.user.exception.UserNotFoundException;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -13,15 +14,8 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
@Order(value = 1)
@Slf4j
public class UserExceptionController {
private static @NonNull ResponseEntity<ErrorResponse> response500(ErrorResponse body) {
log.error(body.message(), body.code());
return ResponseEntity.status(500)
.contentType(org.springframework.http.MediaType.APPLICATION_JSON)
.body(body);
}
private static @NonNull ResponseEntity<ErrorResponse> response400(ErrorResponse body) {
return ResponseEntity.status(400)
private static @NonNull ResponseEntity<ErrorResponse> response(ErrorResponse body, HttpStatus status) {
return ResponseEntity.status(status.value())
.contentType(org.springframework.http.MediaType.APPLICATION_JSON)
.body(body);
}
@@ -36,7 +30,7 @@ public class UserExceptionController {
@ExceptionHandler(UserNotFoundException.class)
public ResponseEntity<ErrorResponse> clientError(UserNotFoundException ex) {
var body = new ErrorResponse("USER_NOT_FOUND", ex.getMessage());
return response400(body);
return response(body, HttpStatus.NOT_FOUND);
}
}