Skip to content

test: User/Record/PublicCourse 컨트롤러 @WebMvcTest 추가 + sort NPE 수정 - #228

Merged
unam98 merged 1 commit into
devfrom
tests/user-record-publiccourse-controller-tests
Aug 6, 2026
Merged

test: User/Record/PublicCourse 컨트롤러 @WebMvcTest 추가 + sort NPE 수정#228
unam98 merged 1 commit into
devfrom
tests/user-record-publiccourse-controller-tests

Conversation

@unam98

@unam98 unam98 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

작업 배경

  • 컨트롤러 @WebMvcTest 스윕의 두 번째 배치로, 규모가 큰 User/Record/PublicCourse 컨트롤러의 라우팅/@Valid 검증/@userid 인증/예외→HTTP 상태코드 매핑을 검증한다.
  • PublicCourseController의 정상 케이스 테스트 작성 중 GET /api/public-course를 쿼리 파라미터 없이 호출하면 500이 발생하는 실제 버그를 발견해 함께 수정했다.

변경 사항

영역 내용
common/resolver/sort/SortStatusIdResolver.java request.getQueryString()이 null일 때(쿼리 파라미터가 전혀 없을 때) NPE로 500이 나던 버그 수정 — sort 키가 없는 경우와 동일하게 기본값("date")으로 처리
user/controller/UserControllerTest.java (신규) User 4개 엔드포인트 (8 테스트)
record/controller/RecordControllerTest.java (신규) Record 4개 엔드포인트 (8 테스트)
publicCourse/controller/PublicCourseControllerTest.java (신규) PublicCourse 9개 엔드포인트 (14 테스트)

영향 범위

  • 버그 수정: GET /api/public-course(퍼블릭 코스 추천/메인 피드 엔드포인트)를 쿼리 파라미터 없이 호출하면(흔한 실제 클라이언트 호출 패턴) HttpServletRequest.getQueryString()이 null을 반환해 SortStatusIdResolvernull.split()으로 NPE → 500을 반환하던 버그. sort 키만 없는 경우(예: ?pageNo=1)는 이미 정상 처리되고 있었어서 그동안 드러나지 않았던 것으로 보인다. 이번 수정으로 쿼리 파라미터가 아예 없어도 기본 정렬("date")로 정상 처리된다.
  • [설계상 주의, 미수정] recommendPublicCoursepageNo@Positive가 붙어있지만 컨트롤러 클래스에 @Validated가 없어 실제로는 검증되지 않는다 (UserController의 appleAccessToken @NotBlank도 동일한 패턴). 테스트에는 실제 동작 그대로 반영했고, 별도 이슈로 남겨둔다.
  • 나머지는 테스트 전용 변경, 컨트롤러/서비스 로직 변경 없음.

검증 매트릭스

영향 범위 테스트 코드
GET /api/user 정상 조회 정상_조회
GET /api/user 존재하지 않는 유저 404 존재하지_않는_유저
PATCH /api/user 정상 변경 정상_변경
PATCH /api/user 닉네임 빈값 400 닉네임_빈값
GET /api/user/{id} 정상 조회 정상_조회
DELETE /api/user 정상 삭제 정상_삭제
DELETE /api/user appleAccessToken 헤더 없어도 통과 애플토큰_헤더_없음
POST /api/record 정상 생성 정상_생성
POST /api/record title 없으면 400 제목_없음
GET /api/record/user 정상 조회 정상_조회
PATCH /api/record/{id} 정상 수정 정상_수정
PATCH /api/record/{id} title 없으면 400 제목_없음
PUT /api/record 정상 삭제 정상_삭제
PUT /api/record 목록 비어있으면 400 목록_비어있음
GET /api/public-course 정상 조회 (쿼리 없음, NPE 수정 검증) 정상_조회
GET /api/public-course sort 유효하지 않으면 400 정렬값_유효하지_않음
GET /api/public-course pageNo=0 (검증 미동작, 실제 동작 문서화) 페이지번호_0이어도_검증되지_않음
GET /api/public-course/search 정상 검색 정상_검색
GET /api/public-course/search keyword 없으면 400 검색어_없음
GET /api/public-course/marathon 정상 조회 정상_조회
POST /api/public-course 정상 생성 정상_생성
POST /api/public-course title 없으면 400 제목_없음
GET /api/public-course/detail/{id} 존재하지 않으면 400 존재하지_않음
GET /api/public-course/user 정상 조회 정상_조회
GET /api/public-course/total-page-count 정상 조회 정상_조회
PUT /api/public-course 정상 삭제 정상_삭제
PUT /api/public-course 목록 비어있으면 400 목록_비어있음
PATCH /api/public-course/{id} 정상 수정 정상_수정
PATCH /api/public-course/{id} title 없으면 400 제목_없음
PATCH /api/public-course/{id} 소유권 없으면 403 소유권_없음
SortStatusIdResolver null 쿼리스트링 수정 코드

Test Plan

  • 배치 3개 컨트롤러 테스트 30/30 통과
  • 로컬 postgres/redis 기동 후 ./gradlew test 전체 243/243 통과

🤖 Generated with Claude Code

GET /api/public-course를 쿼리 파라미터 없이(예: 그냥 /api/public-course) 호출하면
HttpServletRequest.getQueryString()이 null을 반환하는데, SortStatusIdResolver가
이를 null 체크 없이 split()하다가 NPE(500)로 이어지던 버그를 테스트 작성 중 발견해
수정했다. sort 키가 없는 경우와 동일하게 기본값("date")으로 처리하도록 했다.
@unam98 unam98 self-assigned this Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@unam98, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d7da151-8da1-424c-a446-d1fc654004ea

📥 Commits

Reviewing files that changed from the base of the PR and between a112678 and 092690d.

📒 Files selected for processing (4)
  • src/main/java/org/runnect/server/common/resolver/sort/SortStatusIdResolver.java
  • src/test/java/org/runnect/server/publicCourse/controller/PublicCourseControllerTest.java
  • src/test/java/org/runnect/server/record/controller/RecordControllerTest.java
  • src/test/java/org/runnect/server/user/controller/UserControllerTest.java

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@unam98
unam98 merged commit 03050ac into dev Aug 6, 2026
2 checks passed
@unam98
unam98 deleted the tests/user-record-publiccourse-controller-tests branch August 6, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants