Skip to content

Conversation

@thezz9
Copy link
Collaborator

@thezz9 thezz9 commented Jun 30, 2025

작업 내용

  • 도메인 레이어 테스트 코드 작성

Summary by CodeRabbit

  • 테스트
    • SubmissionDomainService에 대한 새로운 단위 테스트가 추가되었습니다.
    • LanguageDomainServiceTest의 패키지 선언 및 import가 정리되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Jun 30, 2025

Walkthrough

테스트 코드의 패키지 선언과 import가 수정되었으며, 새로운 SubmissionDomainServiceTest 테스트 클래스가 추가되었습니다. 이 클래스는 SubmissionDomainService의 다양한 동작 시나리오에 대해 Mockito를 활용하여 단위 테스트를 수행합니다.

Changes

파일/경로 변경 요약
src/test/java/org/ezcode/codetest/domain/language/LanguageDomainServiceTest.java 패키지 선언 변경 및 LanguageDomainService import 추가
src/test/java/org/ezcode/codetest/domain/submission/SubmissionDomainServiceTest.java SubmissionDomainService의 다양한 동작을 검증하는 새로운 단위 테스트 클래스 추가

Sequence Diagram(s)

sequenceDiagram
    participant Test as SubmissionDomainServiceTest
    participant Service as SubmissionDomainService
    participant Repo as SubmissionRepository
    participant Context as SubmissionContext
    participant UserResult as UserProblemResult

    Test->>Service: finalizeSubmission(submission, context)
    Service->>Repo: save(submission)
    Service->>Context: incrementSubmissionCount()
    Service->>UserResult: updateResult()
    Service->>Repo: findByUserId(userId)
    Service->>Repo: countWeeklySolveByUserIdAndDateRange(userId, start, end)
Loading

Suggested reviewers

  • NCookies
  • minjee2758
  • Kimminu7
  • pokerbearkr
  • chat26666

Poem

테스트 토끼가 깡총깡총,
새 서비스 검증에 뛰어들었죠!
패키지 정리, import 보강,
제출 서비스 꼼꼼히 점검,
모두가 안심할 수 있도록,
코드숲에 평화가 찾아왔어요! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/test/java/org/ezcode/codetest/domain/submission/SubmissionDomainServiceTest.java (1)

314-334: 테스트 케이스 실패 조건의 명확성을 개선해주세요.

현재 input.isCorrect()true를 반환하지만 timeEfficient()false를 반환하여 실패하는 시나리오인데, 테스트 의도가 명확하지 않을 수 있습니다.

테스트 시나리오를 더 명확하게 하기 위해 다음과 같이 개선하는 것을 고려해보세요:

