1717import dmu .dasom .api .domain .recruit .enums .ResultCheckType ;
1818import dmu .dasom .api .domain .recruit .repository .RecruitRepository ;
1919import dmu .dasom .api .domain .recruit .service .RecruitServiceImpl ;
20- import dmu .dasom .api .global .generation .service .GenerationService ;
2120import org .junit .jupiter .api .DisplayName ;
2221import org .junit .jupiter .api .Test ;
2322import org .junit .jupiter .api .extension .ExtendWith ;
@@ -47,9 +46,6 @@ class RecruitServiceTest {
4746 @ Mock
4847 private InterviewServiceImpl interviewService ;
4948
50- @ Mock
51- private GenerationService generationService ;
52-
5349 @ InjectMocks
5450 private RecruitServiceImpl recruitService ;
5551
@@ -59,42 +55,32 @@ void getRecruitSchedule() {
5955 // given
6056 Recruit recruit1 = mock (Recruit .class );
6157 Recruit recruit2 = mock (Recruit .class );
62- Recruit recruit3 = mock (Recruit .class );
63- when (recruitRepository .findAll ()).thenReturn (List .of (recruit1 , recruit2 , recruit3 ));
64- when (recruit1 .getKey ()).thenReturn (ConfigKey .RECRUITMENT_PERIOD_START );
65- when (recruit2 .getKey ()).thenReturn (ConfigKey .RECRUITMENT_PERIOD_END );
66- when (recruit3 .getKey ()).thenReturn (ConfigKey .GENERATION );
67- when (generationService .getCurrentGeneration ()).thenReturn ("34기" );
58+ when (recruitRepository .findAll ()).thenReturn (List .of (recruit1 , recruit2 ));
6859
6960 // when
7061 List <RecruitConfigResponseDto > schedule = recruitService .getRecruitSchedule ();
7162
7263 // then
7364 assertNotNull (schedule );
74- assertEquals (3 , schedule .size ());
65+ assertEquals (2 , schedule .size ());
7566 verify (recruitRepository , times (1 )).findAll ();
76- verify (generationService , times (1 )).getCurrentGeneration ();
7767 }
7868
7969 @ Test
8070 @ DisplayName ("모집 일정 수정 - 성공" )
8171 void modifyRecruitSchedule_success () {
8272 // given
8373 Recruit recruit = mock (Recruit .class );
84- Recruit generationRecruit = mock (Recruit .class );
8574 RecruitScheduleModifyRequestDto request = mock (RecruitScheduleModifyRequestDto .class );
8675 when (request .getKey ()).thenReturn (ConfigKey .RECRUITMENT_PERIOD_START );
8776 when (request .getValue ()).thenReturn ("2025-01-02T12:00:00" );
8877 when (recruitRepository .findByKey (ConfigKey .RECRUITMENT_PERIOD_START )).thenReturn (Optional .of (recruit ));
89- when (recruitRepository .findByKey (ConfigKey .GENERATION )).thenReturn (Optional .of (generationRecruit ));
90- when (generationService .getCurrentGeneration ()).thenReturn ("34기" );
9178
9279 // when
9380 recruitService .modifyRecruitSchedule (request );
9481
9582 // then
9683 verify (recruit , times (1 )).updateDateTime (LocalDateTime .of (2025 , 1 , 2 , 12 , 0 , 0 ));
97- verify (generationRecruit , times (1 )).updateGeneration ("34기" );
9884 }
9985
10086 @ Test
@@ -115,6 +101,36 @@ void modifyRecruitSchedule_fail() {
115101 assertEquals (ErrorCode .INVALID_TIME_FORMAT , exception .getErrorCode ());
116102 }
117103
104+ @ Test
105+ @ DisplayName ("모집 기수 수정" )
106+ void modifyGeneration_success () {
107+ // given
108+ Recruit generationRecruit = mock (Recruit .class );
109+ String newGeneration = "35기" ;
110+ when (recruitRepository .findByKey (ConfigKey .GENERATION )).thenReturn (Optional .of (generationRecruit ));
111+
112+ // when
113+ recruitService .modifyGeneration (newGeneration );
114+
115+ // then
116+ verify (generationRecruit , times (1 )).updateGeneration (newGeneration );
117+ }
118+
119+ @ Test
120+ @ DisplayName ("기수 조회" )
121+ void getCurrentGeneration_success () {
122+ // given
123+ Recruit generationRecruit = mock (Recruit .class );
124+ when (recruitRepository .findByKey (ConfigKey .GENERATION )).thenReturn (Optional .of (generationRecruit ));
125+ when (generationRecruit .getValue ()).thenReturn ("34기" );
126+ // when
127+ String currentGeneration = recruitService .getCurrentGeneration ();
128+ // then
129+ assertEquals ("34기" , currentGeneration );
130+ verify (recruitRepository , times (1 )).findByKey (ConfigKey .GENERATION );
131+ verify (generationRecruit , times (1 )).getValue ();
132+ }
133+
118134 @ Test
119135 @ DisplayName ("면접 일정 생성 - 성공" )
120136 void createInterviewSlots_success () {
@@ -209,42 +225,5 @@ void reserveInterviewSlot_fail_alreadyReserved() {
209225 assertEquals (ErrorCode .ALREADY_RESERVED , exception .getErrorCode ());
210226 }
211227
212- @ Test
213- @ DisplayName ("기수 정보 조회" )
214- void getGenerationInfo () {
215- // given
216- Recruit generationRecruit = mock (Recruit .class );
217- when (recruitRepository .findAll ()).thenReturn (List .of (generationRecruit ));
218- when (generationRecruit .getKey ()).thenReturn (ConfigKey .GENERATION );
219- when (generationService .getCurrentGeneration ()).thenReturn ("34기" );
220-
221- // when
222- List <RecruitConfigResponseDto > schedule = recruitService .getRecruitSchedule ();
223- boolean generationFound = schedule .stream ()
224- .anyMatch (dto -> dto .getKey () == ConfigKey .GENERATION );
225-
226- // then
227- assertTrue (generationFound );
228- verify (generationService , times (1 )).getCurrentGeneration ();
229- }
230-
231- @ Test
232- @ DisplayName ("기수 정보 수정" )
233- void modifyGenerationInfo () {
234- // given
235- Recruit generationRecruit = mock (Recruit .class );
236- RecruitScheduleModifyRequestDto request = mock (RecruitScheduleModifyRequestDto .class );
237- when (request .getKey ()).thenReturn (ConfigKey .RECRUITMENT_PERIOD_START );
238- when (request .getValue ()).thenReturn ("2025-01-02T12:00:00" );
239- when (recruitRepository .findByKey (ConfigKey .RECRUITMENT_PERIOD_START )).thenReturn (Optional .of (mock (Recruit .class )));
240- when (recruitRepository .findByKey (ConfigKey .GENERATION )).thenReturn (Optional .of (generationRecruit ));
241- when (generationService .getCurrentGeneration ()).thenReturn ("34기" );
242-
243- // when
244- recruitService .modifyRecruitSchedule (request );
245-
246- // then
247- verify (generationRecruit , times (1 )).updateGeneration ("34기" );
248- }
249228
250- }
229+ }
0 commit comments