Skip to content

Commit

Permalink
refactor: 엔티티 정적 팩토리 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
uwoobeat committed Oct 15, 2024
1 parent eee5c51 commit 1f23e78
Show file tree
Hide file tree
Showing 29 changed files with 104 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CouponService {

@Transactional
public void createCoupon(CouponCreateRequest request) {
Coupon coupon = Coupon.createCoupon(request.name(), Money.from(request.discountAmount()));
Coupon coupon = Coupon.create(request.name(), Money.from(request.discountAmount()));
couponRepository.save(coupon);
log.info("[CouponService] 쿠폰 생성: name={}, discountAmount={}", request.name(), request.discountAmount());
}
Expand All @@ -59,7 +59,7 @@ public void createIssuedCoupon(CouponIssueRequest request) {
List<Member> members = memberRepository.findAllById(request.memberIds());

List<IssuedCoupon> issuedCoupons = members.stream()
.map(member -> IssuedCoupon.issue(coupon, member))
.map(member -> IssuedCoupon.create(coupon, member))
.toList();

issuedCouponRepository.saveAll(issuedCoupons);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private Coupon(String name, Money discountAmount) {
this.discountAmount = discountAmount;
}

public static Coupon createCoupon(String name, Money discountAmount) {
public static Coupon create(String name, Money discountAmount) {
validateDiscountAmountPositive(discountAmount);
return Coupon.builder().name(name).discountAmount(discountAmount).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private IssuedCoupon(Coupon coupon, Member member, Boolean hasRevoked) {
this.hasRevoked = hasRevoked;
}

public static IssuedCoupon issue(Coupon coupon, Member member) {
public static IssuedCoupon create(Coupon coupon, Member member) {
return IssuedCoupon.builder()
.coupon(coupon)
.member(member)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void createTestMember(String githubHandle) {
throw new CustomException(INTERNAL_SERVER_ERROR);
}

Member guestMember = Member.createGuestMember(githubOauthId);
Member guestMember = Member.createGuest(githubOauthId);
memberRepository.save(guestMember);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private Member(
this.associateRequirement = associateRequirement;
}

public static Member createGuestMember(String oauthId) {
public static Member createGuest(String oauthId) {
AssociateRequirement associateRequirement = AssociateRequirement.unsatisfied();
return Member.builder()
.oauthId(oauthId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void submitMembership(Long recruitmentRoundId) {

membershipValidator.validateMembershipSubmit(currentMember, recruitmentRound, isMembershipDuplicate);

Membership membership = Membership.createMembership(currentMember, recruitmentRound);
Membership membership = Membership.create(currentMember, recruitmentRound);
membershipRepository.save(membership);

log.info("[MembershipService] 멤버십 가입 신청 접수: membershipId = {}", membership.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private Membership(Member member, RecruitmentRound recruitmentRound, RegularRequ
this.regularRequirement = regularRequirement;
}

public static Membership createMembership(Member member, RecruitmentRound recruitmentRound) {
public static Membership create(Member member, RecruitmentRound recruitmentRound) {
return Membership.builder()
.member(member)
.recruitmentRound(recruitmentRound)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void createRecruitment(RecruitmentCreateRequest request) {

recruitmentValidator.validateRecruitmentCreate(isRecruitmentOverlap);

Recruitment recruitment = Recruitment.createRecruitment(
Recruitment recruitment = Recruitment.create(
request.academicYear(),
request.semesterType(),
Money.from(request.fee()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private Recruitment(
this.semesterPeriod = semesterPeriod;
}

public static Recruitment createRecruitment(
public static Recruitment create(
Integer academicYear, SemesterType semesterType, Money fee, String feeName, Period semesterPeriod) {
return Recruitment.builder()
.academicYear(academicYear)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ public void createStudyAnnouncement(Long studyId, StudyAnnouncementCreateUpdateR

studyValidator.validateStudyMentor(currentMember, study);

StudyAnnouncement studyAnnouncement =
StudyAnnouncement.createStudyAnnouncement(study, request.title(), request.link());
StudyAnnouncement studyAnnouncement = StudyAnnouncement.create(study, request.title(), request.link());
studyAnnouncementRepository.save(studyAnnouncement);

log.info("[MentorStudyService] 스터디 공지 생성: studyAnnouncementId={}", studyAnnouncement.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private Study(
this.endTime = endTime;
}

public static Study createStudy(
public static Study create(
Integer academicYear,
SemesterType semesterType,
String title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public StudyAnnouncement(Study study, String title, String link) {
this.link = link;
}

public static StudyAnnouncement createStudyAnnouncement(Study study, String title, String link) {
public static StudyAnnouncement create(Study study, String title, String link) {
return StudyAnnouncement.builder().study(study).title(title).link(link).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class StudyDomainFactory {
// 새로운 스터디를 생성합니다.
public Study createNewStudy(StudyCreateRequest request, Member mentor) {
LocalDate endDate = request.startDate().plusWeeks(request.totalWeek()).minusDays(1);
return Study.createStudy(
return Study.create(
request.academicYear(),
request.semesterType(),
request.title(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.gdschongik.gdsc.global.security;

import static com.gdschongik.gdsc.global.common.constant.SecurityConstant.*;

import com.gdschongik.gdsc.domain.member.dao.MemberRepository;
import com.gdschongik.gdsc.domain.member.domain.Member;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -33,7 +31,7 @@ private Member fetchOrCreate(OAuth2User oAuth2User) {
}

private Member registerMember(OAuth2User oAuth2User) {
Member guest = Member.createGuestMember(oAuth2User.getName());
Member guest = Member.createGuest(oAuth2User.getName());
return memberRepository.save(guest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class 쿠폰_생성할때 {
@Test
void 성공한다() {
// when
Coupon coupon = Coupon.createCoupon(COUPON_NAME, Money.from(ONE));
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));

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

// when & then
assertThatThrownBy(() -> Coupon.createCoupon(COUPON_NAME, discountAmount))
assertThatThrownBy(() -> Coupon.create(COUPON_NAME, discountAmount))
.isInstanceOf(CustomException.class)
.hasMessageContaining(COUPON_DISCOUNT_AMOUNT_NOT_POSITIVE.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class 발급쿠폰_사용할때 {
@Test
void 성공하면_사용여부는_true이다() {
// given
Coupon coupon = Coupon.createCoupon(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuestMember(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.issue(coupon, member);
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);

// when
issuedCoupon.use();
Expand All @@ -34,9 +34,9 @@ class 발급쿠폰_사용할때 {
@Test
void 이미_사용한_쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.createCoupon(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuestMember(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.issue(coupon, member);
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
issuedCoupon.use();

// when & then
Expand All @@ -48,9 +48,9 @@ class 발급쿠폰_사용할때 {
@Test
void 이미_회수한_쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.createCoupon(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuestMember(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.issue(coupon, member);
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
issuedCoupon.revoke();

// when & then
Expand All @@ -66,9 +66,9 @@ class 발급쿠폰_회수할때 {
@Test
void 성공하면_회수여부는_true이다() {
// given
Coupon coupon = Coupon.createCoupon(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuestMember(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.issue(coupon, member);
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);

// when
issuedCoupon.revoke();
Expand All @@ -80,9 +80,9 @@ class 발급쿠폰_회수할때 {
@Test
void 이미_회수한_발급쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.createCoupon(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuestMember(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.issue(coupon, member);
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
issuedCoupon.revoke();

// when & then
Expand All @@ -94,9 +94,9 @@ class 발급쿠폰_회수할때 {
@Test
void 이미_사용한_발급쿠폰이면_실패한다() {
// given
Coupon coupon = Coupon.createCoupon(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuestMember(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.issue(coupon, member);
Coupon coupon = Coupon.create(COUPON_NAME, Money.from(ONE));
Member member = Member.createGuest(OAUTH_ID);
IssuedCoupon issuedCoupon = IssuedCoupon.create(coupon, member);
issuedCoupon.use();

// when & then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AdminMemberServiceTest extends IntegrationTest {
@Test
void status가_DELETED라면_예외_발생() {
// given
Member member = Member.createGuestMember(OAUTH_ID);
Member member = Member.createGuest(OAUTH_ID);
member.withdraw();
memberRepository.save(member);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void setUp() {
@Test
void 기본정보_미작성시_멤버_기본정보는_모두_null이다() {
// given
memberRepository.save(Member.createGuestMember(OAUTH_ID));
memberRepository.save(Member.createGuest(OAUTH_ID));
logoutAndReloginAs(1L, MemberRole.ASSOCIATE);

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MemberRepositoryTest extends RepositoryTest {
private MemberRepository memberRepository;

private Member getMember() {
Member member = Member.createGuestMember(OAUTH_ID);
Member member = Member.createGuest(OAUTH_ID);
return memberRepository.save(member);
}

Expand Down
Loading

0 comments on commit 1f23e78

Please sign in to comment.