Skip to content

Commit

Permalink
[test] couponRoomStayMore 추가 관련 테스트 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tkddn204 committed Jan 23, 2024
1 parent b51ee32 commit 5132c30
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
19 changes: 12 additions & 7 deletions src/test/java/com/coolpeace/docs/coupon/CouponControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;

import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document;
import static com.epages.restdocs.apispec.ResourceDocumentation.parameterWithName;
Expand Down Expand Up @@ -108,8 +106,9 @@ void registerCoupon_success() throws Exception {
coupon.getDiscountType().equals(DiscountType.FIXED_PRICE) ? coupon.getDiscountValue() : null,
coupon.getDiscountType().equals(DiscountType.FIXED_RATE) ? coupon.getDiscountValue() : null,
coupon.getMaximumDiscountPrice(),
Stream.of(coupon.getCouponRoomType(), coupon.getCouponRoomStayType())
.filter(Objects::nonNull).map(CouponRoomType::getValue).toList(),
coupon.getCouponRoomTypeStringsExcludingTwoNight(),
coupon.getCouponRoomStayType() != null &&
coupon.getCouponRoomStayType().equals(CouponRoomType.TWO_NIGHT),
accommodation.getId(),
false,
randomRoomNumbers,
Expand Down Expand Up @@ -142,6 +141,7 @@ void registerCoupon_success() throws Exception {
fieldWithPath("discount_flat_rate").type(JsonFieldType.NUMBER).description("정률 할인의 비율").optional(),
fieldWithPath("maximum_discount_price").type(JsonFieldType.NUMBER).description("정률 할인일 때 최대 할인 한도").optional(),
fieldWithPath("coupon_room_types").type(JsonFieldType.ARRAY).description("객실의 유형"),
fieldWithPath("coupon_room_stay_more").type(JsonFieldType.BOOLEAN).description("객실의 유형이 숙박일 때 2박 이상 여부"),
fieldWithPath("accommodation_id").type(JsonFieldType.NUMBER).description("숙박업체의 ID"),
fieldWithPath("register_all_room").type(JsonFieldType.BOOLEAN).description("객실 등록 여부"),
fieldWithPath("register_rooms").type(JsonFieldType.ARRAY).description("등록될 객실의 리스트"),
Expand Down Expand Up @@ -207,6 +207,7 @@ void searchCoupon_success() throws Exception {
fieldWithPath("content[].maximum_discount_price").type(JsonFieldType.NUMBER).description("정률 할인일 때 최대 할인 한도").optional(),
fieldWithPath("content[].customer_type").type(JsonFieldType.STRING).description("고객의 유형"),
fieldWithPath("content[].coupon_room_types").type(JsonFieldType.ARRAY).description("객실의 유형"),
fieldWithPath("content[].coupon_room_stay_more").type(JsonFieldType.BOOLEAN).description("객실의 유형이 숙박일 때 2박 이상 여부"),
fieldWithPath("content[].minimum_reservation_price").type(JsonFieldType.NUMBER).description("최소 예약 가격"),
fieldWithPath("content[].coupon_use_condition_days").type(JsonFieldType.STRING).description("쿠폰 사용 가능 요일"),
fieldWithPath("content[].exposure_start_date").type(JsonFieldType.STRING).description("노출 시작 날짜"),
Expand Down Expand Up @@ -280,6 +281,7 @@ void getCouponRecentHistory_success() throws Exception {
fieldWithPath("[].maximum_discount_price").type(JsonFieldType.NUMBER).description("정률 할인일 때 최대 할인 한도").optional(),
fieldWithPath("[].customer_type").type(JsonFieldType.STRING).description("고객의 유형"),
fieldWithPath("[].coupon_room_types").type(JsonFieldType.ARRAY).description("객실의 유형"),
fieldWithPath("[].coupon_room_stay_more").type(JsonFieldType.BOOLEAN).description("객실의 유형이 숙박일 때 2박 이상 여부"),
fieldWithPath("[].minimum_reservation_price").type(JsonFieldType.NUMBER).description("최소 예약 가격"),
fieldWithPath("[].coupon_use_condition_days").type(JsonFieldType.STRING).description("쿠폰 사용 가능 요일"),
fieldWithPath("[].exposure_start_date").type(JsonFieldType.STRING).description("노출 시작 날짜"),
Expand Down Expand Up @@ -355,6 +357,7 @@ void getCouponByCouponNumber_success() throws Exception {
fieldWithPath("maximum_discount_price").type(JsonFieldType.NUMBER).description("정률 할인일 때 최대 할인 한도").optional(),
fieldWithPath("customer_type").type(JsonFieldType.STRING).description("고객의 유형"),
fieldWithPath("coupon_room_types").type(JsonFieldType.ARRAY).description("객실의 유형"),
fieldWithPath("coupon_room_stay_more").type(JsonFieldType.BOOLEAN).description("객실의 유형이 숙박일 때 2박 이상 여부"),
fieldWithPath("minimum_reservation_price").type(JsonFieldType.NUMBER).description("최소 예약 가격"),
fieldWithPath("coupon_use_condition_days").type(JsonFieldType.STRING).description("쿠폰 사용 가능 요일"),
fieldWithPath("exposure_start_date").type(JsonFieldType.STRING).description("노출 시작 날짜"),
Expand Down Expand Up @@ -389,8 +392,9 @@ void updateCoupon_success() throws Exception {
coupon.getDiscountType().equals(DiscountType.FIXED_PRICE) ? coupon.getDiscountValue() : null,
coupon.getDiscountType().equals(DiscountType.FIXED_RATE) ? coupon.getDiscountValue() : null,
coupon.getMaximumDiscountPrice(),
Stream.of(coupon.getCouponRoomType(), coupon.getCouponRoomStayType())
.filter(Objects::nonNull).map(CouponRoomType::getValue).toList(),
coupon.getCouponRoomTypeStringsExcludingTwoNight(),
coupon.getCouponRoomStayType() != null &&
coupon.getCouponRoomStayType().equals(CouponRoomType.TWO_NIGHT),
coupon.getCouponRooms().isEmpty(),
coupon.getCouponRooms().stream().map(room -> room.getRoom().getRoomNumber()).toList(),
coupon.getMinimumReservationPrice() + 10000,
Expand Down Expand Up @@ -422,7 +426,8 @@ void updateCoupon_success() throws Exception {
fieldWithPath("discount_flat_value").type(JsonFieldType.NUMBER).description("정액 할인의 값").optional(),
fieldWithPath("discount_flat_rate").type(JsonFieldType.NUMBER).description("정률 할인의 비율").optional(),
fieldWithPath("maximum_discount_price").type(JsonFieldType.NUMBER).description("정률 할인일 때 최대 할인 한도").optional(),
fieldWithPath("coupon_room_types").type(JsonFieldType.ARRAY).description("객실의 유형").optional(),
fieldWithPath("coupon_room_types").type(JsonFieldType.ARRAY).description("객실의 유형"),
fieldWithPath("coupon_room_stay_more").type(JsonFieldType.BOOLEAN).description("객실의 유형이 숙박일 때 2박 이상 여부"),
fieldWithPath("register_all_room").type(JsonFieldType.BOOLEAN).description("객실 등록 여부").optional(),
fieldWithPath("register_rooms").type(JsonFieldType.ARRAY).description("등록될 객실의 리스트").optional(),
fieldWithPath("minimum_reservation_price").type(JsonFieldType.NUMBER).description("최소 예약 가격").optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.time.LocalDate;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -322,8 +321,9 @@ private CouponRegisterRequest getCouponRegisterRequest(boolean registerAllRoom)
coupon.getDiscountType().equals(DiscountType.FIXED_PRICE) ? coupon.getDiscountValue() : null,
coupon.getDiscountType().equals(DiscountType.FIXED_RATE) ? coupon.getDiscountValue() : null,
coupon.getMaximumDiscountPrice(),
Stream.of(coupon.getCouponRoomType(), coupon.getCouponRoomStayType())
.filter(Objects::nonNull).map(CouponRoomType::getValue).toList(),
coupon.getCouponRoomTypeStringsExcludingTwoNight(),
coupon.getCouponRoomStayType() != null &&
coupon.getCouponRoomStayType().equals(CouponRoomType.TWO_NIGHT),
accommodation.getId(),
registerAllRoom,
!registerAllRoom ? registerRoomNumbers : null,
Expand Down Expand Up @@ -394,8 +394,9 @@ void updateCoupon_mono_update_success() {
null,
null,
null,
Stream.of(couponB.getCouponRoomType(), couponB.getCouponRoomStayType())
.filter(Objects::nonNull).map(CouponRoomType::getValue).toList(),
couponB.getCouponRoomTypeStringsExcludingTwoNight(),
couponB.getCouponRoomStayType() != null &&
couponB.getCouponRoomStayType().equals(CouponRoomType.TWO_NIGHT),
null,
null,
couponB.getMinimumReservationPrice(),
Expand Down Expand Up @@ -426,8 +427,9 @@ void updateCoupon_discountType_update_success() {
couponB.getDiscountType().equals(DiscountType.FIXED_PRICE) ? couponB.getDiscountValue() : null,
couponB.getDiscountType().equals(DiscountType.FIXED_RATE) ? couponB.getDiscountValue() : null,
couponB.getMaximumDiscountPrice(),
Stream.of(couponB.getCouponRoomType(), couponB.getCouponRoomStayType())
.filter(Objects::nonNull).map(CouponRoomType::getValue).toList(),
couponB.getCouponRoomTypeStringsExcludingTwoNight(),
couponB.getCouponRoomStayType() != null &&
couponB.getCouponRoomStayType().equals(CouponRoomType.TWO_NIGHT),
null,
null,
null,
Expand Down

0 comments on commit 5132c30

Please sign in to comment.