Skip to content

test: ScrapService 단위 테스트 추가 + 스크랩 취소 NPE 수정 - #217

Merged
unam98 merged 1 commit into
devfrom
tests/scrap-service-unit-tests
Aug 5, 2026
Merged

test: ScrapService 단위 테스트 추가 + 스크랩 취소 NPE 수정#217
unam98 merged 1 commit into
devfrom
tests/scrap-service-unit-tests

Conversation

@unam98

@unam98 unam98 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

작업 배경

  • 테스트 커버리지 확장 6단계. 스크랩 생성/취소/조회를 담당하는 ScrapService에 단위 테스트 추가, 테스트 작성 중 발견한 NPE 버그 수정.

변경 사항

영역 내용
ScrapService.createAndDeleteScrap 스크랩한 적 없는 코스에 취소 요청이 오면(scrap == null) NPE 대신 조용히 무시하도록 수정
ScrapServiceTest 2개 메서드 전체에 대해 정상/예외/경계값 테스트 9개 신규

영향 범위

  • 스크랩 취소 API에 "스크랩한 적 없는 코스"를 넘기는 경우 기존엔 500(NPE)이 났는데, 이제 정상 응답(idempotent)으로 처리됨. 클라이언트의 중복 취소 요청이나 race condition에서 실제로 발생할 수 있는 경로라 영향 범위 있음 — 다만 방향은 "에러가 사라지는" 쪽이라 안전.
  • 런타임 영향 없음 (새 의존성/DB 스키마 변경 없음).

검증 매트릭스

영향 범위 테스트 코드
스크랩 생성/재활성화/취소 신규_스크랩
기존_스크랩_재활성화
스크랩_취소
스크랩 취소 NPE 버그 수정 검증 스크랩한_적_없는_코스_취소_요청은_무시된다
스크랩 생성/취소 - 유저/공개코스 없음 존재하지_않는_유저
존재하지_않는_공개코스
스크랩 목록 조회 정상_조회
스크랩_없음
조회_결과가_없으면_예외

Test Plan

  • 로컬에서 신규 테스트 9개 전부 통과
  • 기존 서비스 테스트들과 함께 실행해도 간섭 없음 확인
  • 로컬 DB/Redis 띄우고 ./gradlew build 전체(기존 ServerApplicationTests 포함) 통과 확인

🤖 Generated with Claude Code

createAndDeleteScrap/getScrapCourseByUser 전체 메서드에 대해
정상 케이스 + 예외 케이스 + 경계값 검증 (9개).

테스트 작성 중 발견해서 수정한 버그:
- createAndDeleteScrap: 스크랩한 적 없는 코스를 "취소"(scrapTF=false)
  요청하면 scrap 변수가 null이라 scrap.updateScrapTF(false) 호출 시
  바로 NPE(500)가 났음. 클라이언트가 중복 취소 요청을 보내거나
  race condition만 있어도 쉽게 재현 가능한 케이스라 조건 분기 추가로
  null이면 조용히 무시하도록 수정 (idempotent하게).
@unam98 unam98 self-assigned this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 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: 4 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: 8db2e370-2e71-44ce-8462-a70ae5f1a120

📥 Commits

Reviewing files that changed from the base of the PR and between 92e9d55 and 6cad2f2.

📒 Files selected for processing (2)
  • src/main/java/org/runnect/server/scrap/service/ScrapService.java
  • src/test/java/org/runnect/server/scrap/service/ScrapServiceTest.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 bf0b7ef into dev Aug 5, 2026
2 checks passed
@unam98
unam98 deleted the tests/scrap-service-unit-tests branch August 5, 2026 10:46
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