Skip to content

Conversation

@thezz9
Copy link
Collaborator

@thezz9 thezz9 commented Jun 29, 2025

작업 내용

  • 애플리케이션 레이어 테스트 코드 작성

Summary by CodeRabbit

  • Tests
    • GitHub 연동, 비동기 채점, 이벤트 발행, 제출 서비스에 대한 단위 테스트가 추가되었습니다.
    • 테스트용 의존성(mockito-inline)이 추가되었습니다.
    • 일부 테스트 파일의 패키지 선언이 수정되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Jun 29, 2025

Walkthrough

Gradle 빌드 설정에 Mockito 인라인 모킹 라이브러리가 테스트 의존성으로 추가되었습니다. 테스트 코드에서는 새로운 서비스 테스트 클래스들이 추가되었고, 기존 테스트 파일의 패키지 선언이 수정되었습니다. 각 서비스의 주요 비즈니스 로직에 대한 단위 테스트가 세분화되어 도입되었습니다.

Changes

파일/경로 변경 요약
build.gradle org.mockito:mockito-inline:4.+ 테스트 의존성 추가
src/test/java/org/ezcode/codetest/application/language/LanguageServiceTest.java 패키지 선언 변경
src/test/java/org/ezcode/codetest/application/submission/GitHubPushServiceTest.java
src/test/java/org/ezcode/codetest/application/submission/JudgementServiceAsyncTest.java
src/test/java/org/ezcode/codetest/application/submission/JudgementServiceEventTest.java
src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.java
새로운 서비스 테스트 클래스 추가
- GitHubPushServiceTest
- JudgementServiceAsyncTest
- JudgementServiceEventTest
- SubmissionServiceTest

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test
    participant Service as ServiceUnderTest
    participant MockDep as MockedDependency

    Test->>Service: 메서드 호출 (예: runTestcases, pushSolutionToRepo)
    Service->>MockDep: 의존성 호출 (예: JudgeClient, GitHubClient 등)
    alt 성공 시나리오
        MockDep-->>Service: 정상 응답
        Service-->>Test: 결과 반환/이벤트 발행
    else 실패 시나리오
        MockDep-->>Service: 예외 발생
        Service->>MockDep: 예외 알림/이벤트 발행
        Service-->>Test: 예외 반환/에러 이벤트 발행
    end
Loading

Suggested labels

Test

Poem

🐰
테스트 토끼가 깡충 뛰며
새로운 클래스에 인라인 모킹을 더해요.
서비스 로직 꼼꼼히 검증하며
예외와 성공 모두 놓치지 않죠!
코드의 숲에 평화가 찾아오길,
오늘도 토끼는 테스트를 즐깁니다.
🧪✨


📜 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 7ed0a5a and fec7075.

📒 Files selected for processing (1)
  • src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.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: 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/domain/problem/model/dto/SubmissionData.java:42-53
Timestamp: 2025-06-04T13:12:16.729Z
Learning: 사용자 thezz9는 개발 시 기능적 정확성을 먼저 달성한 후 세부 리팩터링을 나중에 하는 접근 방식을 선호한다. 테스트 단계에서는 하드코딩된 값도 허용한다.
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/application/submission/SubmissionServiceTest.java (5)
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:142-147
Timestamp: 2025-06-19T07:00:53.895Z
Learning: SubmissionService.getCodeReview() 메서드에서 토큰 차감을 리뷰 요청 전에 수행하는 이유: OpenAI 서버 장애보다 유저 토큰 부족 상황이 더 빈번하므로, 확률이 높은 실패 케이스를 먼저 체크하여 불필요한 처리를 방지함. OpenAI 서버 장애 시에는 OpenAIClient에서 트랜잭션 롤백으로 토큰 복원이 처리됨.
Learnt from: thezz9
PR: ezcode-my/backend#98
File: src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java:17-22
Timestamp: 2025-06-25T01:24:30.754Z
Learning: JudgeClient에서 모든 예외를 SubmissionException으로 래핑해서 넘길 계획이므로, SubmissionErrorEvent.resolveCode() 메서드의 캐스팅은 안전할 예정임.
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#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#73
File: src/main/resources/templates/submit-test.html:135-135
Timestamp: 2025-06-18T11:41:58.457Z
Learning: src/main/resources/templates/submit-test.html 파일은 테스트용 파일로, isCorrect 값의 하드코딩은 의도적이며 사용자가 UI 요소를 통해 정답/오답 상태를 선택할 수 있도록 개선 예정입니다.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (8)
src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.java (8)

