-
Notifications
You must be signed in to change notification settings - Fork 3
test(submission): add domain layer tests #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough테스트 코드의 패키지 선언과 import가 수정되었으며, 새로운 Changes
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)
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 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에서 공통 테스트 데이터를 초기화하여 코드 중복을 줄이고 유지보수성을 높였습니다.
작업 내용
Summary by CodeRabbit