Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 쿠폰 도메인에 메타데이터 필드 추가 #847

Merged
merged 6 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.gdschongik.gdsc.domain.coupon.application;

import static com.gdschongik.gdsc.domain.coupon.domain.IssuanceType.*;
import static com.gdschongik.gdsc.global.exception.ErrorCode.*;

import com.gdschongik.gdsc.domain.common.vo.Money;
import com.gdschongik.gdsc.domain.coupon.dao.CouponRepository;
import com.gdschongik.gdsc.domain.coupon.dao.IssuedCouponRepository;
import com.gdschongik.gdsc.domain.coupon.domain.Coupon;
import com.gdschongik.gdsc.domain.coupon.domain.CouponType;
import com.gdschongik.gdsc.domain.coupon.domain.IssuedCoupon;
import com.gdschongik.gdsc.domain.coupon.dto.request.CouponCreateRequest;
import com.gdschongik.gdsc.domain.coupon.dto.request.CouponIssueRequest;
Expand All @@ -16,10 +18,13 @@
import com.gdschongik.gdsc.domain.member.dao.MemberRepository;
import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.study.dao.StudyHistoryRepository;
import com.gdschongik.gdsc.domain.study.dao.StudyRepository;
import com.gdschongik.gdsc.domain.study.domain.Study;
import com.gdschongik.gdsc.domain.study.domain.StudyHistory;
import com.gdschongik.gdsc.global.exception.CustomException;
import com.gdschongik.gdsc.global.util.MemberUtil;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
Expand All @@ -36,13 +41,16 @@ public class CouponService {
private final CouponNameUtil couponNameUtil;
private final MemberUtil memberUtil;
private final StudyHistoryRepository studyHistoryRepository;
private final StudyRepository studyRepository;
private final CouponRepository couponRepository;
private final IssuedCouponRepository issuedCouponRepository;
private final MemberRepository memberRepository;

@Transactional
public void createCoupon(CouponCreateRequest request) {
Coupon coupon = Coupon.create(request.name(), Money.from(request.discountAmount()));
Optional<Study> study = Optional.ofNullable(request.studyId()).flatMap(studyRepository::findById);
Coupon coupon = Coupon.create(
request.name(), Money.from(request.discountAmount()), request.couponType(), MANUAL, study.orElse(null));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

쿠폰 타입과 스터디 관계 검증이 필요합니다

현재 구현에서 ADMIN 타입 쿠폰에 스터디가 연결되거나, STUDY_COMPLETION 타입 쿠폰에 스터디가 없는 경우를 방지하는 검증 로직이 없습니다. 다음과 같은 검증 로직 추가를 제안합니다:

 Optional<Study> study = Optional.ofNullable(request.studyId()).flatMap(studyRepository::findById);
+if (request.couponType() == CouponType.ADMIN && study.isPresent()) {
+    throw new CustomException(new ErrorCode("어드민 쿠폰은 스터디와 연결될 수 없습니다."));
+}
+if (request.couponType() == CouponType.STUDY_COMPLETION && study.isEmpty()) {
+    throw new CustomException(new ErrorCode("스터디 수료 쿠폰은 반드시 스터디와 연결되어야 합니다."));
+}
 Coupon coupon = Coupon.create(
         request.name(), Money.from(request.discountAmount()), request.couponType(), MANUAL, study.orElse(null));
🔗 Analysis chain

쿠폰 타입과 스터디 관계에 대한 유효성 검증이 필요합니다.

현재 구현에서는 쿠폰 타입과 스터디 관계의 유효성을 검증하지 않고 있습니다. 예를 들어, ADMIN 타입 쿠폰에 스터디가 연결되거나, STUDY_COMPLETION 타입 쿠폰에 스터디가 없는 경우를 방지해야 합니다.

다음과 같은 검증 로직 추가를 제안합니다:

 Optional<Study> study = Optional.ofNullable(request.studyId()).flatMap(studyRepository::findById);
+if (request.couponType() == CouponType.ADMIN && study.isPresent()) {
+    throw new CustomException(INVALID_COUPON_TYPE_STUDY_COMBINATION);
+}
+if (request.couponType() == CouponType.STUDY_COMPLETION && study.isEmpty()) {
+    throw new CustomException(STUDY_REQUIRED_FOR_STUDY_COMPLETION_COUPON);
+}
 Coupon coupon = Coupon.create(
         request.name(), Money.from(request.discountAmount()), request.couponType(), MANUAL, study.orElse(null));
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Find and examine CouponType enum and Coupon-related files
echo "=== CouponType enum definition ==="
fd -e java -E test "CouponType.java" --exec cat {}

echo -e "\n=== Coupon entity and related implementations ==="
fd -e java -E test "Coupon.java" --exec cat {}

echo -e "\n=== Searching for existing validation patterns ==="
rg -A 5 "CouponType.*Study" --type java

Length of output: 8929


Script:

#!/bin/bash
# Check for error codes related to coupon validation
echo "=== Error Codes ==="
fd -e java "ErrorCode.java" --exec cat {}

echo -e "\n=== Searching for coupon-related exceptions ==="
rg "COUPON.*" --type java

Length of output: 19835

couponRepository.save(coupon);
log.info("[CouponService] 쿠폰 생성: name={}, discountAmount={}", request.name(), request.discountAmount());
}
Expand Down Expand Up @@ -100,11 +108,11 @@ public void createAndIssueCouponByStudyHistories(List<Long> studyHistoryIds) {
.map(studyHistory -> studyHistory.getStudent().getId())
.toList();
List<Member> students = memberRepository.findAllById(studentIds);
Study study = studyHistories.get(0).getStudy();

Comment on lines +110 to 111
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

스터디 히스토리의 일관성 검증이 필요합니다.

코드베이스 분석 결과, 현재 구현에서는 모든 히스토리가 동일한 스터디에서 왔다고 가정하고 있으며, 이를 검증하는 로직이 없습니다. 이는 잘못된 쿠폰 발급으로 이어질 수 있습니다.

다음과 같은 검증 로직 추가를 제안합니다:

Set<Study> uniqueStudies = studyHistories.stream()
    .map(StudyHistory::getStudy)
    .collect(Collectors.toSet());
if (uniqueStudies.size() > 1) {
    throw new CustomException(MULTIPLE_STUDIES_NOT_ALLOWED);
}
Study study = studyHistories.get(0).getStudy();
🔗 Analysis chain

스터디 히스토리의 일관성 검증이 필요합니다.

첫 번째 히스토리에서 스터디 정보를 가져오는 방식은 모든 히스토리가 동일한 스터디에서 왔다고 가정합니다. 이 가정이 깨질 경우 잘못된 쿠폰이 발급될 수 있습니다.

다음과 같은 검증 로직 추가를 제안합니다:

+Set<Study> uniqueStudies = studyHistories.stream()
+    .map(StudyHistory::getStudy)
+    .collect(Collectors.toSet());
+if (uniqueStudies.size() > 1) {
+    throw new CustomException(MULTIPLE_STUDIES_NOT_ALLOWED);
+}
 Study study = studyHistories.get(0).getStudy();
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for StudyHistory related patterns
ast-grep --pattern 'List<StudyHistory> $_ = $_'
ast-grep --pattern 'studyHistories.stream().$$$'

# Search for validation patterns
rg "throw\s+new\s+CustomException" -A 2

# Search for Study related validations
rg "Study.*validate" -A 2

Length of output: 35307


Script:

#!/bin/bash
# Check StudyHistoryValidator implementation
ast-grep --pattern 'class StudyHistoryValidator {
  $$$
}'

# Search for any study-related consistency checks
rg "studyHistories.*stream\(\).*collect" -A 2

Length of output: 108


Script:

#!/bin/bash
# Search for any stream operations on studyHistories
rg "studyHistories\." -A 3

# Look for study validation patterns
ast-grep --pattern 'validateStudy($$$)'
ast-grep --pattern 'validate($$$) {
  $$$
  study
  $$$
}'

