Skip to content

Commit

Permalink
fix: 테스트 코드에서 사용되는 년도가 이전이라서 발생하는 예외 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyh99 committed Nov 17, 2023
1 parent 256d177 commit 42f9214
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ void deleteAllByRoomId() {
//given
final long roomId = 1L;
final Reservation reservation1 = new Reservation(roomId,
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
final Reservation reservation2 = new Reservation(roomId,
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
final Reservation reservation3 = new Reservation(roomId,
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
reservationRepository.saveAll(List.of(reservation1, reservation2, reservation3));

//when
Expand All @@ -68,16 +68,16 @@ void findAllByStartTimeDate() {
//given
final long roomId = 1L;
final Reservation reservation1 = new Reservation(roomId,
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
final Reservation reservation2 = new Reservation(roomId,
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
final Reservation reservation3 = new Reservation(roomId,
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
reservationRepository.saveAll(List.of(reservation1, reservation2, reservation3));

//when
final List<Reservation> nothing = reservationRepository.findAllByStartTimeDate(LocalDate.of(1999, 3, 19));
final List<Reservation> hasThree = reservationRepository.findAllByStartTimeDate(LocalDate.of(2023, 11, 10));
final List<Reservation> hasThree = reservationRepository.findAllByStartTimeDate(LocalDate.of(3000, 11, 10));

//then
assertSoftly(softAssertions -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void setUp() {
void create() {
//given
final CreateReservationRequest request = new CreateReservationRequest(
1L, of(2023, 11, 10, 14, 0), of(2023, 11, 10, 15, 0));
1L, of(3000, 11, 10, 14, 0), of(3000, 11, 10, 15, 0));

//when
reservationService.create(request);
Expand All @@ -76,10 +76,10 @@ void create() {
void create_fail() {
//given
reservationService.create(new CreateReservationRequest(
1L, of(2023, 11, 10, 14, 0), of(2023, 11, 10, 15, 0)));
1L, of(3000, 11, 10, 14, 0), of(3000, 11, 10, 15, 0)));

final CreateReservationRequest request = new CreateReservationRequest(
1L, of(2023, 11, 10, 14, 30), of(2023, 11, 10, 17, 0));
1L, of(3000, 11, 10, 14, 30), of(3000, 11, 10, 17, 0));

//when, then
assertThatThrownBy(() -> reservationService.create(request))
Expand Down Expand Up @@ -189,7 +189,7 @@ void findAll2() {

private Reservation createReservation(final Long roomId) {
return reservationRepository.save(
new Reservation(roomId, of(2023, 11, 10, 14, 0), of(2023, 11, 10, 15, 0)));
new Reservation(roomId, of(3000, 11, 10, 14, 0), of(3000, 11, 10, 15, 0)));
}

private Reservation createCanceledReservation(final Long roomId) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/example/busan/room/RoomServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ void findAll() {

final Room room = createRoom();
final Reservation reservation1 = new Reservation(room.getId(),
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
final Reservation reservation2 = new Reservation(room.getId(),
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
final Reservation reservation3 = new Reservation(room.getId(),
LocalDateTime.of(2023, 11, 10, 13, 0), LocalDateTime.of(2023, 11, 10, 15, 30));
LocalDateTime.of(3000, 11, 10, 13, 0), LocalDateTime.of(3000, 11, 10, 15, 30));
reservationRepository.saveAll(List.of(reservation1, reservation2, reservation3));

//when
final List<RoomResponse> response = roomService.findAllAtDate(LocalDate.of(2023, 11, 10), authentication);
final List<RoomResponse> response = roomService.findAllAtDate(LocalDate.of(3000, 11, 10), authentication);

//then
assertSoftly(softAssertions -> {
Expand Down

0 comments on commit 42f9214

Please sign in to comment.