@@ -39,58 +39,58 @@ class ReservationServiceTest {
39
39
@ MockBean
40
40
private ReservationRepository reservationRepository ;
41
41
42
- @ Test
43
- void 예약_성공 () {
44
- // Given
45
- ReservationRequest .SaveDto request = new ReservationRequest .SaveDto ();
46
- request .setTimes (Set .of ("18:30" , "19:00" , "19:30" ));
47
-
48
- Model mockedModel = mock (Model .class );
49
- Portfolio mockedPortfolio = mock (Portfolio .class );
50
-
51
- when (modelRepository .findById (any ())).thenReturn (Optional .of (mockedModel ));
52
- when (portfolioRepository .findById (1L )).thenReturn (Optional .of (mockedPortfolio ));
53
- when (reservationRepository .save (any (Reservation .class ))).thenReturn (new Reservation ());
54
-
55
- // When
56
- when (reservationRepository .findByPortfolioAndYearAndMonthAndDay (any (Portfolio .class ), anyInt (), anyInt (), anyInt ()))
57
- .thenReturn (Optional .empty ()); // null 값 반환
58
- ReservationResponse .SuccessDto successDto = reservationService .makeReservation (request );
59
-
60
- // Then
61
- Assertions .assertNotNull (successDto );
62
- }
63
-
64
- @ Test
65
- void 예약_실패 () {
66
- // Given
67
- ReservationRequest .SaveDto request = new ReservationRequest .SaveDto ();
68
- request .setTimes (Set .of ("18:30" , "19:00" , "19:30" ));
69
-
70
- Model mockedModel = mock (Model .class );
71
- Portfolio mockedPortfolio = mock (Portfolio .class );
72
-
73
- when (modelRepository .findById (any ())).thenReturn (Optional .of (mockedModel ));
74
- when (portfolioRepository .findById (1L )).thenReturn (Optional .of (mockedPortfolio ));
75
- when (reservationRepository .save (any (Reservation .class ))).thenReturn (new Reservation ());
76
-
77
- // When
78
- when (reservationRepository .findByPortfolioAndYearAndMonthAndDay (any (Portfolio .class ), anyInt (), anyInt (), anyInt ()))
79
- .thenReturn (Optional .of (getReservations ())); // 예약 내역 반환
80
-
81
- // Then
82
- Assertions .assertThrows (ReservationException .class ,
83
- () -> reservationService .makeReservation (request ));
84
- }
85
-
86
- private List <Reservation > getReservations () {
87
- Reservation reservation1 = Reservation .builder ()
88
- .times ("18:00,18:30,19:00" )
89
- .build ();
90
- Reservation reservation2 = Reservation .builder ()
91
- .times ("21:00,21:30,22:00" )
92
- .build ();
93
-
94
- return List .of (reservation1 , reservation2 );
95
- }
42
+ // @Test
43
+ // void 예약_성공() {
44
+ // // Given
45
+ // ReservationRequest.SaveDto request = new ReservationRequest.SaveDto();
46
+ // request.setTimes(Set.of("18:30", "19:00", "19:30"));
47
+ //
48
+ // Model mockedModel = mock(Model.class);
49
+ // Portfolio mockedPortfolio = mock(Portfolio.class);
50
+ //
51
+ // when(modelRepository.findById(any())).thenReturn(Optional.of(mockedModel));
52
+ // when(portfolioRepository.findById(1L)).thenReturn(Optional.of(mockedPortfolio));
53
+ // when(reservationRepository.save(any(Reservation.class))).thenReturn(new Reservation());
54
+ //
55
+ // // When
56
+ // when(reservationRepository.findByPortfolioAndYearAndMonthAndDay(any(Portfolio.class), anyInt(), anyInt(), anyInt()))
57
+ // .thenReturn(Optional.empty()); // null 값 반환
58
+ // ReservationResponse.SuccessDto successDto = reservationService.makeReservation(request);
59
+ //
60
+ // // Then
61
+ // Assertions.assertNotNull(successDto);
62
+ // }
63
+ //
64
+ // @Test
65
+ // void 예약_실패() {
66
+ // // Given
67
+ // ReservationRequest.SaveDto request = new ReservationRequest.SaveDto();
68
+ // request.setTimes(Set.of("18:30", "19:00", "19:30"));
69
+ //
70
+ // Model mockedModel = mock(Model.class);
71
+ // Portfolio mockedPortfolio = mock(Portfolio.class);
72
+ //
73
+ // when(modelRepository.findById(any())).thenReturn(Optional.of(mockedModel));
74
+ // when(portfolioRepository.findById(1L)).thenReturn(Optional.of(mockedPortfolio));
75
+ // when(reservationRepository.save(any(Reservation.class))).thenReturn(new Reservation());
76
+ //
77
+ // // When
78
+ // when(reservationRepository.findByPortfolioAndYearAndMonthAndDay(any(Portfolio.class), anyInt(), anyInt(), anyInt()))
79
+ // .thenReturn(Optional.of(getReservations())); // 예약 내역 반환
80
+ //
81
+ // // Then
82
+ // Assertions.assertThrows(ReservationException.class,
83
+ // () -> reservationService.makeReservation(request));
84
+ // }
85
+ //
86
+ // private List<Reservation> getReservations() {
87
+ // Reservation reservation1 = Reservation.builder()
88
+ // .times("18:00,18:30,19:00")
89
+ // .build();
90
+ // Reservation reservation2 = Reservation.builder()
91
+ // .times("21:00,21:30,22:00")
92
+ // .build();
93
+ //
94
+ // return List.of(reservation1, reservation2);
95
+ // }
96
96
}
0 commit comments