Skip to content

Commit

Permalink
fix : mapper, 쿼리 수정에 따른 테스트 전부 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
dlswns2480 committed Jan 17, 2024
1 parent 4482c68 commit 1f04832
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/**
* 수정하려는 예약시간 예제 데이터 생성
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,6 +47,8 @@ class OwnerReservationControllerTest extends BaseIntegrationTest {
private ShopRepository shopRepository;
@Autowired
private ReservationRepository reservationRepository;
@Autowired
private MemberRepository memberRepository;

@BeforeEach
void setUp() {
Expand All @@ -53,8 +58,11 @@ void setUp() {
ReservationTime savedReservationTime = reservationTimeRepository.save(reservationTime);
savedReservationTime.setOccupiedTrue();
log.info("예약 시간 차지 여부 : {}", savedReservationTime.isOccupied());

Member member = MemberFixture.member("[email protected]");
Member savedMember = memberRepository.save(member);
Reservation reservation = reservationRepository.save(
ReservationFixture.getReservation(savedReservationTime));
ReservationFixture.getReservationWithMember(savedReservationTime,savedMember));

ReservationTime reservationTime2 = ReservationFixture.getAnotherReservationTimeNotPreOccupied();
reservationTime2.insertShop(shop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ void findByIdWithReservationTimeAndShop() {
reservationTime.insertShop(savedShop);
ReservationTime savedReservationTime = reservationTimeRepository.save(reservationTime);

Reservation reservation = ReservationFixture.getReservation(savedReservationTime);
Member member = MemberFixture.member("[email protected]");
Member savedMember = memberRepository.save(member);

Reservation reservation = ReservationFixture.getReservationWithMember(savedReservationTime, savedMember);
Reservation savedReservation = reservationRepository.save(reservation);

Reservation findReservation = reservationRepository.findByIdWithReservationTimeAndShop(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]"));
ModifyReservationRequest request = ReservationFixture.getModifyReservationRequest(
2L);

Expand Down

0 comments on commit 1f04832

Please sign in to comment.