diff --git a/backend/streetdrop-api/src/main/java/com/depromeet/common/error/dto/CommonErrorCode.java b/backend/streetdrop-api/src/main/java/com/depromeet/common/error/dto/CommonErrorCode.java index 50475d92..c7b5c4ca 100644 --- a/backend/streetdrop-api/src/main/java/com/depromeet/common/error/dto/CommonErrorCode.java +++ b/backend/streetdrop-api/src/main/java/com/depromeet/common/error/dto/CommonErrorCode.java @@ -29,7 +29,7 @@ public enum CommonErrorCode implements ErrorCodeInterface { * Basic Server Error */ INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "COMMON_INTERNAL_SERVER_ERROR", "Internal Server Error", "An unexpected error occurred"), - NOT_IMPLEMENTED(HttpStatus.NOT_IMPLEMENTED, "COMMON_INTERNAL_SERVER_ERROR", "Not Implemented", "The server does not support the functionality required to fulfill the request."); + NOT_IMPLEMENTED(HttpStatus.NOT_IMPLEMENTED, "COMMON_NOT_IMPLEMENTED", "Not Implemented", "The server does not support the functionality required to fulfill the request."); private final HttpStatus status; diff --git a/backend/streetdrop-api/src/main/java/com/depromeet/domains/user/error/UserErrorCode.java b/backend/streetdrop-api/src/main/java/com/depromeet/domains/user/error/UserErrorCode.java index de1b5faf..e7a28097 100644 --- a/backend/streetdrop-api/src/main/java/com/depromeet/domains/user/error/UserErrorCode.java +++ b/backend/streetdrop-api/src/main/java/com/depromeet/domains/user/error/UserErrorCode.java @@ -11,7 +11,7 @@ public enum UserErrorCode implements ErrorCodeInterface { USER_NOT_FOUND(HttpStatus.NOT_FOUND, "USER_NOT_FOUND", "User Not Found", "User with the corresponding id could not be found"), INVALID_USER_EXCEPTION(HttpStatus.FORBIDDEN, "USER_FORBIDDEN", "User does not have permission", "Modify or Delete Not Permitted"), - INVALID_INPUT_EXCEPTION(HttpStatus.BAD_REQUEST, "USER_NOT_FOUND", "C-0015", "Nickname must be at least 1 character and not more than 10 characters"), + USER_NICKNAME_INVALID(HttpStatus.BAD_REQUEST, "USER_NICKNAME_INVALID", "User nickname is invalid", "Nickname must be at least 1 character and not more than 10 characters"), USER_CAN_NOT_BLOCK_SELF(HttpStatus.BAD_REQUEST, "USER_CAN_NOT_BLOCK_SELF", "Can Not Block Myself", "You can't block yourself"); private final HttpStatus status; diff --git a/backend/streetdrop-api/src/test/java/unit/common/error/StreetDropErrorCodeTest.java b/backend/streetdrop-api/src/test/java/unit/common/error/StreetDropErrorCodeTest.java new file mode 100644 index 00000000..a0a3c351 --- /dev/null +++ b/backend/streetdrop-api/src/test/java/unit/common/error/StreetDropErrorCodeTest.java @@ -0,0 +1,34 @@ +package unit.common.error; + +import com.depromeet.common.error.dto.StreetDropErrorCode; +import com.depromeet.common.error.dto.StreetDropErrorCodeList; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertTrue; + + +@DisplayName("에러 코드 테스트") +public class StreetDropErrorCodeTest { + @Test + @DisplayName("다른 도메인의 에러 코드가 중복되지 않는지 테스트") + public void testNoDuplicateErrorResponseCodes() { + + StreetDropErrorCodeList streetDropErrorCodeList = StreetDropErrorCodeList.getInstance(); + List errorCodes = streetDropErrorCodeList.getStreetDropErrorCodeList(); + + List errorResponseCodes = errorCodes.stream() + .map(StreetDropErrorCode::getErrorResponseCode) + .toList(); + + var duplicatedList = errorResponseCodes.stream() + .filter(i -> errorResponseCodes.stream().filter(i::equals).count() > 1) + .distinct() + .toList(); + + assertTrue(duplicatedList.isEmpty(), "There are duplicated error response codes: " + duplicatedList); + } + +}