1-46: 임포트와 패키지 선언이 적절합니다

필요한 의존성들이 체계적으로 임포트되어 있고, 패키지 구조도 올바릅니다. 정적 임포트를 사용해 테스트 코드의 가독성을 높인 점도 좋습니다.


47-117: 모킹 설정과 테스트 데이터 초기화가 적절합니다

MockitoExtension을 사용한 모킹 설정이 올바르고, @beforeeach에서 테스트에 필요한 기본 데이터를 적절히 초기화하고 있습니다. 한국어 DisplayName 사용도 프로젝트 특성에 맞습니다.


125-145: 제출 큐잉 성공 테스트가 잘 구현되었습니다

argThat을 사용해 SubmissionMessage의 각 필드를 검증하는 방식이 효과적입니다. startsWith를 사용해 동적으로 생성되는 sessionKey를 검증하는 것도 적절한 접근입니다.


149-172: 비동기 처리 전체 플로우 테스트가 포괄적입니다

ArgumentCaptor를 사용해 SubmissionContext를 캡처하고, 모든 서비스 호출 순서를 검증하는 방식이 우수합니다. 락 해제까지 포함해 전체 플로우를 완전히 검증하고 있습니다.


176-218: 제출 내역 그룹핑 테스트가 체계적입니다

여러 Submission 객체를 생성하고 문제별로 그룹핑되는 로직을 적절히 테스트하고 있습니다. 각 그룹의 크기를 검증하는 어설션도 정확합니다.


222-244: 코드 리뷰 플로우 테스트가 완전합니다

토큰 차감과 리뷰 응답 반환을 모두 검증하고 있어, 학습된 내용에서 언급된 "토큰 차감을 리뷰 요청 전에 수행하는 로직"을 올바르게 테스트하고 있습니다.


247-266: 락 획득 실패 시나리오가 정확히 구현되었습니다

lockManager.tryLock이 false를 반환할 때 적절한 예외가 발생하는지 검증하고 있습니다. 예외 타입과 메시지를 모두 확인하는 것이 좋습니다.


270-293: 예외 처리 플로우가 완벽하게 테스트되었습니다

언어 조회 실패 시 에러 이벤트 발행, 예외 알림, 락 해제가 모두 수행되는지 검증하고 있어 예외 상황에서의 정리 작업이 누락되지 않도록 보장합니다.

✨ 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/application/submission/SubmissionServiceTest.java (1)

134-145: 큐 메시지 검증 로직 개선 제안

현재 argThat을 사용한 검증이 잘 구현되어 있지만, 더 명확한 검증을 위해 ArgumentCaptor 사용을 고려해보세요:

-        then(queueProducer).should()
-            .enqueue(argThat(msg ->
-                msg.sessionKey().startsWith(sessionKey) &&
-                msg.problemId().equals(problemId) &&
-                msg.languageId().equals(languageId) &&
-                msg.sourceCode().equals(sourceCode)
-            ));
+        ArgumentCaptor<SubmissionMessage> msgCaptor = ArgumentCaptor.forClass(SubmissionMessage.class);
+        then(queueProducer).should().enqueue(msgCaptor.capture());
+        SubmissionMessage capturedMsg = msgCaptor.getValue();
+        assertThat(capturedMsg.sessionKey()).startsWith(sessionKey);
+        assertThat(capturedMsg.problemId()).isEqualTo(problemId);
+        assertThat(capturedMsg.languageId()).isEqualTo(languageId);
+        assertThat(capturedMsg.sourceCode()).isEqualTo(sourceCode);