Length of output: 7962

String couponName = couponNameUtil.generateStudyCompletionCouponName(
studyHistories.get(0).getStudy());
String couponName = couponNameUtil.generateStudyCompletionCouponName(study);
// TODO: 요청할 때마다 새로운 쿠폰 생성되는 문제 수정: 스터디마다 하나의 쿠폰만 존재하도록 쿠폰 타입 및 참조 식별자 추가
Coupon coupon = Coupon.create(couponName, Money.from(5000L));
Coupon coupon = Coupon.create(couponName, Money.from(5000L), CouponType.STUDY_COMPLETION, AUTOMATIC, study);
Copy link

@coderabbitai coderabbitai bot Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

하드코딩된 할인 금액 값 개선 필요

스터디 완료 쿠폰의 할인 금액이 5000원으로 하드코딩되어 있습니다. 이 값은 설정 파일이나 상수로 관리되어야 합니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 이 의견에 동의합니다. 할인액은 상수로 관리하면 좋을 것 같아요

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kckc0608 감사합니다. 이 피드백을 반영하여 다음 PR에서 할인액을 상수로 관리하도록 하겠습니다.


✏️ Learnings added
Learnt from: kckc0608
PR: GDSC-Hongik/gdsc-server#847
File: src/main/java/com/gdschongik/gdsc/domain/coupon/application/CouponService.java:115-115
Timestamp: 2025-01-22T12:26:59.977Z
Learning: Discount amounts in the coupon domain should be managed as constants rather than hardcoded values, especially for specific coupon types like study completion coupons.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저 부분은 바로 윗줄 todo 처리할 때 아예 제거될거라서 그때 처리하면 될 것 같아요

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

