diff --git a/src/test/java/com/prgrms/catchtable/reservation/controller/MemberReservationControllerTest.java b/src/test/java/com/prgrms/catchtable/reservation/controller/MemberReservationControllerTest.java index 4d46c7f0..88ea0402 100644 --- a/src/test/java/com/prgrms/catchtable/reservation/controller/MemberReservationControllerTest.java +++ b/src/test/java/com/prgrms/catchtable/reservation/controller/MemberReservationControllerTest.java @@ -170,8 +170,9 @@ void registerReservationWithException() throws Exception { @DisplayName("예약 수정 api 호출에 성공한다.") void modifyReservation() throws Exception { ReservationTime reservationTime = reservationTimeRepository.findAll().get(0); + Member member1 = memberRepository.findAll().get(0); reservationTime.setOccupiedTrue(); - Reservation reservation = ReservationFixture.getReservation(reservationTime); + Reservation reservation = ReservationFixture.getReservationWithMember(reservationTime, member1); Reservation savedReservation = reservationRepository.save(reservation); /** * 수정하려는 예약시간 예제 데이터 생성 @@ -204,7 +205,8 @@ void modifyReservation() throws Exception { @DisplayName("예약 삭제 api 호출에 성공한다") void cancelReservation() throws Exception { ReservationTime reservationTime = reservationTimeRepository.findAll().get(0); - Reservation reservation = ReservationFixture.getReservation(reservationTime); + Member member1 = memberRepository.findAll().get(0); + Reservation reservation = ReservationFixture.getReservationWithMember(reservationTime, member1); Reservation savedReservation = reservationRepository.save(reservation); mockMvc.perform(delete("/reservations/{reservationId}", savedReservation.getId()) diff --git a/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java b/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java index 01e4629c..20efc437 100644 --- a/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java +++ b/src/test/java/com/prgrms/catchtable/reservation/controller/OwnerReservationControllerTest.java @@ -12,6 +12,9 @@ import com.prgrms.catchtable.common.base.BaseIntegrationTest; import com.prgrms.catchtable.common.data.shop.ShopData; import com.prgrms.catchtable.jwt.token.Token; +import com.prgrms.catchtable.member.MemberFixture; +import com.prgrms.catchtable.member.domain.Member; +import com.prgrms.catchtable.member.repository.MemberRepository; import com.prgrms.catchtable.owner.domain.Owner; import com.prgrms.catchtable.owner.fixture.OwnerFixture; import com.prgrms.catchtable.owner.repository.OwnerRepository; @@ -44,6 +47,8 @@ class OwnerReservationControllerTest extends BaseIntegrationTest { private ShopRepository shopRepository; @Autowired private ReservationRepository reservationRepository; + @Autowired + private MemberRepository memberRepository; @BeforeEach void setUp() { @@ -53,8 +58,11 @@ void setUp() { ReservationTime savedReservationTime = reservationTimeRepository.save(reservationTime); savedReservationTime.setOccupiedTrue(); log.info("예약 시간 차지 여부 : {}", savedReservationTime.isOccupied()); + + Member member = MemberFixture.member("qwe@naver.com"); + Member savedMember = memberRepository.save(member); Reservation reservation = reservationRepository.save( - ReservationFixture.getReservation(savedReservationTime)); + ReservationFixture.getReservationWithMember(savedReservationTime,savedMember)); ReservationTime reservationTime2 = ReservationFixture.getAnotherReservationTimeNotPreOccupied(); reservationTime2.insertShop(shop); diff --git a/src/test/java/com/prgrms/catchtable/reservation/fixture/ReservationFixture.java b/src/test/java/com/prgrms/catchtable/reservation/fixture/ReservationFixture.java index af468e84..d7c49f9d 100644 --- a/src/test/java/com/prgrms/catchtable/reservation/fixture/ReservationFixture.java +++ b/src/test/java/com/prgrms/catchtable/reservation/fixture/ReservationFixture.java @@ -3,6 +3,7 @@ import static com.prgrms.catchtable.reservation.domain.ReservationStatus.COMPLETED; import com.prgrms.catchtable.common.data.shop.ShopData; +import com.prgrms.catchtable.member.MemberFixture; import com.prgrms.catchtable.member.domain.Member; import com.prgrms.catchtable.reservation.domain.Reservation; import com.prgrms.catchtable.reservation.domain.ReservationStatus; @@ -108,4 +109,15 @@ public static Reservation getReservation(ReservationTime reservationTime, Member .build(); } + public static Reservation getReservationWithMember(ReservationTime reservationTime, Member member) { + if (!reservationTime.isOccupied()) { + reservationTime.setOccupiedTrue(); + } + return Reservation.builder() + .status(COMPLETED) + .peopleCount(4) + .reservationTime(reservationTime) + .member(member) + .build(); + } } diff --git a/src/test/java/com/prgrms/catchtable/reservation/repository/ReservationRepositoryTest.java b/src/test/java/com/prgrms/catchtable/reservation/repository/ReservationRepositoryTest.java index 42bcbb34..2e56cbf0 100644 --- a/src/test/java/com/prgrms/catchtable/reservation/repository/ReservationRepositoryTest.java +++ b/src/test/java/com/prgrms/catchtable/reservation/repository/ReservationRepositoryTest.java @@ -70,7 +70,10 @@ void findByIdWithReservationTimeAndShop() { reservationTime.insertShop(savedShop); ReservationTime savedReservationTime = reservationTimeRepository.save(reservationTime); - Reservation reservation = ReservationFixture.getReservation(savedReservationTime); + Member member = MemberFixture.member("dlswns661035@gmail.com"); + Member savedMember = memberRepository.save(member); + + Reservation reservation = ReservationFixture.getReservationWithMember(savedReservationTime, savedMember); Reservation savedReservation = reservationRepository.save(reservation); Reservation findReservation = reservationRepository.findByIdWithReservationTimeAndShop( diff --git a/src/test/java/com/prgrms/catchtable/reservation/service/MemberReservationServiceTest.java b/src/test/java/com/prgrms/catchtable/reservation/service/MemberReservationServiceTest.java index 165a56b7..6fd4b429 100644 --- a/src/test/java/com/prgrms/catchtable/reservation/service/MemberReservationServiceTest.java +++ b/src/test/java/com/prgrms/catchtable/reservation/service/MemberReservationServiceTest.java @@ -204,7 +204,7 @@ void modifyReservation() { ReservationTime modifyTime = ReservationFixture.getAnotherReservationTimeNotPreOccupied(); ReflectionTestUtils.setField(modifyTime, "id", 2L); //수정하려는 예약시간 객체 -> Id : 2 - Reservation reservation = ReservationFixture.getReservation(reservationTime); + Reservation reservation = ReservationFixture.getReservationWithMember(reservationTime, MemberFixture.member("dlsw@gamil.com")); ModifyReservationRequest request = ReservationFixture.getModifyReservationRequest( 2L);