더 세밀한 검증과 오류 시 명확한 메시지를 제공할 수 있습니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1360305 and da06ded.

📒 Files selected for processing (6)
  • build.gradle (1 hunks)
  • src/test/java/org/ezcode/codetest/application/language/LanguageServiceTest.java (1 hunks)
  • src/test/java/org/ezcode/codetest/application/submission/GitHubPushServiceTest.java (1 hunks)
  • src/test/java/org/ezcode/codetest/application/submission/JudgementServiceAsyncTest.java (1 hunks)
  • src/test/java/org/ezcode/codetest/application/submission/JudgementServiceEventTest.java (1 hunks)
  • src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.java (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 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: 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/domain/problem/model/dto/SubmissionData.java:42-53
Timestamp: 2025-06-04T13:12:16.729Z
Learning: 사용자 thezz9는 개발 시 기능적 정확성을 먼저 달성한 후 세부 리팩터링을 나중에 하는 접근 방식을 선호한다. 테스트 단계에서는 하드코딩된 값도 허용한다.
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/application/submission/JudgementServiceEventTest.java (2)
Learnt from: thezz9
PR: ezcode-my/backend#98
File: src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java:17-22
Timestamp: 2025-06-25T01:24:30.754Z
Learning: JudgeClient에서 모든 예외를 SubmissionException으로 래핑해서 넘길 계획이므로, SubmissionErrorEvent.resolveCode() 메서드의 캐스팅은 안전할 예정임.
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 엔티티의 실제 테스트케이스로 대체 예정입니다.
src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.java (5)
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:142-147
Timestamp: 2025-06-19T07:00:53.895Z
Learning: SubmissionService.getCodeReview() 메서드에서 토큰 차감을 리뷰 요청 전에 수행하는 이유: OpenAI 서버 장애보다 유저 토큰 부족 상황이 더 빈번하므로, 확률이 높은 실패 케이스를 먼저 체크하여 불필요한 처리를 방지함. OpenAI 서버 장애 시에는 OpenAIClient에서 트랜잭션 롤백으로 토큰 복원이 처리됨.
Learnt from: thezz9
PR: ezcode-my/backend#98
File: src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java:17-22
Timestamp: 2025-06-25T01:24:30.754Z
Learning: JudgeClient에서 모든 예외를 SubmissionException으로 래핑해서 넘길 계획이므로, SubmissionErrorEvent.resolveCode() 메서드의 캐스팅은 안전할 예정임.
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#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#73
File: src/main/resources/templates/submit-test.html:135-135
Timestamp: 2025-06-18T11:41:58.457Z
Learning: src/main/resources/templates/submit-test.html 파일은 테스트용 파일로, isCorrect 값의 하드코딩은 의도적이며 사용자가 UI 요소를 통해 정답/오답 상태를 선택할 수 있도록 개선 예정입니다.
src/test/java/org/ezcode/codetest/application/submission/JudgementServiceAsyncTest.java (2)
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#36
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:50-57
Timestamp: 2025-06-06T08:02:14.159Z
Learning: SseEmitter를 사용한 실시간 스트리밍에서는 @Async 방식이 부적합하다. @Async는 메서드 전체가 백그라운드에서 실행되어 최종 결과만 반환하므로, 중간 결과를 실시간으로 스트리밍할 수 없다. 이런 경우에는 CompletableFuture + TaskExecutor나 Reactor Flux를 사용하여 스트리밍을 유지하면서 스레드 관리를 개선해야 한다.
🔇 Additional comments (11)
build.gradle (1)

64-64: 테스트용 mockito-inline 의존성 추가 승인

새로 추가된 테스트 클래스들에서 static 메서드 모킹(예: GitHubPushRequest.of)을 위해 필요한 의존성입니다. 버전 패턴도 적절합니다.

src/test/java/org/ezcode/codetest/application/language/LanguageServiceTest.java (1)

1-1: 패키지 구조 정리 승인

다른 새로 추가된 테스트 클래스들과 일관된 패키지 구조로 변경되었습니다.

src/test/java/org/ezcode/codetest/application/submission/JudgementServiceEventTest.java (1)

24-107: 이벤트 발행 테스트 클래스 승인

JudgementService의 이벤트 발행 기능에 대한 테스트가 잘 구성되어 있습니다:

  • 테스트케이스 초기화, 최종 결과, 에러 이벤트 발행을 모두 커버
  • BDD 패턴과 적절한 검증 로직 사용
  • Mock 설정과 상호작용 검증이 정확함
src/test/java/org/ezcode/codetest/application/submission/GitHubPushServiceTest.java (1)

25-169: GitHub 푸시 서비스 테스트 클래스 승인

GitHubPushService의 다양한 시나리오를 포괄적으로 테스트하고 있습니다:

  • 조건부 실행 로직 테스트 (비활성/오답 시 동작 안함)
  • 정상 실행 흐름과 예외 처리 테스트
  • static 모킹을 통한 팩토리 메서드 제어가 적절함
  • try-with-resources로 static mock 정리가 올바름
src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.java (1)

47-295: 제출 서비스 종합 테스트 클래스 승인

SubmissionService의 핵심 기능들에 대한 포괄적이고 체계적인 테스트입니다:

장점:

  • 큐 등록, 비동기 처리, 조회, 리뷰 등 주요 기능 모두 커버
  • ArgumentCaptor를 활용한 정확한 인자 검증
  • 성공/실패 시나리오 균형있게 테스트
  • 락 관리와 예외 처리 검증이 철저함

특히 좋은 부분:

  • 라인 164-172: SubmissionContext 캡처를 통한 서비스 호출 순서 검증
  • 라인 284-292: 예외 발생 시 에러 이벤트 발행과 락 해제 검증
src/test/java/org/ezcode/codetest/application/submission/JudgementServiceAsyncTest.java (6)

1-30: 임포트 구조가 깔끔하게 정리되어 있습니다.

비동기 테스트에 필요한 모든 의존성이 적절히 임포트되어 있습니다.


31-61: 비동기 테스트를 위한 적절한 설정입니다.

directExecutor를 사용하여 비동기 작업을 동기적으로 실행하는 것은 테스트의 예측 가능성을 보장하는 좋은 패턴입니다.


63-69: 테스트 초기화 로직이 명확합니다.

리플렉션을 통한 executor 주입은 비동기 테스트의 deterministic 실행을 위해 적절한 방법입니다.


71-100: 성공 케이스 테스트가 잘 구성되어 있습니다.

다양한 evaluation 결과를 시뮬레이션하고 이벤트 발행 횟수를 정확히 검증하는 논리가 우수합니다.


102-151: 실패 케이스 테스트가 포괄적입니다.

타임아웃과 예외 처리 시나리오에서 예외 알림, 이벤트 발행, countDown 호출까지 모든 측면을 검증하는 것이 훌륭합니다.


33-152: 비동기 서비스 테스트의 모범 사례입니다.

중첩 클래스로 테스트를 체계적으로 분리하고, 비동기 로직을 deterministic하게 테스트하며, 성공/실패 시나리오를 모두 포괄적으로 다룬 우수한 테스트 클래스입니다.

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between da06ded and 7ed0a5a.

📒 Files selected for processing (2)
  • src/test/java/org/ezcode/codetest/application/submission/JudgementServiceEventTest.java (1 hunks)
  • src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/org/ezcode/codetest/application/submission/JudgementServiceEventTest.java
🧰 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: 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/domain/problem/model/dto/SubmissionData.java:42-53
Timestamp: 2025-06-04T13:12:16.729Z
Learning: 사용자 thezz9는 개발 시 기능적 정확성을 먼저 달성한 후 세부 리팩터링을 나중에 하는 접근 방식을 선호한다. 테스트 단계에서는 하드코딩된 값도 허용한다.
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/application/submission/SubmissionServiceTest.java (5)
Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:142-147
Timestamp: 2025-06-19T07:00:53.895Z
Learning: SubmissionService.getCodeReview() 메서드에서 토큰 차감을 리뷰 요청 전에 수행하는 이유: OpenAI 서버 장애보다 유저 토큰 부족 상황이 더 빈번하므로, 확률이 높은 실패 케이스를 먼저 체크하여 불필요한 처리를 방지함. OpenAI 서버 장애 시에는 OpenAIClient에서 트랜잭션 롤백으로 토큰 복원이 처리됨.
Learnt from: thezz9
PR: ezcode-my/backend#98
File: src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java:17-22
Timestamp: 2025-06-25T01:24:30.754Z
Learning: JudgeClient에서 모든 예외를 SubmissionException으로 래핑해서 넘길 계획이므로, SubmissionErrorEvent.resolveCode() 메서드의 캐스팅은 안전할 예정임.
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#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#73
File: src/main/resources/templates/submit-test.html:135-135
Timestamp: 2025-06-18T11:41:58.457Z
Learning: src/main/resources/templates/submit-test.html 파일은 테스트용 파일로, isCorrect 값의 하드코딩은 의도적이며 사용자가 UI 요소를 통해 정답/오답 상태를 선택할 수 있도록 개선 예정입니다.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (8)
src/test/java/org/ezcode/codetest/application/submission/SubmissionServiceTest.java (8)

1-46: Import 문과 패키지 구조가 적절합니다.

필요한 테스트 라이브러리와 도메인 클래스들이 올바르게 import되어 있고, 패키지 구조도 적절합니다.


47-117: 테스트 설정이 잘 구성되어 있습니다.

MockitoExtension 사용, Mock 객체들의 적절한 설정, BeforeEach를 통한 초기화가 잘 되어 있습니다. 테스트에 필요한 모든 의존성이 적절히 모킹되었습니다.


125-145: 제출 큐잉 테스트가 잘 작성되었습니다.

ArgumentMatcher를 사용하여 SubmissionMessage의 속성들을 검증하는 방식이 효과적입니다. 락 획득 성공 시나리오를 정확히 테스트하고 있습니다.


149-172: 비동기 처리 흐름 테스트가 포괄적입니다.

ArgumentCaptor를 사용하여 SubmissionContext 객체를 캡처하고, 모든 서비스 호출 순서를 검증하는 것이 우수합니다. 락 해제까지 확인하여 리소스 관리를 잘 테스트하고 있습니다.


176-218: 제출 내역 그룹핑 테스트가 상세합니다.

여러 제출 데이터를 문제별로 그룹핑하는 로직을 잘 테스트하고 있으며, 스트림 API를 사용한 검증 방식도 적절합니다.


222-244: 코드 리뷰 기능 테스트가 완전합니다.

토큰 차감과 리뷰 요청 흐름을 순서대로 검증하고 있으며, 응답 내용 확인까지 포함하여 비즈니스 로직을 잘 커버하고 있습니다.


252-265: 락 획득 실패 테스트가 정확합니다.

ALREADY_JUDGING 예외가 올바르게 발생하는지 검증하고 있으며, assertThatThrownBy 사용법도 적절합니다.


269-292: 예외 처리 흐름 테스트가 완벽합니다.

예외 발생 시 에러 이벤트 발행, 예외 알림, 락 해제가 모두 수행되는지 검증하여 오류 상황에서의 리소스 정리를 잘 테스트하고 있습니다.

@thezz9 thezz9 merged commit 922522e into dev Jun 30, 2025
2 checks passed
@thezz9 thezz9 deleted the test/submission-application branch June 30, 2025 00:11
@thezz9 thezz9 added the Test label Jun 30, 2025
NCookies pushed a commit that referenced this pull request Jun 30, 2025
* test(submission): add application layer tests

* test(submission): adjust code blocks

* test(submission): adjust code blocks
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