스터디별 중복 쿠폰 생성 문제 해결 필요

TODO 주석에서 언급된 것처럼, 현재 구현은 요청할 때마다 새로운 쿠폰이 생성되는 문제가 있습니다.

다음과 같은 해결 방안을 제안합니다:

  1. 스터디 ID와 쿠폰 타입을 복합 유니크 키로 설정
  2. 쿠폰 생성 전에 기존 쿠폰 존재 여부를 확인하는 로직 추가
+        Optional<Coupon> existingCoupon = couponRepository.findByStudyAndCouponType(study, CouponType.STUDY_COMPLETION);
+        Coupon coupon = existingCoupon.orElseGet(() -> {
             String couponName = couponNameUtil.generateStudyCompletionCouponName(study);
-            Coupon coupon = Coupon.create(couponName, Money.from(5000L), CouponType.STUDY_COMPLETION, AUTOMATIC, study);
-            couponRepository.save(coupon);
+            Coupon newCoupon = Coupon.create(couponName, Money.from(5000L), CouponType.STUDY_COMPLETION, AUTOMATIC, study);
+            return couponRepository.save(newCoupon);
+        });

Committable suggestion skipped: line range outside the PR's diff.

couponRepository.save(coupon);

List<IssuedCoupon> issuedCoupons = students.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

import com.gdschongik.gdsc.domain.common.model.BaseEntity;
import com.gdschongik.gdsc.domain.common.vo.Money;
import com.gdschongik.gdsc.domain.study.domain.Study;
import com.gdschongik.gdsc.global.exception.CustomException;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -31,15 +37,35 @@ public class Coupon extends BaseEntity {
@Embedded
private Money discountAmount;

@Enumerated(EnumType.STRING)
private CouponType couponType;

@Enumerated(EnumType.STRING)
private IssuanceType issuanceType;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "study_id")
private Study study;

