Skip to content

✨ [OMF-339] 단위 테스트 추가 - Member 도메인 (PR 2/3)#157

Merged
KJaeKwan merged 2 commits into
developfrom
feat/OMF-339-member-tests
May 12, 2026
Merged

✨ [OMF-339] 단위 테스트 추가 - Member 도메인 (PR 2/3)#157
KJaeKwan merged 2 commits into
developfrom
feat/OMF-339-member-tests

Conversation

@KJaeKwan

@KJaeKwan KJaeKwan commented May 10, 2026

Copy link
Copy Markdown
Collaborator

✨ Related Issue

OMF-339 단위 테스트 작성 - Member 도메인 (PR 2/3)


📌 Task Details

Member 도메인 서비스 레이어 및 엔티티 비즈니스 로직을 Mockito 기반으로 커버합니다.

테스트 대상 (총 30개 테스트 케이스)

  • MemberTest (14개) — Member 엔티티 비즈니스 로직

    • increaseCoin / decreaseCoin: 양수 검증, 부족 시 예외, 0 이하 예외
    • increasePromotionPoint: 0 이하 예외
    • update: null 필드 무시 검증
    • updateAgreePolicy: SERVICE_AGREED / MARKETING_AGREED / null 처리
    • memberConnectOut: TOSS_CONNECT_OUT 상태 변경
    • completeOnboarding: 거주지·관심사 설정, null interests 처리
  • MemberQueryServiceTest (7개) — 조회 서비스

    • getMemberByUserKey: 존재/미존재 케이스
    • getMemberInfo: 응답 필드 정확성, 미존재 예외
    • validateAdminRoleAndGetMemberIdByUserKey: repository 위임 확인
    • searchMembers: 목록 변환, 빈 목록
    • getUsernameByUserKey: repository 위임 확인
  • MemberModifyServiceTest (9개) — 수정/삭제 서비스

    • upsertMember: 기존 멤버 업데이트 vs 신규 생성, 동의 정책 처리
    • changeMemberStatusTossConnectOut: 상태 변경 및 저장 검증
    • changeProfileImage: 존재/미존재
    • completeOnboarding: 존재/미존재
    • deleteById: repository 위임 확인

전체 PR 계획 (3개로 재구성)

PR 범위
PR 1/3 순수 비즈니스 로직 (환불/변환/CSV/할인코드)
PR 2/3 (현재) Member 도메인
PR 3/3 잔여 서비스 레이어 전체 (Discount Query / Survey / Participation)

💬 Review Requirements (Optional)

없음

- MemberTest: 코인 증감, 포인트, 동의 정책, 온보딩, 상태 변경 등 엔티티 비즈니스 로직 (14개)
- MemberQueryServiceTest: 조회, 검색, 위임 로직 (7개)
- MemberModifyServiceTest: upsertMember(신규/기존), 프로필, 온보딩, 삭제 (9개)
@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 32715260-7ec8-45f1-9eaf-6f191151c7d3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

이 PR은 Member 도메인 엔티티 및 관련 서비스 클래스에 대한 포괄적인 JUnit 테스트 스위트를 추가합니다. 동전 작업, 동의 정책, 프로필 관리, 온보딩 및 저장소 위임 패턴을 검증합니다.

Changes

Member Domain Test Coverage

