diff --git a/src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java b/src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java index 9f2409add..47226076d 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java @@ -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; @@ -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) { diff --git a/src/main/java/com/example/solidconnection/mentor/dto/MentoringConfirmRequest.java b/src/main/java/com/example/solidconnection/mentor/dto/MentoringConfirmRequest.java index ab3f1a8a8..cb284d4c6 100644 --- a/src/main/java/com/example/solidconnection/mentor/dto/MentoringConfirmRequest.java +++ b/src/main/java/com/example/solidconnection/mentor/dto/MentoringConfirmRequest.java @@ -5,9 +5,7 @@ public record MentoringConfirmRequest( @NotNull(message = "승인 상태를 설정해주세요.") - VerifyStatus status, - - String rejectedReason + VerifyStatus status ) { } diff --git a/src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java b/src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java index 165011f55..ca35f6c95 100644 --- a/src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java +++ b/src/main/java/com/example/solidconnection/mentor/service/MentoringCommandService.java @@ -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; @@ -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(); diff --git a/src/main/resources/db/migration/V23__drop_mentoring_reject_reason_column.sql b/src/main/resources/db/migration/V23__drop_mentoring_reject_reason_column.sql new file mode 100644 index 000000000..dde39c460 --- /dev/null +++ b/src/main/resources/db/migration/V23__drop_mentoring_reject_reason_column.sql @@ -0,0 +1,2 @@ +ALTER TABLE mentoring + DROP COLUMN rejected_reason; diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java index 0315777ab..07925628e 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java @@ -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) .confirmedAt(now) .checkedAt(now) .create(); diff --git a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixtureBuilder.java b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixtureBuilder.java index 9400a0a0f..857c18ea8 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixtureBuilder.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixtureBuilder.java @@ -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; @@ -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; @@ -67,7 +61,6 @@ public Mentoring create() { confirmedAt, checkedAt, verifyStatus, - rejectedReason, mentorId, menteeId ); diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java index fb8fbd608..a7cea53bb 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringCommandServiceTest.java @@ -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; @@ -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 @@ -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 @@ -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)) @@ -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)) @@ -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 diff --git a/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java b/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java index 5951920ff..6e61a4a7a 100644 --- a/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java @@ -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());