Skip to content

test: HealthService 단위 테스트 추가 - #218

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

test: HealthService 단위 테스트 추가#218
unam98 merged 1 commit into
devfrom
tests/health-service-unit-tests

Conversation

@unam98

@unam98 unam98 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

작업 배경

  • 테스트 커버리지 확장 7단계(마지막). 러닝 기록의 건강 데이터(심박수/칼로리/존별 시간) 생성/조회/통계/삭제를 담당하는 HealthService에 단위 테스트 추가.

변경 사항

영역 내용
HealthServiceTest 4개 메서드 전체에 대해 정상/예외/경계값 테스트 22개 신규

이번엔 버그가 발견되지 않음. 소유권 검증(record.getRunnectUser().getId().equals(userId))을 4개 메서드 전부에서 일관되게 사용하고 있고, 동시성 경쟁으로 인한 유니크 제약 위반(DataIntegrityViolationException)도 미리 잡아서 409로 변환하는 등, 지금까지 테스트한 서비스 중 가장 방어적으로 잘 짜여있었음 — 다른 서비스들의 IDOR 패턴을 고칠 때 참고한 기준이 이 서비스였음.

영향 범위

  • 테스트 코드만 추가, 프로덕션 코드 변경 없음. 런타임 영향 없음.

검증 매트릭스

영향 범위 테스트 코드
건강 데이터 생성 - 정상/기본값/샘플 처리 정상_생성_샘플없음
정상_생성_샘플있음
기본_최대심박수_사용
건강 데이터 생성 - 소유권/유효성/중복 검증 존재하지_않는_레코드
소유자가_아님
평균심박수_0이하
칼로리_음수
심박수_샘플_초과
이미_존재하는_건강데이터
동시성_경쟁으로_인한_제약위반
건강 데이터 조회 - 있음/없음(404 아님)/소유권 정상_조회
건강데이터_없음
존재하지_않는_레코드
소유자가_아님
건강 데이터 통계 - 기간 검증/집계 정상_조회
집계_결과_없음
잘못된_날짜형식
종료일이_시작일보다_빠름
건강 데이터 삭제 - 정상/소유권/존재 여부 정상_삭제
존재하지_않는_레코드
소유자가_아님
건강데이터_없음

Test Plan

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

🤖 Generated with Claude Code

createHealthData/getHealthData/getHealthSummary/deleteHealthData 전체
메서드에 대해 정상 케이스 + 예외 케이스 + 경계값 검증 (22개).

버그는 발견되지 않음 — 소유권 검증(record.getRunnectUser().getId().equals(userId))을
일관되게 사용하고 있고, 동시성 경쟁으로 인한 유니크 제약 위반도
DataIntegrityViolationException을 잡아 409로 변환하는 등 이번에 테스트한
서비스 중 가장 방어적으로 잘 짜여있었음.
@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: 3 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: f8d42b6b-269a-44b7-b865-36244aff1717

📥 Commits

Reviewing files that changed from the base of the PR and between 92e9d55 and 145af70.

📒 Files selected for processing (1)
  • src/test/java/org/runnect/server/health/service/HealthServiceTest.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 a2218ca into dev Aug 5, 2026
2 checks passed
@unam98
unam98 deleted the tests/health-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