From 5132c30a2e184a7384bcce3206c3bab8e24929da Mon Sep 17 00:00:00 2001 From: rightpair Date: Tue, 23 Jan 2024 22:44:43 +0900 Subject: [PATCH] =?UTF-8?q?[test]=20couponRoomStayMore=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EA=B4=80=EB=A0=A8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docs/coupon/CouponControllerTest.java | 19 ++++++++++++------- .../coupon/service/CouponServiceTest.java | 16 +++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/coolpeace/docs/coupon/CouponControllerTest.java b/src/test/java/com/coolpeace/docs/coupon/CouponControllerTest.java index 0f66c9db..bb9e8e41 100644 --- a/src/test/java/com/coolpeace/docs/coupon/CouponControllerTest.java +++ b/src/test/java/com/coolpeace/docs/coupon/CouponControllerTest.java @@ -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; @@ -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, @@ -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("등록될 객실의 리스트"), @@ -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("노출 시작 날짜"), @@ -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("노출 시작 날짜"), @@ -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("노출 시작 날짜"), @@ -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, @@ -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(), diff --git a/src/test/java/com/coolpeace/domain/coupon/service/CouponServiceTest.java b/src/test/java/com/coolpeace/domain/coupon/service/CouponServiceTest.java index a2044e6c..bc483988 100644 --- a/src/test/java/com/coolpeace/domain/coupon/service/CouponServiceTest.java +++ b/src/test/java/com/coolpeace/domain/coupon/service/CouponServiceTest.java @@ -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; @@ -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, @@ -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(), @@ -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,