55import com .back .domain .study .plan .entity .RepeatRule ;
66import com .back .domain .study .plan .entity .StudyPlan ;
77import com .back .domain .study .plan .repository .StudyPlanRepository ;
8+ import com .back .domain .studyroom .entity .Room ;
9+ import com .back .domain .studyroom .repository .RoomRepository ;
810import com .back .domain .user .entity .Role ;
911import com .back .domain .user .entity .User ;
1012import com .back .domain .user .entity .UserStatus ;
@@ -53,8 +55,11 @@ class StudyRecordControllerTest {
5355 private StudyPlanRepository studyPlanRepository ;
5456 @ Autowired
5557 private UserRepository userRepository ;
58+ @ Autowired
59+ private RoomRepository roomRepository ;
5660
5761 private User testUser ;
62+ private Room testRoom ;
5863 private StudyPlan singlePlan ;
5964 private StudyPlan dailyPlan ;
6065
@@ -73,6 +78,7 @@ void setUp() {
7378
7479 singlePlan = createSinglePlan ();
7580 dailyPlan = createDailyPlan ();
81+ testRoom = createRoom (testUser );
7682 }
7783
7884 private void setupJwtMock (User user ) {
@@ -115,7 +121,23 @@ private StudyPlan createDailyPlan() {
115121 plan .setRepeatRule (repeatRule );
116122
117123 return studyPlanRepository .save (plan );
124+ }
125+
126+ private Room createRoom (User owner ) {
127+
128+ testRoom = Room .create (
129+ "코딩테스트 준비" ,
130+ "알고리즘 문제 풀이 및 코드 리뷰" ,
131+ false , // 공개방
132+ null , // 비밀번호 없음
133+ 20 , // 최대 20명
134+ owner ,
135+ null , // 테마 없음
136+ true // WebRTC 활성화
137+ );
118138
139+ testRoom = roomRepository .save (testRoom );
140+ return testRoom ;
119141 }
120142
121143 @ Test
@@ -127,12 +149,13 @@ void t1() throws Exception {
127149 .content ("""
128150 {
129151 "planId": %d,
152+ "roomId": %d,
130153 "startTime": "2025-10-03T10:00:00",
131154 "endTime": "2025-10-03T12:00:00",
132155 "duration": 7200,
133156 "pauseInfos": []
134157 }
135- """ .formatted (singlePlan .getId ())))
158+ """ .formatted (singlePlan .getId (), testRoom . getId () )))
136159 .andDo (print ());
137160
138161 resultActions
@@ -142,6 +165,7 @@ void t1() throws Exception {
142165 .andExpect (jsonPath ("$.success" ).value (true ))
143166 .andExpect (jsonPath ("$.message" ).value ("학습 기록이 생성되었습니다." ))
144167 .andExpect (jsonPath ("$.data.planId" ).value (singlePlan .getId ()))
168+ .andExpect (jsonPath ("$.data.roomId" ).value (testRoom .getId ()))
145169 .andExpect (jsonPath ("$.data.startTime" ).value ("2025-10-03T10:00:00" ))
146170 .andExpect (jsonPath ("$.data.endTime" ).value ("2025-10-03T12:00:00" ))
147171 .andExpect (jsonPath ("$.data.duration" ).value (7200 ))
@@ -156,6 +180,7 @@ void t2() throws Exception {
156180 .content ("""
157181 {
158182 "planId": %d,
183+ "roomId": %d,
159184 "startTime": "2025-10-03T14:00:00",
160185 "endTime": "2025-10-03T17:00:00",
161186 "duration": "7500",
@@ -172,7 +197,7 @@ void t2() throws Exception {
172197 }
173198 ]
174199 }
175- """ .formatted (dailyPlan .getId ())))
200+ """ .formatted (singlePlan . getId (), testRoom .getId ())))
176201 .andDo (print ());
177202
178203 resultActions
@@ -192,6 +217,7 @@ void t2_1() throws Exception {
192217 .content ("""
193218 {
194219 "planId": %d,
220+ "roomId": %d,
195221 "startTime": "2025-10-03T14:00:00",
196222 "endTime": "2025-10-03T17:00:00",
197223 "duration": "7200",
@@ -207,7 +233,7 @@ void t2_1() throws Exception {
207233 }
208234 ]
209235 }
210- """ .formatted (dailyPlan .getId ())))
236+ """ .formatted (singlePlan . getId (), testRoom .getId ())))
211237 .andDo (print ());
212238
213239 resultActions
@@ -227,12 +253,13 @@ void t3() throws Exception {
227253 .content ("""
228254 {
229255 "planId": %d,
256+ "roomId": %d,
230257 "startTime": "2025-10-03T10:00:00",
231258 "endTime": "2025-10-03T12:00:00",
232259 "duration": 7200,
233260 "pauseInfos": []
234261 }
235- """ .formatted (singlePlan .getId ())))
262+ """ .formatted (singlePlan .getId (), testRoom . getId () )))
236263 .andExpect (status ().isOk ());
237264
238265 // 조회
@@ -258,12 +285,13 @@ void t5() throws Exception {
258285 .content ("""
259286 {
260287 "planId": %d,
288+ "roomId": %d,
261289 "startTime": "2025-10-02T23:00:00",
262290 "endTime": "2025-10-03T05:00:00",
263291 "duration": 21600,
264292 "pauseInfos": []
265293 }
266- """ .formatted (singlePlan .getId ())))
294+ """ .formatted (singlePlan .getId (), testRoom . getId () )))
267295 .andExpect (status ().isOk ());
268296 // 10월 2일 조회
269297 ResultActions resultActions = mvc .perform (get ("/api/plans/records?date=2025-10-02" )
0 commit comments