From bc271c3cb2fc7a9a1a7da0e50b15c24027b77edf Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Wed, 23 Jul 2025 11:34:57 +0900 Subject: [PATCH 1/4] =?UTF-8?q?refactor:=20=EA=B1=B0=EC=A0=88=20=EC=82=AC?= =?UTF-8?q?=EC=9C=A0=20=EC=9E=85=EB=A0=A5=20=EA=B8=B0=EB=8A=A5=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/solidconnection/mentor/domain/Mentoring.java | 3 +-- .../mentor/dto/MentoringConfirmRequest.java | 4 +--- .../mentor/service/MentoringCommandService.java | 8 +------- 3 files changed, 3 insertions(+), 12 deletions(-) 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..cc641363b 100644 --- a/src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java +++ b/src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java @@ -66,9 +66,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(); From e796fc7d1c7ee040a611cfeb7923bc0274a56128 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Wed, 23 Jul 2025 11:42:31 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor:=20=EA=B1=B0=EC=A0=88=20=EC=82=AC?= =?UTF-8?q?=EC=9C=A0=20=EC=BB=AC=EB=9F=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/solidconnection/mentor/domain/Mentoring.java | 3 --- .../db/migration/V23__drop_mentoring_reject_reason_column.sql | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/db/migration/V23__drop_mentoring_reject_reason_column.sql 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 cc641363b..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; 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; From d4cd824a79de9995af5f22933b85e2e4bd005b31 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Wed, 23 Jul 2025 11:42:57 +0900 Subject: [PATCH 3/4] =?UTF-8?q?test:=20=EA=B1=B0=EC=A0=88=EC=82=AC?= =?UTF-8?q?=EC=9C=A0=20=EC=9E=85=EB=A0=A5=20=EA=B8=B0=EB=8A=A5=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EC=97=90=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mentor/fixture/MentoringFixture.java | 1 - .../fixture/MentoringFixtureBuilder.java | 7 ----- .../service/MentoringCommandServiceTest.java | 26 ++++--------------- 3 files changed, 5 insertions(+), 29 deletions(-) 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..983ea9321 100644 --- a/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java +++ b/src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixture.java @@ -39,7 +39,6 @@ public class MentoringFixture { .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 From 90d3e8723f14ce944d2d051280bc0b46830363e3 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 24 Jul 2025 01:30:26 +0900 Subject: [PATCH 4/4] =?UTF-8?q?refactor:=20fixture=20=EC=9D=B8=EC=9E=90?= =?UTF-8?q?=EC=97=90=EC=84=9C=20rejectedReason=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/mentor/fixture/MentoringFixture.java | 2 +- .../mentor/service/MentoringQueryServiceTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 983ea9321..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,7 +33,7 @@ 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) 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());