Skip to content

Commit

Permalink
refactor: 테스트에서만 사용하는 메서드 제거 (#770)
Browse files Browse the repository at this point in the history
* refactor: 테스트에서만 사용하는 메서드 제거

* refactor: 검증 메서드 접근 레벨 변경
  • Loading branch information
Sangwook02 authored Sep 12, 2024
1 parent e9e4c62 commit 88f6840
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public void verifyPaymentStatus(String orderNanoId) {
findMembershipAndVerifyPayment(membershipId);
}

@Transactional
public void verifyPaymentStatus(Long membershipId) {
findMembershipAndVerifyPayment(membershipId);
}

private void findMembershipAndVerifyPayment(Long membershipId) {
Membership currentMembership = membershipRepository
.findById(membershipId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static Membership createMembership(Member member, RecruitmentRound recrui

// 검증 로직

public void validateRegularRequirement() {
private void validateRegularRequirement() {
if (isRegularRequirementAllSatisfied()) {
throw new CustomException(MEMBERSHIP_ALREADY_SATISFIED);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.gdschongik.gdsc.domain.membership.application;

import static com.gdschongik.gdsc.domain.common.model.RequirementStatus.SATISFIED;
import static com.gdschongik.gdsc.domain.member.domain.MemberRole.ASSOCIATE;
import static com.gdschongik.gdsc.global.common.constant.RecruitmentConstant.*;
import static com.gdschongik.gdsc.global.exception.ErrorCode.*;
import static org.assertj.core.api.Assertions.*;

import com.gdschongik.gdsc.domain.common.vo.Money;
import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.membership.dao.MembershipRepository;
import com.gdschongik.gdsc.domain.membership.domain.Membership;
import com.gdschongik.gdsc.domain.recruitment.domain.RecruitmentRound;
import com.gdschongik.gdsc.domain.recruitment.domain.RoundType;
import com.gdschongik.gdsc.global.exception.CustomException;
Expand All @@ -24,9 +20,6 @@ public class MembershipServiceTest extends IntegrationTest {
@Autowired
private MembershipService membershipService;

@Autowired
private MembershipRepository membershipRepository;

@Nested
class 멤버십_가입신청시 {
@Test
Expand Down Expand Up @@ -73,38 +66,4 @@ class 멤버십_가입신청시 {
.doesNotThrowAnyException();
}
}

@Test
void 멤버십_회비납부시_이미_회비납부_했다면_회비납부_실패한다() {
// given
Member member = createMember();
logoutAndReloginAs(1L, ASSOCIATE);
RecruitmentRound recruitmentRound = createRecruitmentRound();
Membership membership = createMembership(member, recruitmentRound);
membershipService.verifyPaymentStatus(membership.getId());

// when & then
assertThatThrownBy(() -> membershipService.verifyPaymentStatus(membership.getId()))
.isInstanceOf(CustomException.class)
.hasMessage(MEMBERSHIP_ALREADY_SATISFIED.getMessage());
}

@Nested
class 정회원_가입조건_인증시도시 {
@Test
void 멤버십_회비납부시_정회원_가입조건중_회비납부_인증상태가_인증_성공한다() {
// given
Member member = createMember();
logoutAndReloginAs(1L, ASSOCIATE);
RecruitmentRound recruitmentRound = createRecruitmentRound();
Membership membership = createMembership(member, recruitmentRound);

// when
membershipService.verifyPaymentStatus(membership.getId());
membership = membershipRepository.findById(membership.getId()).get();

// then
assertThat(membership.getRegularRequirement().getPaymentStatus()).isEqualTo(SATISFIED);
}
}
}

0 comments on commit 88f6840

Please sign in to comment.