@Test
-@DisplayName("실패한 테스트케이스일 때")
+@DisplayName("논리적으로 정답이지만 시간 효율성으로 실패한 테스트케이스일 때")
void whenFailed() {

또는 더 직관적인 실패 케이스로 변경:

-given(input.isCorrect()).willReturn(true);
-given(input.timeEfficient()).willReturn(false);
+given(input.isCorrect()).willReturn(false);
+given(input.timeEfficient()).willReturn(true);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 922522e and 297eaab.

📒 Files selected for processing (2)
  • src/test/java/org/ezcode/codetest/domain/language/LanguageDomainServiceTest.java (2 hunks)
  • src/test/java/org/ezcode/codetest/domain/submission/SubmissionDomainServiceTest.java (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.654Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.
Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/domain/problem/model/entity/ProblemLanguage.java:3-3
Timestamp: 2025-06-06T07:57:51.226Z
Learning: 사용자 thezz9는 Language 엔티티를 Submission 도메인으로 이동시킨 이유가 "제출하려면 필요해서"라고 설명했으며, Problem 도메인과 Submission 도메인 간의 종속성 위반 문제에 대한 해결 방안을 고민하고 있다.
Learnt from: chat26666
PR: ezcode-my/backend#37
File: src/main/java/org/ezcode/codetest/infrastructure/elasticsearch/repository/ProblemElasticsearchRepositoryDsl.java:10-10
Timestamp: 2025-06-06T19:56:27.759Z
Learning: When user chat26666 mentions that code was implemented in a previous PR but explanation was missing, they may submit a follow-up PR just to add documentation/explanation without the actual implementation code.
Learnt from: thezz9
PR: ezcode-my/backend#30
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:44-46
Timestamp: 2025-06-04T13:12:17.636Z
Learning: SubmissionService에서 "2 10" 입력값과 "12" 기대출력이 하드코딩되어 있는 것은 테스트 단계의 의도적인 구현이며, 추후 Problem 엔티티의 실제 테스트케이스로 대체 예정입니다.
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java:25-41
Timestamp: 2025-06-19T06:37:57.845Z
Learning: User thezz9 tends to skip validation for scenarios they consider unlikely to occur, but is willing to implement defensive programming practices when suggested for code robustness.
Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:93-96
Timestamp: 2025-06-28T02:04:24.910Z
Learning: User thezz9 sometimes temporarily uses less secure or inconsistent exception handling (like RuntimeException with raw error bodies) for debugging purposes when error messages are being hidden in the normal application flow, but acknowledges this as technical debt and fixes it once debugging is complete.
src/test/java/org/ezcode/codetest/domain/submission/SubmissionDomainServiceTest.java (2)
Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/domain/submission/dto/SubmissionData.java:47-58
Timestamp: 2025-06-06T07:59:41.806Z
Learning: SubmissionData.withAggregatedStats() 메서드에서 testCaseList는 상위 프로세스(base() 메서드의 problemInfo.testcaseList())에서 이미 null 체크가 처리되어 오므로 추가적인 null 체크가 불필요함
Learnt from: thezz9
PR: ezcode-my/backend#30
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:44-46
Timestamp: 2025-06-04T13:12:17.636Z
Learning: SubmissionService에서 "2 10" 입력값과 "12" 기대출력이 하드코딩되어 있는 것은 테스트 단계의 의도적인 구현이며, 추후 Problem 엔티티의 실제 테스트케이스로 대체 예정입니다.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (10)
src/test/java/org/ezcode/codetest/domain/language/LanguageDomainServiceTest.java (2)

1-1: 패키지 구조 개선이 적절합니다.

테스트 클래스를 도메인 레벨로 이동시켜 새로 추가된 SubmissionDomainServiceTest와 일관된 패키지 구조를 만들었습니다.


13-13: 명시적 import 추가로 가독성이 향상되었습니다.

패키지 변경에 따른 필요한 import 구문이 적절히 추가되었습니다.

src/test/java/org/ezcode/codetest/domain/submission/SubmissionDomainServiceTest.java (8)

86-125: 첫 번째 제출 통과 시나리오 테스트가 잘 구현되었습니다.

Given-When-Then 구조와 적절한 Mock 설정으로 테스트 로직이 명확합니다. 제출 저장, 카운트 증가, 사용자 문제 결과 저장 등의 상호작용을 정확히 검증하고 있습니다.


127-166: 첫 번째 제출 실패 시나리오 테스트가 적절합니다.

통과 시나리오와 대비되는 실패 케이스를 정확히 테스트하고 있으며, incrementCorrectSubmissions()가 호출되지 않는 것을 never()로 검증한 것이 좋습니다.


168-207: 재제출 시나리오의 상태 전환 로직이 정확히 테스트되었습니다.

이전 오답 기록에서 정답으로 전환되는 시나리오를 잘 다루고 있으며, updateUserProblemResult 호출 검증이 적절합니다.


209-249: 재제출 실패 시나리오의 경계 조건 테스트가 견고합니다.

이전 오답 기록에서 다시 오답인 경우 불필요한 업데이트가 발생하지 않는 것을 never()로 검증한 로직이 정확합니다.


251-291: 이미 정답인 문제의 재제출 시나리오가 적절히 처리되었습니다.

정답 기록이 있는 상태에서의 재제출 시 불필요한 카운트 증가나 업데이트가 발생하지 않도록 하는 로직을 잘 검증하고 있습니다.


336-353: 레포지토리 위임 패턴 테스트가 적절합니다.

서비스가 레포지토리로 올바르게 위임하고 결과를 그대로 반환하는지 검증하는 테스트가 정확합니다.


355-375: 주간 통계 조회 테스트가 잘 구현되었습니다.

날짜 범위를 사용한 조회 기능과 레포지토리 위임 패턴을 적절히 테스트하고 있습니다.


74-84: 테스트 설정이 체계적으로 구성되었습니다.

@BeforeEach에서 공통 테스트 데이터를 초기화하여 코드 중복을 줄이고 유지보수성을 높였습니다.

@thezz9 thezz9 merged commit f78c761 into dev Jun 30, 2025
2 checks passed
@thezz9 thezz9 deleted the test/submission-domain branch June 30, 2025 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants