-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 멤버 예매 연동 * test: 테스트코드 멤버 연동 * test: 테스트코드 멤버 생성 수정 * refactor: booking의 member nullable=false 설정 추가 * fix: 불필요한 출력 제거 * fix: custom exception으로 처리
- Loading branch information
Showing
5 changed files
with
71 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,19 @@ | |
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.pgms.apibooking.domain.booking.service.BookingService; | ||
import com.pgms.apibooking.config.TestConfig; | ||
import com.pgms.apibooking.domain.booking.dto.request.BookingCancelRequest; | ||
import com.pgms.apibooking.domain.booking.dto.request.BookingCreateRequest; | ||
import com.pgms.apibooking.domain.payment.dto.request.RefundAccountRequest; | ||
import com.pgms.apibooking.domain.booking.dto.response.BookingCreateResponse; | ||
import com.pgms.apibooking.domain.booking.service.BookingService; | ||
import com.pgms.apibooking.domain.payment.dto.request.RefundAccountRequest; | ||
import com.pgms.apibooking.exception.BookingErrorCode; | ||
import com.pgms.apibooking.exception.BookingException; | ||
import com.pgms.apibooking.factory.BookingFactory; | ||
|
@@ -49,6 +50,11 @@ | |
import com.pgms.coredomain.domain.event.repository.EventSeatAreaRepository; | ||
import com.pgms.coredomain.domain.event.repository.EventSeatRepository; | ||
import com.pgms.coredomain.domain.event.repository.EventTimeRepository; | ||
import com.pgms.coredomain.domain.member.Member; | ||
import com.pgms.coredomain.domain.member.Role; | ||
import com.pgms.coredomain.domain.member.enums.Provider; | ||
import com.pgms.coredomain.domain.member.repository.MemberRepository; | ||
import com.pgms.coredomain.domain.member.repository.RoleRepository; | ||
|
||
@SpringBootTest | ||
@Import(TestConfig.class) | ||
|
@@ -77,6 +83,26 @@ class BookingServiceTest { | |
|
||
@Autowired | ||
private BookingService bookingService; | ||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private RoleRepository roleRepository; | ||
|
||
private Member member; | ||
|
||
@BeforeEach | ||
void setup() { | ||
Role role = roleRepository.save(new Role("ROLE_USER")); | ||
member = memberRepository.save(Member.builder() | ||
.email("[email protected]") | ||
.password("test1234!") | ||
.name("홍길동") | ||
.provider(Provider.KAKAO) | ||
.role(role) | ||
.phoneNumber("010-123-456") | ||
.build()); | ||
} | ||
|
||
@Test | ||
void 예매를_생성한다() { | ||
|
@@ -130,7 +156,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when | ||
BookingCreateResponse response = bookingService.createBooking(request); | ||
BookingCreateResponse response = bookingService.createBooking(request, member.getId()); | ||
|
||
// then | ||
Booking booking = bookingRepository.findBookingInfoById(response.bookingId()).get(); | ||
|
@@ -201,7 +227,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> bookingService.createBooking(request)) | ||
assertThatThrownBy(() -> bookingService.createBooking(request, member.getId())) | ||
.isInstanceOf(BookingException.class) | ||
.hasMessage(BookingErrorCode.UNBOOKABLE_EVENT.getMessage()); | ||
} | ||
|
@@ -253,7 +279,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> bookingService.createBooking(request)) | ||
assertThatThrownBy(() -> bookingService.createBooking(request, member.getId())) | ||
.isInstanceOf(BookingException.class) | ||
.hasMessage(BookingErrorCode.NON_EXISTENT_SEAT_INCLUSION.getMessage()); | ||
} | ||
|
@@ -303,7 +329,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> bookingService.createBooking(request)) | ||
assertThatThrownBy(() -> bookingService.createBooking(request, member.getId())) | ||
.isInstanceOf(BookingException.class) | ||
.hasMessage(BookingErrorCode.UNBOOKABLE_SEAT_INCLUSION.getMessage()); | ||
} | ||
|
@@ -353,7 +379,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> bookingService.createBooking(request)) | ||
assertThatThrownBy(() -> bookingService.createBooking(request, member.getId())) | ||
.isInstanceOf(BookingException.class) | ||
.hasMessage(BookingErrorCode.DELIVERY_ADDRESS_REQUIRED.getMessage()); | ||
} | ||
|
@@ -388,7 +414,7 @@ class BookingServiceTest { | |
eventSeatRepository.save(seat); | ||
|
||
Booking booking = BookingFactory.generate( | ||
null, | ||
member, | ||
time, | ||
seat.getEventSeatArea().getPrice(), | ||
BookingStatus.PAYMENT_COMPLETED | ||
|
@@ -407,7 +433,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when | ||
bookingService.cancelBooking(booking.getId(), request); | ||
bookingService.cancelBooking(booking.getId(), request, member.getId()); | ||
|
||
// then | ||
Booking canceledBooking = bookingRepository.findBookingInfoById(booking.getId()).get(); | ||
|
@@ -455,7 +481,7 @@ class BookingServiceTest { | |
eventSeatRepository.save(seat); | ||
|
||
Booking booking = BookingFactory.generate( | ||
null, | ||
member, | ||
time, | ||
seat.getEventSeatArea().getPrice(), | ||
BookingStatus.CANCELED | ||
|
@@ -474,7 +500,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> bookingService.cancelBooking(booking.getId(), request)) | ||
assertThatThrownBy(() -> bookingService.cancelBooking(booking.getId(), request, member.getId())) | ||
.isInstanceOf(BookingException.class) | ||
.hasMessage(BookingErrorCode.UNCANCELABLE_BOOKING.getMessage()); | ||
} | ||
|
@@ -509,7 +535,7 @@ class BookingServiceTest { | |
eventSeatRepository.save(seat); | ||
|
||
Booking booking = BookingFactory.generate( | ||
null, | ||
member, | ||
time, | ||
seat.getEventSeatArea().getPrice(), | ||
BookingStatus.PAYMENT_COMPLETED | ||
|
@@ -529,7 +555,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> bookingService.cancelBooking(booking.getId(), request)) | ||
assertThatThrownBy(() -> bookingService.cancelBooking(booking.getId(), request, member.getId())) | ||
.isInstanceOf(BookingException.class) | ||
.hasMessage(BookingErrorCode.REFUND_ACCOUNT_REQUIRED.getMessage()); | ||
} | ||
|
@@ -564,7 +590,7 @@ class BookingServiceTest { | |
eventSeatRepository.save(seat); | ||
|
||
Booking booking = BookingFactory.generate( | ||
null, | ||
member, | ||
time, | ||
seat.getEventSeatArea().getPrice(), | ||
BookingStatus.PAYMENT_COMPLETED | ||
|
@@ -583,7 +609,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when | ||
bookingService.cancelBooking(booking.getId(), request); | ||
bookingService.cancelBooking(booking.getId(), request, member.getId()); | ||
|
||
// then | ||
Booking canceledBooking = bookingRepository.findBookingInfoById(booking.getId()).get(); | ||
|
@@ -620,7 +646,7 @@ class BookingServiceTest { | |
eventSeatRepository.save(seat); | ||
|
||
Booking booking = BookingFactory.generate( | ||
null, | ||
member, | ||
time, | ||
seat.getEventSeatArea().getPrice(), | ||
BookingStatus.WAITING_FOR_PAYMENT | ||
|
@@ -646,7 +672,7 @@ class BookingServiceTest { | |
); | ||
|
||
// when | ||
bookingService.cancelBooking(booking.getId(), request); | ||
bookingService.cancelBooking(booking.getId(), request, member.getId()); | ||
|
||
// then | ||
Booking canceledBooking = bookingRepository.findBookingInfoById(booking.getId()).get(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters