test: PublicCourseService 단위 테스트 추가 + 버그 4건 수정 - #215
Conversation
getPublicCourseTotalPageCount/getMarathonPublicCourse/searchPublicCourse/ recommendPublicCourse/getPublicCourseByUser/getPublicCourseDetail/ createPublicCourse/deletePublicCourses/updatePublicCourse 전체 메서드에 대해 정상 케이스 + 예외 케이스 + 경계값 검증 (38개). 테스트 작성 중 발견해서 함께 수정한 버그 4건: 1. PublicCourse에 equals/hashCode 부재 — RunnectUser와 동일한 참조비교 문제. scrap 목록과 publicCourse 목록을 서로 다른 쿼리로 가져와 비교하는 곳이 5곳(getMarathonPublicCourse, searchPublicCourse, recommendPublicCourse, getPublicCourseByUser, getPublicCourseDetail)이라 isScrap이 잘못 표시될 수 있었음. id 기준 equals/hashCode 추가로 일괄 해결. 2. getPublicCourseDetail: 삭제된 코스 체크 조건이 반대(`== null`)였고, 심지어 예외를 생성만 하고 throw를 안 해서 완전히 죽은 코드였음. 조건 반전 + throw 추가. 3. updatePublicCourse: userId를 받으면서 소유권 검증을 안 해 다른 사람의 공개 코스 제목/설명도 수정 가능했음 (IDOR). deletePublicCourses와 동일한 관리자 예외 패턴으로 소유권 검증 추가. ErrorStatus.PERMISSION_DENIED_PUBLIC_COURSE_UPDATE_EXCEPTION 추가. 4. recommendPublicCourse: sort 파라미터가 "scrap"/"date" 둘 다 아니면 Page 변수가 null로 남아 NPE. 이미 정의돼 있던 INVALID_SORT_PARAMETER_EXCEPTION을 실제로 사용하도록 수정.
|
Warning Review limit reached
Next review available in: 20 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
작업 배경
변경 사항
PublicCoursePublicCourseService.getPublicCourseDetailPublicCourseService.updatePublicCoursePublicCourseService.recommendPublicCourseErrorStatusPERMISSION_DENIED_PUBLIC_COURSE_UPDATE_EXCEPTION추가PublicCourseServiceTest영향 범위
PublicCourse.equals/hashCode변경은 이 엔티티를 비교하는 모든 곳(스크랩 매칭 로직 5곳)에 영향. 값 기반 비교로 바뀌어 기존에 놓치던 매칭이 이제 정확히 잡힘 — 동작이 "고쳐지는" 방향의 변경이라 별도 마이그레이션 불필요.updatePublicCourse는 이제 소유자가 아니면 403을 반환함 (기존엔 아무나 수정 가능했음) — 클라이언트가 이 케이스를 이미 정상 동작으로 오인해 의존하고 있었다면 영향 있을 수 있음.recommendPublicCourse는 잘못된 sort 값일 때 500(NPE) 대신 400을 반환함 — 클라이언트 에러 핸들링에 더 명확한 신호.@Cacheable)가 걸린 두 메서드(getMarathonPublicCourse, recommendPublicCourse)는 로직만 바뀌고 캐시 키/설정은 그대로.검증 매트릭스
나누어_떨어짐•
나누어_안_떨어짐•
코스가_없음정상_조회•
마라톤_코스_일부_없음•
존재하지_않는_유저정상_검색•
검색_결과_없음스크랩순_정렬•
최신순_정렬•
잘못된_정렬값정상_조회•
공개한_코스_없음삭제된_코스정상_조회_건물명_있음•
정상_조회_건물명_없음•
타인_코스•
업로더가_없는_코스•
스크랩_매칭정상_생성•
소유자가_아님•
이미_공개된_코스정상_삭제•
소유자가_아닌_코스_포함•
관리자는_소유자가_아니어도_삭제_가능소유자가_아니면_수정_불가•
관리자는_소유자가_아니어도_수정_가능•
정상_수정Test Plan
./gradlew build전체(기존 ServerApplicationTests 포함) 통과 확인🤖 Generated with Claude Code