@Builder(access = AccessLevel.PRIVATE)
private Coupon(String name, Money discountAmount) {
private Coupon(String name, Money discountAmount, CouponType couponType, IssuanceType issuanceType, Study study) {
this.name = name;
this.discountAmount = discountAmount;
this.couponType = couponType;
this.issuanceType = issuanceType;
this.study = study;
}

public static Coupon create(String name, Money discountAmount) {
public static Coupon create(
String name, Money discountAmount, CouponType couponType, IssuanceType issuanceType, Study study) {
validateDiscountAmountPositive(discountAmount);
return Coupon.builder().name(name).discountAmount(discountAmount).build();
return Coupon.builder()
.name(name)
.discountAmount(discountAmount)
.couponType(couponType)
.issuanceType(issuanceType)
.study(study)
.build();
}

// 검증 로직
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.gdschongik.gdsc.domain.coupon.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum CouponType {
ADMIN("어드민"),
STUDY_COMPLETION("스터디 수료");

private final String value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.gdschongik.gdsc.domain.coupon.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum IssuanceType {
AUTOMATIC("자동 발급"),
MANUAL("수동 발급");

private final String value;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package com.gdschongik.gdsc.domain.coupon.dto.request;

import com.gdschongik.gdsc.domain.coupon.domain.CouponType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import java.math.BigDecimal;

public record CouponCreateRequest(@NotBlank String name, @Positive BigDecimal discountAmount) {}
public record CouponCreateRequest(
@NotBlank String name,
@Positive BigDecimal discountAmount,
@NotNull(message = "쿠폰 타입은 null이 될 수 없습니다.") CouponType couponType,
@Nullable @Schema(description = "스터디 관련 쿠폰이 아니라면 null을 가집니다.") Long studyId) {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gdschongik.gdsc.domain.coupon.application;

import static com.gdschongik.gdsc.domain.coupon.domain.CouponType.*;
import static com.gdschongik.gdsc.global.common.constant.CouponConstant.*;
import static com.gdschongik.gdsc.global.exception.ErrorCode.*;
import static java.math.BigDecimal.*;
Expand Down Expand Up @@ -34,7 +35,7 @@ class 쿠폰_생성할때 {
@Test
void 성공한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);

// when
couponService.createCoupon(request);
Expand All @@ -46,7 +47,7 @@ class 쿠폰_생성할때 {
@Test
void 할인금액이_양수가_아니라면_실패한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ZERO);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ZERO, ADMIN, null);

// when & then
assertThatThrownBy(() -> couponService.createCoupon(request))
Expand All @@ -61,7 +62,7 @@ class 쿠폰_발급할때 {
@Test
void 성공한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);
couponService.createCoupon(request);

createMember();
Expand All @@ -79,7 +80,7 @@ class 쿠폰_발급할때 {
@Test
void 존재하지_않는_유저이면_제외하고_성공한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);
couponService.createCoupon(request);

createMember();
Expand All @@ -97,7 +98,7 @@ class 쿠폰_발급할때 {
@Test
void 존재하지_않는_쿠폰이면_실패한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);
couponService.createCoupon(request);

createMember();
Expand All @@ -118,7 +119,7 @@ class 쿠폰_회수할때 {
@Test
void 성공한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);
couponService.createCoupon(request);

createMember();
Expand All @@ -137,7 +138,7 @@ class 쿠폰_회수할때 {
@Test
void 존재하지_않는_발급쿠폰이면_실패한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);
couponService.createCoupon(request);

createMember();
Expand All @@ -153,7 +154,7 @@ class 쿠폰_회수할때 {
@Test
void 이미_회수한_발급쿠폰이면_실패한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);
couponService.createCoupon(request);

createMember();
Expand All @@ -174,7 +175,7 @@ class 쿠폰_회수할때 {
@Test
void 이미_사용한_발급쿠폰이면_실패한다() {
// given
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE);
CouponCreateRequest request = new CouponCreateRequest(COUPON_NAME, ONE, ADMIN, null);
couponService.createCoupon(request);

createMember();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gdschongik.gdsc.domain.coupon.domain;

import static com.gdschongik.gdsc.domain.coupon.domain.CouponType.*;
import static com.gdschongik.gdsc.domain.coupon.domain.IssuanceType.*;
import static com.gdschongik.gdsc.global.common.constant.CouponConstant.*;
import static com.gdschongik.gdsc.global.exception.ErrorCode.*;
import static java.math.BigDecimal.*;
Expand All @@ -18,7 +20,7 @@ class 쿠폰_생성할때 {
@Test
void 성공한다() {
// when
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

상수를 사용한 할인 금액 관리가 필요합니다.

이전 피드백에 따라 할인 금액을 상수로 관리하는 것이 좋습니다. ONE 대신 의미 있는 상수를 정의하여 사용하세요.

-Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
+Coupon coupon = Coupon.create(COUPON_NAME, Money.from(DEFAULT_DISCOUNT_AMOUNT), ADMIN, AUTOMATIC, null);

Committable suggestion skipped: line range outside the PR's diff.


// then
assertThat(coupon).isNotNull();
Expand All @@ -30,7 +32,7 @@ class 쿠폰_생성할때 {
Money discountAmount = Money.from(ZERO);

// when & then
assertThatThrownBy(() -> Coupon.create(COUPON_NAME, discountAmount))
assertThatThrownBy(() -> Coupon.create(COUPON_NAME, discountAmount, ADMIN, AUTOMATIC, null))
.isInstanceOf(CustomException.class)
.hasMessageContaining(COUPON_DISCOUNT_AMOUNT_NOT_POSITIVE.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gdschongik.gdsc.domain.coupon.domain;

import static com.gdschongik.gdsc.domain.coupon.domain.CouponType.*;
import static com.gdschongik.gdsc.domain.coupon.domain.IssuanceType.*;
import static com.gdschongik.gdsc.global.common.constant.CouponConstant.*;
import static com.gdschongik.gdsc.global.common.constant.MemberConstant.*;
import static com.gdschongik.gdsc.global.exception.ErrorCode.*;
Expand All @@ -21,7 +23,7 @@ class 발급쿠폰_사용할때 {
@Test
void 성공하면_사용여부는_true이다() {
// given
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
LocalDateTime now = LocalDateTime.now();
Expand All @@ -36,7 +38,7 @@ class 발급쿠폰_사용할때 {
@Test
void 이미_사용한_쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
LocalDateTime now = LocalDateTime.now();
Expand All @@ -51,7 +53,7 @@ class 발급쿠폰_사용할때 {
@Test
void 이미_회수한_쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
issuedCoupon.revoke();
Expand All @@ -70,7 +72,7 @@ class 발급쿠폰_회수할때 {
@Test
void 성공하면_회수여부는_true이다() {
// given
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);

Expand All @@ -84,7 +86,7 @@ class 발급쿠폰_회수할때 {
@Test
void 이미_회수한_발급쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
issuedCoupon.revoke();
Expand All @@ -98,7 +100,7 @@ class 발급쿠폰_회수할때 {
@Test
void 이미_사용한_발급쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE), ADMIN, AUTOMATIC, null);
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
issuedCoupon.use(LocalDateTime.now());
Expand Down
Loading
Loading