Skip to content

[fix] #107 참가자 조회 시 null 반환 제거 및 예외 처리 방식 통일#108

Merged
2hyunjinn merged 5 commits intomainfrom
fix/#107
May 5, 2025
Merged

[fix] #107 참가자 조회 시 null 반환 제거 및 예외 처리 방식 통일#108
2hyunjinn merged 5 commits intomainfrom
fix/#107

Conversation

@2hyunjinn
Copy link
Copy Markdown
Member

@2hyunjinn 2hyunjinn commented May 5, 2025

📌 PR 제목

[fix] #107 참가자 조회 시 null 반환 제거 및 예외 처리 방식 통일

📌 PR 내용

  • 참가자 조회 시 null 반환을 제거하고, 예외를 던지는 방식(getParticipantOrThrow)으로 전면 통일했습니다.
  • 중복 참가자 확인 로직(createParticipant)에서는 유일하게 null 허용 방식(getParticipant)을 유지합니다.
  • 이에 따라 Facade 및 테스트 코드 전반에서 불필요한 null 체크를 제거했습니다.

🛠 작업 내용

  • ParticipantService에 getParticipantOrThrow 메서드 명시적으로 분리
  • ParticipantFacade, FestivalFacade, PointFacade의 조회 로직 예외 방식으로 일원화
  • 테스트 코드 내 mock 및 예외 처리 방식 수정
  • 중복 참가자 확인은 getParticipant로 유지

🔍 관련 이슈

Closes #107

📸 스크린샷 (Optional)

📚 레퍼런스 (Optional)

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling when retrieving participant information, ensuring clearer feedback if a participant is not found.
  • Refactor
    • Streamlined internal logic for participant validation and retrieval, reducing redundant checks and simplifying control flow.
  • Tests
    • Updated tests to reflect new participant retrieval and error handling methods, ensuring continued reliability and accuracy.

@2hyunjinn 2hyunjinn added the fix Further information is requested label May 5, 2025
@2hyunjinn 2hyunjinn self-assigned this May 5, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented May 5, 2025

"""

Walkthrough

This change refactors participant retrieval logic throughout the codebase. The previous approach, which involved methods returning null or requiring explicit null checks, is replaced by a consistent use of getParticipantOrThrow, which throws an exception when a participant is not found. This update affects the service, facade, and test layers, ensuring that exception handling for missing participants is centralized and standardized. Redundant validation methods and helper functions are removed, and test cases are updated to reflect the new error handling mechanism.

Changes

Files/Paths Change Summary
src/main/java/org/festimate/team/api/facade/FestivalFacade.java,
src/main/java/org/festimate/team/api/facade/ParticipantFacade.java,
src/main/java/org/festimate/team/api/facade/PointFacade.java,
src/main/java/org/festimate/team/domain/matching/service/impl/MatchingServiceImpl.java
Refactored participant retrieval to use getParticipantOrThrow instead of null checks or validateParticipation. Removed redundant helper methods and blank lines.
src/main/java/org/festimate/team/domain/participant/service/ParticipantService.java Renamed getParticipant to getParticipantOrThrow, added a new getParticipant method, and removed validateParticipation.
src/main/java/org/festimate/team/domain/participant/service/impl/ParticipantServiceImpl.java Replaced validateParticipation with getParticipantOrThrow that throws if not found, returning the participant otherwise.
src/test/java/org/festimate/team/api/facade/ParticipantFacadeTest.java Updated tests to mock and verify getParticipantOrThrow behavior, removed obsolete mocking and assertions.
src/test/java/org/festimate/team/api/facade/PointFacadeTest.java Updated test mocks to use getParticipantOrThrow instead of getParticipant.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Facade
    participant ParticipantService
    participant Repository

    Client->>Facade: getParticipant(userId, festivalId)
    Facade->>ParticipantService: getParticipantOrThrow(user, festival)
    ParticipantService->>Repository: findByUserAndFestival(user, festival)
    alt Participant found
        Repository-->>ParticipantService: Participant
        ParticipantService-->>Facade: Participant
        Facade-->>Client: Participant
    else Participant not found
        Repository-->>ParticipantService: null
        ParticipantService-->>Facade: throw FestimateException
        Facade-->>Client: Exception
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Refactor participant retrieval to throw exception instead of returning null; ensure facades and tests use this consistently (#107)

Possibly related PRs

  • Team-Festimate/festimate-server#103: Related to participant retrieval and exception handling refactor, focusing on preventing duplicate participant creation and centralizing existence checks.

Suggested labels

refactor

Poem

A hop and a skip through the code we go,
No more nulls—exceptions now flow!
Participants found, or thrown to the sky,
Consistent and clear, our standards held high.
With every refactor, the garden grows neat—
A rabbit’s delight: this change is a treat! 🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbed4d4 and 630e99e.

📒 Files selected for processing (1)
  • src/test/java/org/festimate/team/domain/matching/service/impl/MatchingServiceImplTest.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (1)
src/test/java/org/festimate/team/domain/matching/service/impl/MatchingServiceImplTest.java (1)

87-87: Correctly updated mock to use the new service method.

The test correctly updates the mock to use getParticipantOrThrow instead of the previous getParticipant method, aligning with the PR objective of standardizing participant retrieval logic to use exception-throwing methods instead of null-returning ones.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions bot commented May 5, 2025

Test Results

40 tests   40 ✅  1s ⏱️
10 suites   0 💤
10 files     0 ❌

Results for commit 630e99e.

♻️ This comment has been updated with latest results.

@2hyunjinn 2hyunjinn merged commit 28eea30 into main May 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[hotfix] 참가자 조회 시 null 반환 제거 및 예외 처리 방식 통일

1 participant