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

refactor: 테스트에서만 사용하는 메서드 제거 #770

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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);
}
}
}