|
27 | 27 | import com.tnt.domain.trainer.Trainer;
|
28 | 28 | import com.tnt.dto.trainer.ConnectWithTrainerDto;
|
29 | 29 | import com.tnt.dto.trainer.request.ConnectWithTrainerRequest;
|
| 30 | +import com.tnt.dto.trainer.response.GetCalendarPtLessonCountResponse; |
30 | 31 | import com.tnt.dto.trainer.response.GetPtLessonsOnDateResponse;
|
31 | 32 | import com.tnt.fixture.MemberFixture;
|
32 | 33 | import com.tnt.fixture.PtLessonsFixture;
|
@@ -264,4 +265,54 @@ void get_pt_lessons_success() {
|
264 | 265 | // then
|
265 | 266 | assertThat(result).isEqualTo(ptLessons);
|
266 | 267 | }
|
| 268 | + |
| 269 | + @Test |
| 270 | + @DisplayName("특정 월의 캘린더 PT 레슨 수 조회 성공") |
| 271 | + void get_calendar_pt_lesson_count_success() { |
| 272 | + // given |
| 273 | + Member trainerMember = MemberFixture.getTrainerMember1WithId(); |
| 274 | + Member traineeMember = MemberFixture.getTraineeMember1WithId(); |
| 275 | + |
| 276 | + Trainer trainer = TrainerFixture.getTrainer2(trainerMember); |
| 277 | + Trainee trainee = TraineeFixture.getTrainee2(traineeMember); |
| 278 | + |
| 279 | + PtTrainerTrainee ptTrainerTrainee = PtTrainerTraineeFixture.getPtTrainerTrainee1(trainer, trainee); |
| 280 | + |
| 281 | + int year = 2025; |
| 282 | + int month = 1; |
| 283 | + LocalDateTime date = LocalDate.of(year, month, 1).atTime(10, 0); |
| 284 | + |
| 285 | + List<PtLesson> ptLessons = List.of(PtLesson.builder() |
| 286 | + .id(1L) |
| 287 | + .ptTrainerTrainee(ptTrainerTrainee) |
| 288 | + .lessonStart(date) |
| 289 | + .lessonEnd(date.plusHours(1)) |
| 290 | + .build(), |
| 291 | + PtLesson.builder() |
| 292 | + .id(2L) |
| 293 | + .ptTrainerTrainee(ptTrainerTrainee) |
| 294 | + .lessonStart(date.plusHours(4)) |
| 295 | + .lessonEnd(date.plusHours(5)) |
| 296 | + .build(), |
| 297 | + PtLesson.builder() |
| 298 | + .id(3L) |
| 299 | + .ptTrainerTrainee(ptTrainerTrainee) |
| 300 | + .lessonStart(date.plusDays(1)) |
| 301 | + .lessonEnd(date.plusDays(1).plusHours(1)) |
| 302 | + .build()); |
| 303 | + |
| 304 | + given(trainerService.getTrainerWithMemberId(trainer.getId())).willReturn(trainer); |
| 305 | + given(ptLessonSearchRepository.findAllByTraineeIdForCalendar(trainer.getId(), year, month)) |
| 306 | + .willReturn(ptLessons); |
| 307 | + |
| 308 | + // when |
| 309 | + GetCalendarPtLessonCountResponse result = ptService.getCalendarPtLessonCount(trainer.getId(), year, month); |
| 310 | + |
| 311 | + // then |
| 312 | + assertThat(result.calendarPtLessonCounts()).hasSize(2); |
| 313 | + assertThat(result.calendarPtLessonCounts().getFirst().date()).isEqualTo(LocalDate.of(year, month, 1)); |
| 314 | + assertThat(result.calendarPtLessonCounts().getFirst().count()).isEqualTo(2); |
| 315 | + assertThat(result.calendarPtLessonCounts().getLast().date()).isEqualTo(LocalDate.of(year, month, 2)); |
| 316 | + assertThat(result.calendarPtLessonCounts().getLast().count()).isEqualTo(1); |
| 317 | + } |
267 | 318 | }
|
0 commit comments