11package com .mycodingtest .application .collector ;
22
3- import com .mycodingtest .application .collector .dto .CreateProblemAndJudgmentCommand ;
4- import com .mycodingtest .application .judgment .JudgmentService ;
5- import com .mycodingtest .application .problem .ProblemService ;
6- import com .mycodingtest .application .review .ReviewService ;
3+ import com .mycodingtest .application .collector .command .BojIngestionCommandService ;
4+ import com .mycodingtest .application .collector .command .CreateProblemAndJudgmentCommand ;
5+ import com .mycodingtest .application .judgment .command .JudgmentCommandService ;
6+ import com .mycodingtest .application .judgment .query .JudgmentQueryService ;
7+ import com .mycodingtest .application .problem .command .ProblemCommandService ;
8+ import com .mycodingtest .application .review .command .ReviewCommandService ;
79import com .mycodingtest .domain .common .Platform ;
810import com .mycodingtest .domain .problem .Problem ;
911import org .junit .jupiter .api .Nested ;
2123import static org .mockito .Mockito .verify ;
2224
2325@ ExtendWith (MockitoExtension .class )
24- class BojIngestionServiceTest {
26+ class BojIngestionCommandServiceTest {
2527
2628 @ Mock
27- private JudgmentService judgmentService ;
29+ private JudgmentCommandService judgmentCommandService ;
30+ @ Mock
31+ private JudgmentQueryService judgmentQueryService ;
2832
2933 @ Mock
30- private ProblemService problemService ;
34+ private ProblemCommandService problemCommandService ;
3135
3236 @ Mock
33- private ReviewService reviewService ;
37+ private ReviewCommandService reviewCommandService ;
3438
3539 @ InjectMocks
36- private BojIngestionService bojIngestionService ;
40+ private BojIngestionCommandService bojIngestionCommandService ;
3741
3842 @ Nested
3943 class 데이터_수집 {
@@ -56,17 +60,15 @@ class 데이터_수집 {
5660 .sourceCode ("public class Main {}" )
5761 .build ();
5862
59- Problem mockProblem = Problem .from (1000 , "A+B" , Platform .BOJ );
60-
61- given (problemService .getOrCreateProblem (any ())).willReturn (mockProblem );
63+ given (problemCommandService .syncProblem (any ()));
6264
6365 // when
64- bojIngestionService .ingest (command );
66+ bojIngestionCommandService .ingest (command );
6567
6668 // then
67- verify (problemService ). getOrCreateProblem (any ());
68- verify (judgmentService ).createJudgmentFromBoj (any ());
69- verify (reviewService ).createReview (any ());
69+ verify (problemCommandService ). syncProblem (any ());
70+ verify (judgmentCommandService ).createJudgmentFromBoj (any ());
71+ verify (reviewCommandService ).createReview (any ());
7072 }
7173 }
7274
@@ -77,10 +79,10 @@ class 중복_제출_확인 {
7779 void 중복_제출이면_예외가_발생한다 () {
7880 // given
7981 Long submissionId = 99999L ;
80- given (judgmentService .isJudgmentExist (submissionId , Platform .BOJ )).willReturn (true );
82+ given (judgmentQueryService .isJudgmentExist (submissionId , Platform .BOJ )).willReturn (true );
8183
8284 // when & then
83- assertThatThrownBy (() -> bojIngestionService .checkDuplicatedSubmissionId (submissionId ))
85+ assertThatThrownBy (() -> bojIngestionCommandService .checkDuplicatedSubmissionId (submissionId ))
8486 .isInstanceOf (IllegalStateException .class )
8587 .hasMessageContaining ("이미 존재하는 제출 번호입니다" );
8688 }
@@ -89,10 +91,10 @@ class 중복_제출_확인 {
8991 void 중복이_아니면_예외가_발생하지_않는다 () {
9092 // given
9193 Long submissionId = 99999L ;
92- given (judgmentService .isJudgmentExist (submissionId , Platform .BOJ )).willReturn (false );
94+ given (judgmentQueryService .isJudgmentExist (submissionId , Platform .BOJ )).willReturn (false );
9395
9496 // when & then
95- bojIngestionService .checkDuplicatedSubmissionId (submissionId );
97+ bojIngestionCommandService .checkDuplicatedSubmissionId (submissionId );
9698 // 예외가 발생하지 않으면 성공
9799 }
98100 }
0 commit comments