[필수 과제] CH 4 Spring 리팩터링 및 테스트 개선 (Level 0~4) - #85
Open
yeang976-art wants to merge 1 commit into
Open
Conversation
리소스 패키지 만들고 설정파일 생성해서 MySQL 아이디/비번, JWT 비밀키를 환경변수에 설정
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 개요
CH 4 심화 Spring 과제의 필수 단계 Level 0~4를 수행했습니다.
중첩 조건문과 불필요한 로직을 정리하고, DTO Validation 적용, N+1 문제 개선, 예외 처리 및 테스트 코드 수정을 진행했습니다.
🔧 주요 변경 사항
Level 0. 프로젝트 설정
application.yml추가Level 1. ArgumentResolver 설정
AuthUserArgumentResolver를 Spring Bean으로 등록WebConfig를 복구하고 ArgumentResolver 등록Level 2-1. 인증 로직 선검증
Level 2-2. 불필요한 if-else 제거
WeatherClient의 중첩if-else제거Level 2-3. 비밀번호 Validation 적용
@Valid적용@NotBlank,@Pattern을 이용해 다음 조건 검증Level 3. N+1 문제 개선
TodoRepository조회 메서드에@EntityGraph적용Level 4-1. 성공 테스트 수정
PasswordEncoder.matches()의 인수 순서를 다음과 같이 수정Level 4-2. 예외 테스트 및 서비스 로직 수정
Todo not found로 수정InvalidRequestException으로 변경Todo.user가null인 경우를 먼저 검사하도록 ManagerService 수정||의 단락 평가를 이용해todo.getUser()가null이면 뒤쪽 ID 비교를 실행하지 않도록 처리NullPointerException대신 도메인 예외 반환🧪 수정한 테스트
PasswordEncoderTestCommentServiceTestManagerServiceTest✅ 제출 전 확인 사항
DATABASE_PASSWORD환경변수 설정JWT_SECRET_KEY환경변수 설정