-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Api-v0.1.9
- Loading branch information
Showing
19 changed files
with
668 additions
and
142 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
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
2 changes: 2 additions & 0 deletions
2
DuDoong-Domain/src/main/java/band/gosrock/domain/domains/coupon/domain/ApplyTarget.java
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
2 changes: 2 additions & 0 deletions
2
DuDoong-Domain/src/main/java/band/gosrock/domain/domains/coupon/domain/DiscountType.java
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
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
61 changes: 61 additions & 0 deletions
61
...ng-Domain/src/test/java/band/gosrock/domain/domains/coupon/domain/CouponCampaignTest.java
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package band.gosrock.domain.domains.coupon.domain; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import band.gosrock.domain.common.vo.DateTimePeriod; | ||
import band.gosrock.domain.domains.coupon.exception.NotIssuingCouponPeriodException; | ||
import band.gosrock.domain.domains.coupon.exception.WrongDiscountAmountException; | ||
import java.time.LocalDateTime; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class CouponCampaignTest { | ||
CouponCampaign couponCampaign; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
LocalDateTime nowTime = LocalDateTime.now(); | ||
DateTimePeriod dateTimePeriod = | ||
new DateTimePeriod(nowTime.minusDays(2), nowTime.minusDays(1)); | ||
|
||
CouponStockInfo couponStockInfo = | ||
CouponStockInfo.builder().issuedAmount(3L).remainingAmount(1L).build(); | ||
couponCampaign = | ||
CouponCampaign.builder() | ||
.discountType(DiscountType.PERCENTAGE) | ||
.couponStockInfo(couponStockInfo) | ||
.dateTimePeriod(dateTimePeriod) | ||
.build(); | ||
} | ||
|
||
@Test | ||
public void testValidatePercentageAmount() { | ||
assertThrows( | ||
WrongDiscountAmountException.class, | ||
() -> { | ||
couponCampaign.validatePercentageAmount(DiscountType.PERCENTAGE, 101L); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testDecreaseCouponStock() { | ||
// given | ||
// when | ||
couponCampaign.decreaseCouponStock(); | ||
// then | ||
assertEquals(couponCampaign.getCouponStockInfo().getRemainingAmount(), 0L); | ||
} | ||
|
||
@Test | ||
public void testValidateIssuePeriod() { | ||
assertThrows( | ||
NotIssuingCouponPeriodException.class, | ||
() -> { | ||
couponCampaign.validateIssuePeriod(); | ||
}); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...g-Domain/src/test/java/band/gosrock/domain/domains/coupon/domain/CouponStockInfoTest.java
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package band.gosrock.domain.domains.coupon.domain; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import band.gosrock.domain.domains.coupon.exception.NoCouponStockLeftException; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class CouponStockInfoTest { | ||
|
||
CouponStockInfo zeroCouponStockInfo; | ||
CouponStockInfo leftCouponStockInfo; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
zeroCouponStockInfo = | ||
CouponStockInfo.builder().remainingAmount(0L).issuedAmount(3L).build(); | ||
leftCouponStockInfo = | ||
CouponStockInfo.builder().remainingAmount(1L).issuedAmount(3L).build(); | ||
} | ||
|
||
@Test | ||
public void 쿠폰_남은_재고_없음() { | ||
// given | ||
zeroCouponStockInfo = | ||
CouponStockInfo.builder().remainingAmount(0L).issuedAmount(3L).build(); | ||
// when, then | ||
assertThrows( | ||
NoCouponStockLeftException.class, () -> zeroCouponStockInfo.decreaseCouponStock()); | ||
} | ||
|
||
@Test | ||
public void 쿠폰_남은_재고_있음() { | ||
// given | ||
leftCouponStockInfo = | ||
CouponStockInfo.builder().remainingAmount(1L).issuedAmount(3L).build(); | ||
// when | ||
leftCouponStockInfo.decreaseCouponStock(); | ||
// then | ||
assertEquals(leftCouponStockInfo.getRemainingAmount(), 0L); | ||
} | ||
} |
Oops, something went wrong.