Skip to content

Commit

Permalink
테스크 코드 포맷 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
cire0304 committed Nov 5, 2023
1 parent 9ff6f4f commit 8e1a5fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.transaction.annotation.Transactional;

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

import static org.assertj.core.api.Assertions.*;

Expand All @@ -28,15 +29,15 @@ class IssueCouponServiceTest extends IssueCouponRepositorySupport {
private CouponRepository couponRepository;
@Autowired
private UserCouponRepository userCouponRepository;

@AfterEach
public void afterEach() {
userCouponRepository.deleteAllInBatch();
}

@DisplayName("쿠폰 요청을 할 수 있다.")
@Test
public void issueCoupon() {
public void issueCoupon() {
//given
IssueUserCouponCommand command = new IssueUserCouponCommand(1L, 1L);

Expand All @@ -45,24 +46,24 @@ public void issueCoupon() {

//then
assertThat(issuedCouponId).isNotNull();
}
}

@DisplayName("동일한 쿠폰은 중복 발급할 수 없다.")
@Test
public void duplicateIssueCoupon () {
//given
IssueUserCouponCommand command = new IssueUserCouponCommand(1L, 1L);
issueCouponService.issue(command);
@DisplayName("동일한 쿠폰은 중복 발급할 수 없다.")
@Test
public void duplicateIssueCoupon() {
//given
IssueUserCouponCommand command = new IssueUserCouponCommand(1L, 1L);
issueCouponService.issue(command);

//when then
assertThatThrownBy(() -> issueCouponService.issue(command))
.isInstanceOf(DuplicatedCouponException.class)
.hasMessage("쿠폰이 이미 발급되었습니다.");
}
//when then
assertThatThrownBy(() -> issueCouponService.issue(command))
.isInstanceOf(DuplicatedCouponException.class)
.hasMessage("쿠폰이 이미 발급되었습니다.");
}

@DisplayName("발행된 쿠폰에 대해서만, 쿠폰 발급 요청할 수 있다.")
@Test
public void issueCouponForInvalidCoupon () {
public void issueCouponForInvalidCoupon() {
//given
IssueUserCouponCommand command = new IssueUserCouponCommand(1L, 0L);

Expand All @@ -74,7 +75,7 @@ public void issueCouponForInvalidCoupon () {

@DisplayName("쿠폰을 발급하면, 쿠폰 재고가 감소한다.")
@Test
public void pessimisticLockIssueCouponTest () throws InterruptedException {
public void pessimisticLockIssueCouponTest() throws InterruptedException {
//given
Long couponId = 1L;
Long userNum = 5L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void applyUserCoupon() {
//then
assertThat(discountedProductPrice.getValue()).isEqualTo(9000L);
}

@DisplayName("발급 받은 쿠폰만 사용할 수 있다.")
@Test
public void applyUnissuedUserCoupon() {
Expand Down

0 comments on commit 8e1a5fc

Please sign in to comment.