|
1 | 1 | package timeeat.domain.menu; |
2 | 2 |
|
3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
4 | | -import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
5 | 5 |
|
6 | 6 | import java.time.LocalDateTime; |
7 | 7 |
|
@@ -52,37 +52,37 @@ class CreateDiscount { |
52 | 52 | void 할인_가격이_원가보다_비싸면_예외를_던진다() { |
53 | 53 | Integer invalidDiscountPrice = 12000; |
54 | 54 |
|
55 | | - assertThatThrownBy(() -> new Discount(originalPrice, invalidDiscountPrice, null, null)) |
56 | | - .isInstanceOf(BusinessException.class) |
57 | | - .hasFieldOrPropertyWithValue("errorCode", BusinessErrorCode.INVALID_MENU_DISCOUNT_PRICE); |
| 55 | + BusinessException exception = assertThrows(BusinessException.class, () -> new Discount(originalPrice, invalidDiscountPrice, null, null)); |
| 56 | + |
| 57 | + assertThat(exception.getErrorCode()).isEqualTo(BusinessErrorCode.INVALID_MENU_DISCOUNT_PRICE); |
58 | 58 | } |
59 | 59 |
|
60 | 60 | @Test |
61 | 61 | void 할인_가격이_원가와_같으면_예외를_던진다() { |
62 | 62 | Integer sameDiscountPrice = 10000; |
63 | 63 |
|
64 | | - assertThatThrownBy(() -> new Discount(originalPrice, sameDiscountPrice, null, null)) |
65 | | - .isInstanceOf(BusinessException.class) |
66 | | - .hasFieldOrPropertyWithValue("errorCode", BusinessErrorCode.INVALID_MENU_DISCOUNT_PRICE); |
| 64 | + BusinessException exception = assertThrows(BusinessException.class, () -> new Discount(originalPrice, sameDiscountPrice, null, null)); |
| 65 | + |
| 66 | + assertThat(exception.getErrorCode()).isEqualTo(BusinessErrorCode.INVALID_MENU_DISCOUNT_PRICE); |
67 | 67 | } |
68 | 68 |
|
69 | 69 | @Test |
70 | 70 | void 할인_가격이_0원이면_예외를_던진다() { |
71 | 71 | Integer zeroDiscountPrice = 0; |
72 | 72 |
|
73 | | - assertThatThrownBy(() -> new Discount(originalPrice, zeroDiscountPrice, null, null)) |
74 | | - .isInstanceOf(BusinessException.class) |
75 | | - .hasFieldOrPropertyWithValue("errorCode", BusinessErrorCode.INVALID_MENU_DISCOUNT_PRICE); |
| 73 | + BusinessException exception = assertThrows(BusinessException.class, () -> new Discount(originalPrice, zeroDiscountPrice, null, null)); |
| 74 | + |
| 75 | + assertThat(exception.getErrorCode()).isEqualTo(BusinessErrorCode.INVALID_MENU_DISCOUNT_PRICE); |
76 | 76 | } |
77 | 77 |
|
78 | 78 | @Test |
79 | 79 | void 시작_시간이_종료_시간보다_늦으면_예외를_던진다() { |
80 | 80 | LocalDateTime startTime = LocalDateTime.now(); |
81 | 81 | LocalDateTime endTime = startTime.minusHours(2); |
82 | 82 |
|
83 | | - assertThatThrownBy(() -> new Discount(originalPrice, 8000, startTime, endTime)) |
84 | | - .isInstanceOf(BusinessException.class) |
85 | | - .hasFieldOrPropertyWithValue("errorCode", BusinessErrorCode.INVALID_MENU_DISCOUNT_TIME); |
| 83 | + BusinessException exception = assertThrows(BusinessException.class, () -> new Discount(originalPrice, 8000, startTime, endTime)); |
| 84 | + |
| 85 | + assertThat(exception.getErrorCode()).isEqualTo(BusinessErrorCode.INVALID_MENU_DISCOUNT_TIME); |
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
0 commit comments