Skip to content
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 @@ -46,9 +46,6 @@ public class Mentoring {
@Enumerated(EnumType.STRING)
private VerifyStatus verifyStatus = VerifyStatus.PENDING;

@Column(length = 500)
private String rejectedReason;

@Column
private long mentorId;

Expand All @@ -66,9 +63,8 @@ public void onPrePersist() {
this.createdAt = ZonedDateTime.now(UTC).truncatedTo(MICROS); // 나노초 6자리 까지만 저장
}

public void confirm(VerifyStatus status, String rejectedReason) {
public void confirm(VerifyStatus status) {
this.verifyStatus = status;
this.rejectedReason = rejectedReason;
this.confirmedAt = ZonedDateTime.now(UTC).truncatedTo(MICROS);

if (this.checkedAt == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

public record MentoringConfirmRequest(
@NotNull(message = "승인 상태를 설정해주세요.")
VerifyStatus status,

String rejectedReason
VerifyStatus status
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static com.example.solidconnection.common.exception.ErrorCode.MENTORING_ALREADY_CONFIRMED;
import static com.example.solidconnection.common.exception.ErrorCode.MENTORING_NOT_FOUND;
import static com.example.solidconnection.common.exception.ErrorCode.MENTOR_NOT_FOUND;
import static com.example.solidconnection.common.exception.ErrorCode.REJECTED_REASON_REQUIRED;
import static com.example.solidconnection.common.exception.ErrorCode.UNAUTHORIZED_MENTORING;

import com.example.solidconnection.common.VerifyStatus;
Expand Down Expand Up @@ -46,12 +45,7 @@ public MentoringConfirmResponse confirmMentoring(long siteUserId, long mentoring
validateMentoringOwnership(mentor, mentoring);
validateMentoringNotConfirmed(mentoring);

if (mentoringConfirmRequest.status() == VerifyStatus.REJECTED
&& (mentoringConfirmRequest.rejectedReason() == null || mentoringConfirmRequest.rejectedReason().isBlank())) {
throw new CustomException(REJECTED_REASON_REQUIRED);
}

mentoring.confirm(mentoringConfirmRequest.status(), mentoringConfirmRequest.rejectedReason());
mentoring.confirm(mentoringConfirmRequest.status());

if (mentoringConfirmRequest.status() == VerifyStatus.APPROVED) {
mentor.increaseMenteeCount();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE mentoring
DROP COLUMN rejected_reason;
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ public class MentoringFixture {
.create();
}

public Mentoring 거절된_멘토링(long mentorId, long menteeId, String rejectedReason) {
public Mentoring 거절된_멘토링(long mentorId, long menteeId) {
ZonedDateTime now = getCurrentTime();
return mentoringFixtureBuilder.mentoring()
.mentorId(mentorId)
.menteeId(menteeId)
.verifyStatus(VerifyStatus.REJECTED)
.rejectedReason(rejectedReason)
Copy link
Member

Choose a reason for hiding this comment

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

파라미터에 rejectedReason 도 제거해야 할 것 같습니다 !

Copy link
Collaborator Author

@nayonsoso nayonsoso Jul 23, 2025

Choose a reason for hiding this comment

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

반영했습니다~! 90d3e87

성혁님 진짜.. 어쩜 그렇게 꼼꼼하신가요😭👍👍

.confirmedAt(now)
.checkedAt(now)
.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class MentoringFixtureBuilder {
private ZonedDateTime confirmedAt;
private ZonedDateTime checkedAt;
private VerifyStatus verifyStatus = VerifyStatus.PENDING;
private String rejectedReason;
private long mentorId;
private long menteeId;

Expand Down Expand Up @@ -45,11 +44,6 @@ public MentoringFixtureBuilder verifyStatus(VerifyStatus verifyStatus) {
return this;
}

public MentoringFixtureBuilder rejectedReason(String rejectedReason) {
this.rejectedReason = rejectedReason;
return this;
}

public MentoringFixtureBuilder mentorId(long mentorId) {
this.mentorId = mentorId;
return this;
Expand All @@ -67,7 +61,6 @@ public Mentoring create() {
confirmedAt,
checkedAt,
verifyStatus,
rejectedReason,
mentorId,
menteeId
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.example.solidconnection.common.exception.ErrorCode.MENTORING_ALREADY_CONFIRMED;
import static com.example.solidconnection.common.exception.ErrorCode.MENTORING_NOT_FOUND;
import static com.example.solidconnection.common.exception.ErrorCode.REJECTED_REASON_REQUIRED;
import static com.example.solidconnection.common.exception.ErrorCode.UNAUTHORIZED_MENTORING;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -98,7 +97,7 @@ class 멘토링_승인_거절_테스트 {
void 멘토링을_성공적으로_승인한다() {
// given
Mentoring mentoring = mentoringFixture.대기중_멘토링(mentor1.getId(), menteeUser.getId());
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED, null);
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED);
int beforeMenteeCount = mentor1.getMenteeCount();

// when
Expand All @@ -120,8 +119,7 @@ class 멘토링_승인_거절_테스트 {
void 멘토링을_성공적으로_거절한다() {
// given
Mentoring mentoring = mentoringFixture.대기중_멘토링(mentor1.getId(), menteeUser.getId());
String rejectedReason = "멘토링 거절 사유";
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.REJECTED, rejectedReason);
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.REJECTED);
int beforeMenteeCount = mentor1.getMenteeCount();

// when
Expand All @@ -133,31 +131,17 @@ class 멘토링_승인_거절_테스트 {

assertAll(
() -> assertThat(confirmedMentoring.getVerifyStatus()).isEqualTo(VerifyStatus.REJECTED),
() -> assertThat(confirmedMentoring.getRejectedReason()).isEqualTo(rejectedReason),
() -> assertThat(confirmedMentoring.getConfirmedAt()).isNotNull(),
() -> assertThat(confirmedMentoring.getCheckedAt()).isNotNull(),
() -> assertThat(mentor.getMenteeCount()).isEqualTo(beforeMenteeCount)
);
}

@Test
void 거절_시_사유가_없으면_예외가_발생한다() {
// given
Mentoring mentoring = mentoringFixture.대기중_멘토링(mentor1.getId(), menteeUser.getId());
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.REJECTED, null);

// when & then
assertThatThrownBy(() ->
mentoringCommandService.confirmMentoring(mentorUser1.getId(), mentoring.getId(), request))
.isInstanceOf(CustomException.class)
.hasMessage(REJECTED_REASON_REQUIRED.getMessage());
}

@Test
void 다른_멘토의_멘토링을_승인할_수_없다() {
// given
Mentoring mentoring = mentoringFixture.대기중_멘토링(mentor1.getId(), menteeUser.getId());
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED, null);
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED);

// when & then
assertThatThrownBy(() -> mentoringCommandService.confirmMentoring(mentorUser2.getId(), mentoring.getId(), request))
Expand All @@ -169,7 +153,7 @@ class 멘토링_승인_거절_테스트 {
void 이미_처리된_멘토링은_다시_승인할_수_없다() {
// given
Mentoring mentoring = mentoringFixture.승인된_멘토링(mentor1.getId(), menteeUser.getId());
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED, null);
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED);

// when & then
assertThatThrownBy(() -> mentoringCommandService.confirmMentoring(mentorUser1.getId(), mentoring.getId(), request))
Expand All @@ -180,7 +164,7 @@ class 멘토링_승인_거절_테스트 {
@Test
void 존재하지_않는_멘토링_아이디로_요청시_예외가_발생한다() {
// given
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED, null);
MentoringConfirmRequest request = new MentoringConfirmRequest(VerifyStatus.APPROVED);
long invalidMentoringId = 9999L;

// when & then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class 멘토링_목록_조회_테스트 {
// given
Mentoring mentoring1 = mentoringFixture.대기중_멘토링(mentor.getId(), menteeUser.getId());
Mentoring mentoring2 = mentoringFixture.승인된_멘토링(mentor.getId(), menteeUser.getId());
Mentoring mentoring3 = mentoringFixture.거절된_멘토링(mentor.getId(), menteeUser.getId(), "거절 사유");
Mentoring mentoring3 = mentoringFixture.거절된_멘토링(mentor.getId(), menteeUser.getId());

// when
MentoringListResponse responses = mentoringQueryService.getMentorings(mentorUser.getId());
Expand Down
Loading