Layer / File(s) Summary
Member Entity Tests
src/test/java/OneQ/OnSurvey/domain/member/MemberTest.java
Member 엔티티는 동전 증감, 프로모션 포인트 증가, 필드 업데이트, 동의 정책 관리, TOSS 연동 해제, 프로필 URL 변경 및 온보딩 완료를 검증하며, 무효한 금액 및 불충분한 잔액에 대해 CustomException을 throw합니다.
MemberModifyService Tests
src/test/java/OneQ/OnSurvey/domain/member/service/MemberModifyServiceTest.java
MemberModifyService는 기존 회원 업데이트 시 저장소 저장을 스킵하고, 신규 회원 생성 시 저장소에 저장하며, 동의 약관 처리, 상태 전환, 프로필 이미지 업데이트 및 회원 없음 시 MEMBER_NOT_FOUND 예외를 throw합니다.
MemberQueryService Tests
src/test/java/OneQ/OnSurvey/domain/member/service/MemberQueryServiceTest.java
MemberQueryService는 사용자 키로 회원을 조회하고 MemberInfoResponse로 매핑하며, 검색 결과를 MemberSearchResult 목록으로 변환하고, 회원 없음 시 MEMBER_NOT_FOUND 예외를 throw합니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • On-Survey/Backend#105: Member.update가 null 필드를 무시하도록 변경한 PR으로, 이 PR의 Member.update 테스트와 직접 대응됩니다.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 제목이 PR의 주요 변경사항을 명확하게 설명합니다. Member 도메인에 대한 단위 테스트 추가라는 핵심 내용을 효과적으로 전달합니다.
Description check ✅ Passed 설명이 제공된 템플릿을 따르고 있으며, 관련 이슈, 상세한 테스트 대상 및 테스트 케이스를 포함합니다. 전체 PR 계획도 명확하게 제시됩니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/OMF-339-member-tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/test/java/OneQ/OnSurvey/domain/member/MemberTest.java`:
- Around line 83-92: Add a negative-boundary test for decreaseCoin in
MemberTest: add a new assertion that calling member.decreaseCoin(-1L) throws
CustomException with error code CoinErrorCode.COIN_NOT_POSITIVE, mirroring the
existing zero-case; reference the existing test method
decreaseCoin_zero_throwsException and the classes/members Member, decreaseCoin,
CustomException, and CoinErrorCode when adding the new test case.
- Around line 104-113: Add a test in MemberTest that verifies
Member.increasePromotionPoint throws the same CustomException with
CoinErrorCode.COIN_NOT_POSITIVE when passed a negative value; locate the test
class MemberTest and add a new `@Test` (e.g.,
increasePromotionPoint_negative_throwsException) which constructs a Member via
buildMember() and asserts that calling member.increasePromotionPoint(-1L)
results in the CustomException whose getErrorCode() equals
CoinErrorCode.COIN_NOT_POSITIVE, mirroring the existing zero-case assertion
style.

In
`@src/test/java/OneQ/OnSurvey/domain/member/service/MemberModifyServiceTest.java`:
- Around line 88-103: Test currently mixes serviceAgreed with marketingAgreed;
update the test method upsertMember_withServiceAgreed_setsServiceAgreedTrue to
pass only "serviceAgreed" in the DecryptedLoginMeResponse scopes, set
marketingAgreed expectation to false, and assert result.isServiceAgreed() is
true and result.isMarketingAgreed() is false so the
MemberModifyService.upsertMember behavior for service-only consent is verified
in isolation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 56c4fbdd-0770-4338-b348-3d02e3724f74

📥 Commits

Reviewing files that changed from the base of the PR and between 1ce6463 and b0a7269.

📒 Files selected for processing (3)
  • src/test/java/OneQ/OnSurvey/domain/member/MemberTest.java
  • src/test/java/OneQ/OnSurvey/domain/member/service/MemberModifyServiceTest.java
  • src/test/java/OneQ/OnSurvey/domain/member/service/MemberQueryServiceTest.java

Comment thread src/test/java/OneQ/OnSurvey/domain/member/MemberTest.java
Comment thread src/test/java/OneQ/OnSurvey/domain/member/MemberTest.java
@KJaeKwan KJaeKwan self-assigned this May 10, 2026
@KJaeKwan KJaeKwan added the ✅test 테스트 관련 label May 10, 2026
@KJaeKwan KJaeKwan changed the title ✨ [OMF-339] 단위 테스트 추가 - Member 도메인 (PR 2/9) ✨ [OMF-339] 단위 테스트 추가 - Member 도메인 (PR 2/3) May 10, 2026
@KJaeKwan KJaeKwan merged commit 39b3844 into develop May 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✅test 테스트 관련

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant