From 9c3193a921faaff9746c9c8b156762b83a9315cf Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 02:03:38 +0900 Subject: [PATCH 01/14] =?UTF-8?q?feat:=20=EB=9F=AC=EB=84=88=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80=EC=9D=98=20=EC=84=9C=ED=8F=AC=ED=84=B0=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=EB=B0=B1=20=EC=9C=A0=EB=AC=B4=20=ED=95=84?= =?UTF-8?q?=EB=93=9C(=EC=BB=AC=EB=9F=BC)=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baton/domain/runnerpost/RunnerPost.java | 25 +++++++++++--- .../domain/runnerpost/vo/IsReviewed.java | 33 +++++++++++++++++++ .../domain/runnerpost/vo/IsReviewedTest.java | 21 ++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java create mode 100644 backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/RunnerPost.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/RunnerPost.java index 2e8f78657..19d269e72 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/RunnerPost.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/RunnerPost.java @@ -21,6 +21,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -37,7 +38,10 @@ import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.GenerationType.IDENTITY; import static lombok.AccessLevel.PROTECTED; -import static touch.baton.domain.runnerpost.vo.ReviewStatus.*; +import static touch.baton.domain.runnerpost.vo.ReviewStatus.DONE; +import static touch.baton.domain.runnerpost.vo.ReviewStatus.IN_PROGRESS; +import static touch.baton.domain.runnerpost.vo.ReviewStatus.NOT_STARTED; +import static touch.baton.domain.runnerpost.vo.ReviewStatus.OVERDUE; @Getter @NoArgsConstructor(access = PROTECTED) @@ -73,6 +77,9 @@ public class RunnerPost extends BaseEntity { @Column(nullable = false) private ReviewStatus reviewStatus = ReviewStatus.NOT_STARTED; + @Embedded + private IsReviewed isReviewed; + @ManyToOne(fetch = LAZY) @JoinColumn(name = "runner_id", foreignKey = @ForeignKey(name = "fk_runner_post_to_runner"), nullable = false) private Runner runner; @@ -93,11 +100,12 @@ private RunnerPost(final Title title, final Deadline deadline, final WatchedCount watchedCount, final ReviewStatus reviewStatus, + final IsReviewed isReviewed, final Runner runner, final Supporter supporter, final RunnerPostTags runnerPostTags ) { - this(null, title, implementedContents, curiousContents, postscriptContents, pullRequestUrl, deadline, watchedCount, reviewStatus, runner, supporter, runnerPostTags); + this(null, title, implementedContents, curiousContents, postscriptContents, pullRequestUrl, deadline, watchedCount, reviewStatus, isReviewed, runner, supporter, runnerPostTags); } private RunnerPost(final Long id, @@ -109,11 +117,12 @@ private RunnerPost(final Long id, final Deadline deadline, final WatchedCount watchedCount, final ReviewStatus reviewStatus, + final IsReviewed isReviewed, final Runner runner, final Supporter supporter, final RunnerPostTags runnerPostTags ) { - validateNotNull(title, implementedContents, curiousContents, postscriptContents, pullRequestUrl, deadline, watchedCount, reviewStatus, runner, runnerPostTags); + validateNotNull(title, implementedContents, curiousContents, postscriptContents, pullRequestUrl, deadline, watchedCount, reviewStatus, isReviewed, runner, runnerPostTags); this.id = id; this.title = title; this.implementedContents = implementedContents; @@ -123,6 +132,7 @@ private RunnerPost(final Long id, this.deadline = deadline; this.watchedCount = watchedCount; this.reviewStatus = reviewStatus; + this.isReviewed = isReviewed; this.runner = runner; this.supporter = supporter; this.runnerPostTags = runnerPostTags; @@ -143,10 +153,11 @@ public static RunnerPost newInstance(final String title, .postscriptContents(new PostscriptContents(postscriptContents)) .pullRequestUrl(new PullRequestUrl(pullRequestUrl)) .deadline(new Deadline(deadline)) - .runner(runner) - .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .watchedCount(WatchedCount.zero()) .reviewStatus(NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) + .runner(runner) + .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .build(); } @@ -158,6 +169,7 @@ private void validateNotNull(final Title title, final Deadline deadline, final WatchedCount watchedCount, final ReviewStatus reviewStatus, + final IsReviewed isReviewed, final Runner runner, final RunnerPostTags runnerPostTags ) { @@ -185,6 +197,9 @@ private void validateNotNull(final Title title, if (Objects.isNull(reviewStatus)) { throw new RunnerPostDomainException("RunnerPost 의 reviewStatus 는 null 일 수 없습니다."); } + if (Objects.isNull(isReviewed)) { + throw new RunnerPostDomainException("RunnerPost 의 isReviewed 는 null 일 수 없습니다."); + } if (Objects.isNull(runner)) { throw new RunnerPostDomainException("RunnerPost 의 runner 는 null 일 수 없습니다."); } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java new file mode 100644 index 000000000..3da02de05 --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java @@ -0,0 +1,33 @@ +package touch.baton.domain.runnerpost.vo; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.ColumnDefault; + +import static lombok.AccessLevel.PROTECTED; + +@EqualsAndHashCode +@Getter +@NoArgsConstructor(access = PROTECTED) +@Embeddable +public class IsReviewed { + + @ColumnDefault(value = "false") + @Column(name = "is_reviewed", nullable = false) + private boolean value = false; + + private IsReviewed(final boolean value) { + this.value = value; + } + + public static IsReviewed notReviewed() { + return new IsReviewed(false); + } + + public static IsReviewed reviewed() { + return new IsReviewed(true); + } +} diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java new file mode 100644 index 000000000..0825593ae --- /dev/null +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java @@ -0,0 +1,21 @@ +package touch.baton.domain.runnerpost.vo; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class IsReviewedTest { + + @DisplayName("기본 생성의 default 값은 false 이다.") + @Test + void default_is_false() { + // given + final IsReviewed isReviewed = new IsReviewed(); + + // expect + final boolean actual = isReviewed.isValue(); + + assertThat(actual).isFalse(); + } +} From f12e8e91f0b7ad8bc368fb34b2f5783b5b793e8f Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 02:04:33 +0900 Subject: [PATCH 02/14] =?UTF-8?q?test:=20=EB=9F=AC=EB=84=88=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80=EC=97=90=20=EC=84=9C=ED=8F=AC=ED=84=B0=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=EB=B0=B1=20=EC=9C=A0=EB=AC=B4=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=EC=B6=94=EA=B0=80=20=ED=9B=84=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnerpost/RunnerPostAssuredSupport.java | 3 +- .../ScheduleRunnerPostRepositoryTest.java | 13 +++-- .../read/RunnerPostReadAllApiTest.java | 4 +- .../domain/runnerpost/RunnerPostTest.java | 42 +++++++++++++- .../RunnerPostRepositoryDeleteTest.java | 2 + .../RunnerPostRepositoryReadTest.java | 2 + .../read/RunnerPostRepositoryReadTest.java | 3 + .../service/RunnerPostServiceReadTest.java | 2 + .../service/RunnerPostServiceUpdateTest.java | 16 ++++-- ...UpdateApplicantCancelationServiceTest.java | 5 +- .../supporter/SupporterFeedbackTest.java | 2 + .../baton/domain/tag/RunnerPostTagTest.java | 2 + .../RunnerPostTagRepositoryTest.java | 3 + .../fixture/domain/RunnerPostFixture.java | 56 ++++++++----------- 14 files changed, 105 insertions(+), 50 deletions(-) diff --git a/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java b/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java index ffdf3227d..00c9fae0f 100644 --- a/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java +++ b/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java @@ -147,7 +147,8 @@ private RunnerPostAssuredSupport() { 러너_게시글_태그_목록, 조회수, 지원한_서포터_수, - 리뷰_상태.name() + 리뷰_상태.name(), + 러너_게시글.getIsReviewed().isValue() ); } diff --git a/backend/baton/src/test/java/touch/baton/common/schedule/ScheduleRunnerPostRepositoryTest.java b/backend/baton/src/test/java/touch/baton/common/schedule/ScheduleRunnerPostRepositoryTest.java index 130730e44..912f5f77d 100644 --- a/backend/baton/src/test/java/touch/baton/common/schedule/ScheduleRunnerPostRepositoryTest.java +++ b/backend/baton/src/test/java/touch/baton/common/schedule/ScheduleRunnerPostRepositoryTest.java @@ -10,6 +10,7 @@ import touch.baton.domain.runner.Runner; import touch.baton.domain.runnerpost.RunnerPost; import touch.baton.domain.runnerpost.vo.Deadline; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.ReviewStatus; import touch.baton.fixture.domain.MemberFixture; import touch.baton.fixture.domain.RunnerFixture; @@ -19,7 +20,9 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static touch.baton.domain.runnerpost.vo.ReviewStatus.*; +import static touch.baton.domain.runnerpost.vo.ReviewStatus.DONE; +import static touch.baton.domain.runnerpost.vo.ReviewStatus.NOT_STARTED; +import static touch.baton.domain.runnerpost.vo.ReviewStatus.OVERDUE; import static touch.baton.fixture.vo.DeadlineFixture.deadline; class ScheduleRunnerPostRepositoryTest extends RepositoryTestConfig { @@ -68,8 +71,8 @@ void updateAllPassedDeadline_fail_when_reviewStatus_is_DONE() { final Deadline passedDeadlineOne = deadline(LocalDateTime.now().minusHours(10)); final Deadline passedDeadlineTwo = deadline(LocalDateTime.now().minusHours(5)); final ReviewStatus expectedReviewStatus = DONE; - final RunnerPost runnerPostOne = RunnerPostFixture.create(runner, passedDeadlineOne, expectedReviewStatus); - final RunnerPost runnerPostTwo = RunnerPostFixture.create(runner, passedDeadlineTwo, expectedReviewStatus); + final RunnerPost runnerPostOne = RunnerPostFixture.create(runner, passedDeadlineOne, expectedReviewStatus, IsReviewed.notReviewed()); + final RunnerPost runnerPostTwo = RunnerPostFixture.create(runner, passedDeadlineTwo, expectedReviewStatus, IsReviewed.notReviewed()); em.persist(runnerPostOne); em.persist(runnerPostTwo); @@ -90,8 +93,8 @@ void updateAllPassedDeadline_fail_when_deadline_is_not_passed() { final Deadline passedDeadlineOne = deadline(LocalDateTime.now().plusHours(10)); final Deadline passedDeadlineTwo = deadline(LocalDateTime.now().plusHours(5)); final ReviewStatus expectedReviewStatus = NOT_STARTED; - final RunnerPost runnerPostOne = RunnerPostFixture.create(runner, passedDeadlineOne, expectedReviewStatus); - final RunnerPost runnerPostTwo = RunnerPostFixture.create(runner, passedDeadlineTwo, expectedReviewStatus); + final RunnerPost runnerPostOne = RunnerPostFixture.create(runner, passedDeadlineOne, expectedReviewStatus, IsReviewed.notReviewed()); + final RunnerPost runnerPostTwo = RunnerPostFixture.create(runner, passedDeadlineTwo, expectedReviewStatus, IsReviewed.notReviewed()); em.persist(runnerPostOne); em.persist(runnerPostTwo); diff --git a/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadAllApiTest.java b/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadAllApiTest.java index 88abac463..83897c640 100644 --- a/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadAllApiTest.java +++ b/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadAllApiTest.java @@ -14,10 +14,7 @@ import touch.baton.domain.runnerpost.service.RunnerPostService; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ReviewStatus; -import touch.baton.domain.tag.RunnerPostTag; import touch.baton.domain.tag.Tag; -import touch.baton.domain.tag.repository.TagRepository; -import touch.baton.domain.tag.service.TagService; import touch.baton.fixture.domain.MemberFixture; import touch.baton.fixture.domain.RunnerFixture; import touch.baton.fixture.domain.RunnerPostFixture; @@ -172,6 +169,7 @@ void readRunnerMyPage() throws Exception { fieldWithPath("data.[].watchedCount").type(NUMBER).description("러너 게시글의 조회수"), fieldWithPath("data.[].applicantCount").type(NUMBER).description("러너 게시글에 신청한 서포터 수"), fieldWithPath("data.[].reviewStatus").type(STRING).description("러너 게시글 리뷰 상태"), + fieldWithPath("data.[].isReviewed").type(BOOLEAN).description("러너 게시글을 리뷰해준 서포터에 대한 피드백 유무"), fieldWithPath("pageInfo.isFirst").type(BOOLEAN).description("첫 번째 페이지인지"), fieldWithPath("pageInfo.isLast").type(BOOLEAN).description("마지막 페이지 인지"), fieldWithPath("pageInfo.hasNext").type(BOOLEAN).description("다음 페이지가 있는지"), diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java index 14b4b3630..b49968c4b 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/RunnerPostTest.java @@ -20,6 +20,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -97,7 +98,7 @@ void addAllRunnerPostTags() { // when runnerPost.addAllRunnerPostTags(List.of(java, spring)); - List runnerPostTags = runnerPost.getRunnerPostTags().getRunnerPostTags(); + List runnerPostTags = runnerPost.getRunnerPostTags().getRunnerPostTags(); final List actualTagNames = runnerPostTags.stream() .map(runnerPostTag -> runnerPostTag.getTag().getTagName().getValue()) .collect(Collectors.toList()); @@ -125,6 +126,7 @@ void success() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -144,6 +146,7 @@ void success_if_supporter_is_null() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(null) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -163,6 +166,7 @@ void fail_if_title_is_null() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -183,6 +187,7 @@ void fail_if_contents_is_null() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -203,6 +208,7 @@ void fail_if_pullRequestUrl_is_null() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -223,6 +229,7 @@ void fail_if_deadline_is_null() { .deadline(null) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -243,6 +250,7 @@ void fail_if_watchedCount_is_null() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(null) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -251,6 +259,27 @@ void fail_if_watchedCount_is_null() { .hasMessage("RunnerPost 의 watchedCount 는 null 일 수 없습니다."); } + @DisplayName("is reviewed 에 null 이 들어갈 경우 예외가 발생한다.") + @Test + void fail_if_isReviewed_is_null() { + assertThatThrownBy(() -> RunnerPost.builder() + .title(new Title("아이")) + .implementedContents(new ImplementedContents("김영한 짱짱맨")) + .curiousContents(new CuriousContents("궁금한 점입니다.")) + .postscriptContents(new PostscriptContents("잘 부탁드립니다.")) + .pullRequestUrl(new PullRequestUrl("https://github.com/woowacourse-teams/2023-baton/pull/17")) + .deadline(new Deadline(LocalDateTime.now())) + .watchedCount(new WatchedCount(0)) + .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(null) + .runner(runner) + .supporter(supporter) + .runnerPostTags(new RunnerPostTags(new ArrayList<>())) + .build() + ).isInstanceOf(RunnerPostDomainException.class) + .hasMessage("RunnerPost 의 isReviewed 는 null 일 수 없습니다."); + } + @DisplayName("runner 에 null 이 들어갈 경우 예외가 발생한다.") @Test void fail_if_runner_is_null() { @@ -263,6 +292,7 @@ void fail_if_runner_is_null() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(null) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -283,6 +313,7 @@ void fail_if_runnerPostTags_is_null() { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(null) @@ -334,6 +365,7 @@ void success_supporter_is_null_and_deadline_is_not_end() { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(null) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -357,6 +389,7 @@ void fail_supporter_is_not_null() { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -380,6 +413,7 @@ void fail_deadline_is_already_end() { .deadline(new Deadline(LocalDateTime.now().minusDays(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -413,6 +447,7 @@ void success_IN_PROGRESS__to_DONE() { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.IN_PROGRESS) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -438,6 +473,7 @@ void fail_NOT_STARTED__to_IN_PROGRESS() { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -461,6 +497,7 @@ void fail_NOT_STARTED__to_DONE() { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.DONE) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -484,6 +521,7 @@ void fail_DONE_to_NOT_STARTED() { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.DONE) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -507,6 +545,7 @@ void fail_DONE_to_IN_PROGRESS() { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.DONE) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -531,6 +570,7 @@ void fail_same_to_same(final ReviewStatus reviewStatus) { .deadline(new Deadline(LocalDateTime.now().plusHours(100))) .watchedCount(new WatchedCount(0)) .reviewStatus(reviewStatus) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryDeleteTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryDeleteTest.java index afb5a5a96..7c953fefa 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryDeleteTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryDeleteTest.java @@ -20,6 +20,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -73,6 +74,7 @@ void success_deleteByRunnerPostId() { .watchedCount(new WatchedCount(1)) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(saveRunner) .supporter(null) .build(); diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryReadTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryReadTest.java index b22b9ade6..602ded7f1 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryReadTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostRepositoryReadTest.java @@ -20,6 +20,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -74,6 +75,7 @@ void success_deleteByRunnerPostId() { .watchedCount(new WatchedCount(1)) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(saveRunner) .supporter(null) .build(); diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java index 7a47de727..84cf953be 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java @@ -14,6 +14,7 @@ import touch.baton.domain.runner.repository.RunnerRepository; import touch.baton.domain.runnerpost.RunnerPost; import touch.baton.domain.runnerpost.repository.RunnerPostRepository; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.tag.RunnerPostTag; import touch.baton.domain.tag.Tag; import touch.baton.domain.tag.repository.RunnerPostTagRepository; @@ -78,6 +79,7 @@ void findRunnerPostTagsById_exist() { deadline(LocalDateTime.now().plusHours(10)), watchedCount(0), NOT_STARTED, + IsReviewed.notReviewed(), runner, null, runnerPostTags(new ArrayList<>())); @@ -116,6 +118,7 @@ void findByRunnerId() { deadline(LocalDateTime.now().plusHours(10)), watchedCount(0), NOT_STARTED, + IsReviewed.notReviewed(), runner, null, runnerPostTags(new ArrayList<>())); diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceReadTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceReadTest.java index e9c61c466..570f37f6d 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceReadTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceReadTest.java @@ -22,6 +22,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -96,6 +97,7 @@ void success_findByRunnerPostId() { .watchedCount(new WatchedCount(0)) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .reviewStatus(NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(null) .build(); diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java index 736cf0f53..76ec6e56f 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostServiceUpdateTest.java @@ -10,6 +10,7 @@ import touch.baton.domain.runnerpost.exception.RunnerPostBusinessException; import touch.baton.domain.runnerpost.exception.RunnerPostDomainException; import touch.baton.domain.runnerpost.service.dto.RunnerPostUpdateRequest; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.ReviewStatus; import touch.baton.domain.supporter.Supporter; import touch.baton.fixture.domain.MemberFixture; @@ -140,7 +141,8 @@ void fail_updateRunnerPostAppliedSupporter_if_is_not_owner_of_runnerPost() { @Test void updateRunnerPostReviewStatusDone() { // given - final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, IN_PROGRESS)); + final IsReviewed isReviewed = IsReviewed.notReviewed(); + final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, IN_PROGRESS, isReviewed)); // when runnerPostService.updateRunnerPostReviewStatusDone(targetRunnerPost.getId(), assignedSupporter); @@ -156,7 +158,8 @@ void updateRunnerPostReviewStatusDone() { @Test void fail_updateRunnerPostReviewStatusDone_if_invalid_runnerPostId() { // given - runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, IN_PROGRESS)); + final IsReviewed isReviewed = IsReviewed.notReviewed(); + runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, IN_PROGRESS, isReviewed)); final Long unsavedRunnerPostId = 100000L; // when, then @@ -168,7 +171,8 @@ void fail_updateRunnerPostReviewStatusDone_if_invalid_runnerPostId() { @Test void fail_updateRunnerPostReviewStatusDone_if_supporter_is_null() { // given - final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, null, IN_PROGRESS)); + final IsReviewed isReviewed = IsReviewed.notReviewed(); + final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, null, IN_PROGRESS, isReviewed)); // when, then assertThatThrownBy(() -> runnerPostService.updateRunnerPostReviewStatusDone(targetRunnerPost.getId(), assignedSupporter)) @@ -179,7 +183,8 @@ void fail_updateRunnerPostReviewStatusDone_if_supporter_is_null() { @Test void fail_updateRunnerPostReviewStatusDone_if_different_supporter_is_assigned() { // given - final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, IN_PROGRESS)); + final IsReviewed isReviewed = IsReviewed.notReviewed(); + final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, IN_PROGRESS, isReviewed)); final Member differentMember = memberRepository.save(MemberFixture.createHyena()); final Supporter differentSupporter = supporterRepository.save(SupporterFixture.create(differentMember)); @@ -192,7 +197,8 @@ void fail_updateRunnerPostReviewStatusDone_if_different_supporter_is_assigned() @Test void fail_updateRunnerPostReviewStatusDone_if_reviewStatus_is_overdue() { // given - final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, OVERDUE)); + final IsReviewed isReviewed = IsReviewed.notReviewed(); + final RunnerPost targetRunnerPost = runnerPostRepository.save(RunnerPostFixture.createWithReviewStatus(runner, assignedSupporter, OVERDUE, isReviewed)); // when, then assertThatThrownBy(() -> runnerPostService.updateRunnerPostReviewStatusDone(targetRunnerPost.getId(), assignedSupporter)) diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostUpdateApplicantCancelationServiceTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostUpdateApplicantCancelationServiceTest.java index d0670f24b..ee3afe856 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostUpdateApplicantCancelationServiceTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostUpdateApplicantCancelationServiceTest.java @@ -9,6 +9,7 @@ import touch.baton.domain.runnerpost.RunnerPost; import touch.baton.domain.runnerpost.exception.RunnerPostBusinessException; import touch.baton.domain.runnerpost.vo.Deadline; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.ReviewStatus; import touch.baton.domain.supporter.Supporter; import touch.baton.domain.supporter.SupporterRunnerPost; @@ -84,12 +85,14 @@ void fail_when_runnerPost_not_found() { @Test void fail_when_runnerPost_reviewStatus_is_not_NOT_STARTED() { // given + final IsReviewed isReviewed = IsReviewed.notReviewed(); final RunnerPost runnerPost = runnerPostRepository.save( RunnerPostFixture.create( revieweeRunner, applicantSupporter, new Deadline(LocalDateTime.now().plusHours(100)), - ReviewStatus.IN_PROGRESS + ReviewStatus.IN_PROGRESS, + isReviewed )); final SupporterRunnerPost supporterRunnerPost = SupporterRunnerPostFixture.create(runnerPost, applicantSupporter); supporterRunnerPostRepository.save(supporterRunnerPost); diff --git a/backend/baton/src/test/java/touch/baton/domain/supporter/SupporterFeedbackTest.java b/backend/baton/src/test/java/touch/baton/domain/supporter/SupporterFeedbackTest.java index b87b42ede..0e71329ef 100644 --- a/backend/baton/src/test/java/touch/baton/domain/supporter/SupporterFeedbackTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/supporter/SupporterFeedbackTest.java @@ -9,6 +9,7 @@ import touch.baton.domain.feedback.vo.ReviewType; import touch.baton.domain.runner.Runner; import touch.baton.domain.runnerpost.RunnerPost; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.supporter.vo.ReviewCount; import touch.baton.fixture.domain.MemberFixture; import touch.baton.fixture.domain.RunnerFixture; @@ -57,6 +58,7 @@ void setUp() { deadline(LocalDateTime.now().plusHours(10)), watchedCount(0), NOT_STARTED, + IsReviewed.notReviewed(), runner, supporter, RunnerPostTagsFixture.runnerPostTags(new ArrayList<>())); diff --git a/backend/baton/src/test/java/touch/baton/domain/tag/RunnerPostTagTest.java b/backend/baton/src/test/java/touch/baton/domain/tag/RunnerPostTagTest.java index ba0f50528..95eb857b2 100644 --- a/backend/baton/src/test/java/touch/baton/domain/tag/RunnerPostTagTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/tag/RunnerPostTagTest.java @@ -17,6 +17,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -76,6 +77,7 @@ class Create { .deadline(new Deadline(LocalDateTime.now())) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(supporter) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) diff --git a/backend/baton/src/test/java/touch/baton/domain/tag/repository/RunnerPostTagRepositoryTest.java b/backend/baton/src/test/java/touch/baton/domain/tag/repository/RunnerPostTagRepositoryTest.java index 9fa7784ac..a99ecb85c 100644 --- a/backend/baton/src/test/java/touch/baton/domain/tag/repository/RunnerPostTagRepositoryTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/tag/repository/RunnerPostTagRepositoryTest.java @@ -22,6 +22,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -85,6 +86,7 @@ void success_joinTagByRunnerPostIds() { .watchedCount(new WatchedCount(1)) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(saveRunner) .supporter(null) .build(); @@ -142,6 +144,7 @@ void success_joinTagByRunnerPostIds_if_tag_is_empty() { .watchedCount(new WatchedCount(1)) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(saveRunner) .supporter(null) .build(); diff --git a/backend/baton/src/test/java/touch/baton/fixture/domain/RunnerPostFixture.java b/backend/baton/src/test/java/touch/baton/fixture/domain/RunnerPostFixture.java index 8450582be..bae8fc7c1 100644 --- a/backend/baton/src/test/java/touch/baton/fixture/domain/RunnerPostFixture.java +++ b/backend/baton/src/test/java/touch/baton/fixture/domain/RunnerPostFixture.java @@ -7,6 +7,7 @@ import touch.baton.domain.runnerpost.vo.CuriousContents; import touch.baton.domain.runnerpost.vo.Deadline; import touch.baton.domain.runnerpost.vo.ImplementedContents; +import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.runnerpost.vo.PostscriptContents; import touch.baton.domain.runnerpost.vo.PullRequestUrl; import touch.baton.domain.runnerpost.vo.ReviewStatus; @@ -33,6 +34,7 @@ public static RunnerPost create(final Title title, final Deadline deadline, final WatchedCount watchedCount, final ReviewStatus reviewStatus, + final IsReviewed isReviewed, final Runner runner, final Supporter supporter, final RunnerPostTags runnerPostTags @@ -46,6 +48,7 @@ public static RunnerPost create(final Title title, .deadline(deadline) .watchedCount(watchedCount) .reviewStatus(reviewStatus) + .isReviewed(isReviewed) .runner(runner) .supporter(supporter) .runnerPostTags(runnerPostTags) @@ -62,13 +65,18 @@ public static RunnerPost create(final Runner runner, final Deadline deadline) { .deadline(deadline) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(null) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .build(); } - public static RunnerPost create(final Runner runner, final Deadline deadline, final ReviewStatus reviewStatus) { + public static RunnerPost create(final Runner runner, + final Deadline deadline, + final ReviewStatus reviewStatus, + final IsReviewed isReviewed + ) { return RunnerPost.builder() .title(new Title("테스트 제목")) .implementedContents(new ImplementedContents("테스트 내용")) @@ -78,6 +86,7 @@ public static RunnerPost create(final Runner runner, final Deadline deadline, fi .deadline(deadline) .watchedCount(new WatchedCount(0)) .reviewStatus(reviewStatus) + .isReviewed(isReviewed) .runner(runner) .supporter(null) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -94,6 +103,7 @@ public static RunnerPost create(final Runner runner, final Deadline deadline, Li .deadline(deadline) .watchedCount(new WatchedCount(0)) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runner(runner) .supporter(null) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) @@ -108,22 +118,6 @@ public static RunnerPost create(final Runner runner, final Deadline deadline, Li return runnerPost; } - - public static RunnerPost create(final Runner runner, final RunnerPostTags runnerPostTags, final Deadline deadline) { - return RunnerPost.builder() - .title(new Title("테스트 제목")) - .implementedContents(new ImplementedContents("테스트 내용")) - .curiousContents(new CuriousContents("테스트 궁금 점")) - .postscriptContents(new PostscriptContents("테스트 참고 사항")) - .pullRequestUrl(new PullRequestUrl("https://테스트")) - .deadline(deadline) - .watchedCount(new WatchedCount(0)) - .runner(runner) - .supporter(null) - .runnerPostTags(runnerPostTags) - .build(); - } - public static RunnerPost create(final Runner runner, final Supporter supporter) { return RunnerPost.builder() .title(new Title("테스트 제목")) @@ -136,11 +130,16 @@ public static RunnerPost create(final Runner runner, final Supporter supporter) .runner(runner) .supporter(supporter) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .build(); } - public static RunnerPost createWithReviewStatus(final Runner runner, final Supporter supporter, final ReviewStatus reviewStatus) { + public static RunnerPost createWithReviewStatus(final Runner runner, + final Supporter supporter, + final ReviewStatus reviewStatus, + final IsReviewed isReviewed + ) { return RunnerPost.builder() .title(new Title("테스트 제목")) .implementedContents(new ImplementedContents("테스트 내용")) @@ -152,6 +151,7 @@ public static RunnerPost createWithReviewStatus(final Runner runner, final Suppo .runner(runner) .supporter(supporter) .reviewStatus(reviewStatus) + .isReviewed(isReviewed) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .build(); } @@ -168,6 +168,7 @@ public static RunnerPost create(final Runner runner, final Supporter supporter, .runner(runner) .supporter(supporter) .reviewStatus(ReviewStatus.NOT_STARTED) + .isReviewed(IsReviewed.notReviewed()) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .build(); } @@ -175,7 +176,8 @@ public static RunnerPost create(final Runner runner, final Supporter supporter, public static RunnerPost create(final Runner runner, final Supporter supporter, final Deadline deadline, - final ReviewStatus reviewStatus + final ReviewStatus reviewStatus, + final IsReviewed isReviewed ) { return RunnerPost.builder() .title(new Title("테스트 제목")) @@ -188,22 +190,8 @@ public static RunnerPost create(final Runner runner, .runner(runner) .supporter(supporter) .reviewStatus(reviewStatus) + .isReviewed(isReviewed) .runnerPostTags(new RunnerPostTags(new ArrayList<>())) .build(); } - - public static RunnerPost create(final Runner runner, final Supporter supporter, final RunnerPostTags runnerPostTags, final Deadline deadline) { - return RunnerPost.builder() - .title(new Title("테스트 제목")) - .implementedContents(new ImplementedContents("테스트 내용")) - .curiousContents(new CuriousContents("테스트 궁금 점")) - .postscriptContents(new PostscriptContents("테스트 참고 사항")) - .pullRequestUrl(new PullRequestUrl("https://테스트")) - .deadline(deadline) - .watchedCount(new WatchedCount(0)) - .runner(runner) - .supporter(supporter) - .runnerPostTags(runnerPostTags) - .build(); - } } From 5af32d595540152aba3c5811fb4ee23ad08d0433 Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 02:05:06 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20=EB=9F=AC=EB=84=88=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80=20=EC=9D=91=EB=8B=B5=EC=97=90=20=EC=84=9C?= =?UTF-8?q?=ED=8F=AC=ED=84=B0=20=ED=94=BC=EB=93=9C=EB=B0=B1=20=EC=9C=A0?= =?UTF-8?q?=EB=AC=B4=20=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnerpost/controller/response/RunnerPostResponse.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java index 8fa8577f9..bf676d107 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java @@ -114,6 +114,7 @@ public static Mine from(final RunnerPost runnerPost) { ); } } + public record SimpleInMyPage(Long runnerPostId, Long supporterId, String title, @@ -121,7 +122,8 @@ public record SimpleInMyPage(Long runnerPostId, List tags, int watchedCount, long applicantCount, - String reviewStatus + String reviewStatus, + boolean isReviewed ) { @@ -136,7 +138,8 @@ public static SimpleInMyPage from(final RunnerPost runnerPost, convertToTags(runnerPost), runnerPost.getWatchedCount().getValue(), applicantCount, - runnerPost.getReviewStatus().name() + runnerPost.getReviewStatus().name(), + runnerPost.getIsReviewed().isValue() ); } From 9bc39b7ce6a945dd9756e9209621143de069687c Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 02:05:39 +0900 Subject: [PATCH 04/14] =?UTF-8?q?chore:=20=EB=9F=AC=EB=84=88=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80=EC=97=90=20=EC=84=9C=ED=8F=AC=ED=84=B0=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=EB=B0=B1=20=EC=9C=A0=EB=AC=B4=20flyway=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=20=EC=BB=AC=EB=9F=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V20230920_1__add_new_runner_post_is_reviewed_column.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 backend/baton/src/main/resources/db/migration/V20230920_1__add_new_runner_post_is_reviewed_column.sql diff --git a/backend/baton/src/main/resources/db/migration/V20230920_1__add_new_runner_post_is_reviewed_column.sql b/backend/baton/src/main/resources/db/migration/V20230920_1__add_new_runner_post_is_reviewed_column.sql new file mode 100644 index 000000000..3de6086a0 --- /dev/null +++ b/backend/baton/src/main/resources/db/migration/V20230920_1__add_new_runner_post_is_reviewed_column.sql @@ -0,0 +1 @@ +ALTER TABLE runner_post ADD COLUMN is_reviewed BOOLEAN DEFAULT FALSE; From 18386aa75aaef80ee40587b8e10aa4277f77a0fd Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 02:06:07 +0900 Subject: [PATCH 05/14] =?UTF-8?q?chore:=20=EB=9F=AC=EB=84=88=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80=20=EC=A1=B0=ED=9A=8C=EC=88=98=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=EB=AA=85=20flyway=20=EC=88=98=EC=A0=95=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V20230920_2__alter_runner_post_watched_count_column_name.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 backend/baton/src/main/resources/db/migration/V20230920_2__alter_runner_post_watched_count_column_name.sql diff --git a/backend/baton/src/main/resources/db/migration/V20230920_2__alter_runner_post_watched_count_column_name.sql b/backend/baton/src/main/resources/db/migration/V20230920_2__alter_runner_post_watched_count_column_name.sql new file mode 100644 index 000000000..8d240ccf0 --- /dev/null +++ b/backend/baton/src/main/resources/db/migration/V20230920_2__alter_runner_post_watched_count_column_name.sql @@ -0,0 +1 @@ +ALTER TABLE runner_post CHANGE COLUMN watch_count watched_count INT DEFAULT 0 NOT NULL; From 57c55f6232f8dabb6f3267a4bd382c45d6e84597 Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 12:11:33 +0900 Subject: [PATCH 06/14] =?UTF-8?q?style:=20IsReviewed=20get=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20get=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=ED=86=B5=EC=9D=BC=EB=90=98=EA=B2=8C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnerpost/controller/response/RunnerPostResponse.java | 2 +- .../java/touch/baton/domain/runnerpost/vo/IsReviewed.java | 6 ++++-- .../baton/assure/runnerpost/RunnerPostAssuredSupport.java | 2 +- .../touch/baton/domain/runnerpost/vo/IsReviewedTest.java | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java index bf676d107..2db4fffb1 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java @@ -139,7 +139,7 @@ public static SimpleInMyPage from(final RunnerPost runnerPost, runnerPost.getWatchedCount().getValue(), applicantCount, runnerPost.getReviewStatus().name(), - runnerPost.getIsReviewed().isValue() + runnerPost.getIsReviewed().getValue() ); } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java index 3da02de05..8c59ea317 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java @@ -3,14 +3,12 @@ import jakarta.persistence.Column; import jakarta.persistence.Embeddable; import lombok.EqualsAndHashCode; -import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.ColumnDefault; import static lombok.AccessLevel.PROTECTED; @EqualsAndHashCode -@Getter @NoArgsConstructor(access = PROTECTED) @Embeddable public class IsReviewed { @@ -30,4 +28,8 @@ public static IsReviewed notReviewed() { public static IsReviewed reviewed() { return new IsReviewed(true); } + + public boolean getValue() { + return false; + } } diff --git a/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java b/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java index 00c9fae0f..1f3d0b374 100644 --- a/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java +++ b/backend/baton/src/test/java/touch/baton/assure/runnerpost/RunnerPostAssuredSupport.java @@ -148,7 +148,7 @@ private RunnerPostAssuredSupport() { 조회수, 지원한_서포터_수, 리뷰_상태.name(), - 러너_게시글.getIsReviewed().isValue() + 러너_게시글.getIsReviewed().getValue() ); } diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java index 0825593ae..fb3183b21 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/vo/IsReviewedTest.java @@ -14,7 +14,7 @@ void default_is_false() { final IsReviewed isReviewed = new IsReviewed(); // expect - final boolean actual = isReviewed.isValue(); + final boolean actual = isReviewed.getValue(); assertThat(actual).isFalse(); } From 17539c8bbf6d83e1fac51b972e64f98837f98555 Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 12:18:01 +0900 Subject: [PATCH 07/14] =?UTF-8?q?fix:=20IsReviewed=20=EB=82=B4=EB=B6=80=20?= =?UTF-8?q?=EA=B0=92=20=EB=B0=98=ED=99=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java index 8c59ea317..e96528fa0 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/vo/IsReviewed.java @@ -30,6 +30,6 @@ public static IsReviewed reviewed() { } public boolean getValue() { - return false; + return value; } } From 73c09269b3e8a7fca22af24190b1398b0115dd8b Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 15:55:33 +0900 Subject: [PATCH 08/14] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=82=B4=EB=B6=80=20entityManager=20=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=ED=9B=84=20close=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SupporterTechnicalTagRepositoryTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/baton/src/test/java/touch/baton/domain/technicaltag/repository/SupporterTechnicalTagRepositoryTest.java b/backend/baton/src/test/java/touch/baton/domain/technicaltag/repository/SupporterTechnicalTagRepositoryTest.java index d76612dbb..6f9d21652 100644 --- a/backend/baton/src/test/java/touch/baton/domain/technicaltag/repository/SupporterTechnicalTagRepositoryTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/technicaltag/repository/SupporterTechnicalTagRepositoryTest.java @@ -24,28 +24,29 @@ class SupporterTechnicalTagRepositoryTest extends RepositoryTestConfig { private SupporterTechnicalTagRepository supporterTechnicalTagRepository; @Autowired - private EntityManager entityManager; + private EntityManager em; @DisplayName("batch 로 supporter 의 모든 SupporterTechnicalTag 를 삭제한다.") @Test void deleteBySupporter() { // given final Member member = MemberFixture.createDitoo(); - entityManager.persist(member); + em.persist(member); final Supporter supporter = SupporterFixture.create(member); - entityManager.persist(supporter); + em.persist(supporter); final TechnicalTag technicalTag1 = TechnicalTagFixture.createReact(); final TechnicalTag technicalTag2 = TechnicalTagFixture.createSpring(); final TechnicalTag technicalTag3 = TechnicalTagFixture.createJava(); - entityManager.persist(technicalTag1); - entityManager.persist(technicalTag2); - entityManager.persist(technicalTag3); + em.persist(technicalTag1); + em.persist(technicalTag2); + em.persist(technicalTag3); final SupporterTechnicalTag supporterTechnicalTag1 = SupporterTechnicalTagFixture.create(supporter, technicalTag1); final SupporterTechnicalTag supporterTechnicalTag2 = SupporterTechnicalTagFixture.create(supporter, technicalTag2); final SupporterTechnicalTag supporterTechnicalTag3 = SupporterTechnicalTagFixture.create(supporter, technicalTag3); final List savedSupporterTechnicalTags = List.of(supporterTechnicalTag1, supporterTechnicalTag2, supporterTechnicalTag3); supporterTechnicalTagRepository.saveAll(savedSupporterTechnicalTags); - entityManager.flush(); + em.flush(); + em.close(); // when final int expected = savedSupporterTechnicalTags.size(); From 383526e491165453b8e14e99e7ff039c198468ed Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 15:56:39 +0900 Subject: [PATCH 09/14] =?UTF-8?q?refactor:=20=EB=9F=AC=EB=84=88=20?= =?UTF-8?q?=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=8B=9D=EB=B3=84=EC=9E=90?= =?UTF-8?q?=EA=B0=92=20=EB=AA=A9=EB=A1=9D=EC=9C=BC=EB=A1=9C=20=EC=84=9C?= =?UTF-8?q?=ED=8F=AC=ED=84=B0=20=EC=A7=80=EC=9B=90=EC=9E=90=20=EC=88=98=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EB=A7=A4=ED=95=91=EB=90=9C=20?= =?UTF-8?q?=EC=84=9C=ED=8F=AC=ED=84=B0=20=EC=A7=80=EC=9B=90=EC=9E=90=20?= =?UTF-8?q?=EC=88=98=20=EA=B0=9D=EC=B2=B4=EB=A5=BC=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=A0=88=ED=8F=AC=EC=A7=80?= =?UTF-8?q?=ED=84=B0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/RunnerPostReadRepository.java | 24 +++++-- .../repository/dto/ApplicantCountDto.java | 46 +++++++++++++ .../dto/ApplicantCountMappingDto.java | 34 +++++++++ .../TestRunnerPostReadRepository.java | 5 +- .../RunnerPostReadRepositoryTest.java | 69 +++++++++++++++++-- .../read/RunnerPostRepositoryReadTest.java | 18 ++--- 6 files changed, 174 insertions(+), 22 deletions(-) create mode 100644 backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java create mode 100644 backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java index b7f46d986..c3fdeb3f5 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java @@ -6,21 +6,37 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import touch.baton.domain.runnerpost.RunnerPost; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountDto; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountMappingDto; import touch.baton.domain.runnerpost.vo.ReviewStatus; import touch.baton.domain.tag.vo.TagReducedName; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; public interface RunnerPostReadRepository extends JpaRepository { - @Query(""" - select coalesce(count(srp.id), 0) + default ApplicantCountMappingDto findApplicantCountMappingByRunnerPostIds(final List runnerPostIds) { + final Map applicantCountMapping = countApplicantsByRunnerPostIds(runnerPostIds) + .stream() + .collect(Collectors.toMap( + applicantCountDto -> applicantCountDto.getRunnerPostId(), + applicantCountDto -> applicantCountDto.getApplicantCount() + )); + + return new ApplicantCountMappingDto(applicantCountMapping); + } + + @Query(value = """ + select new touch.baton.domain.runnerpost.repository.dto.ApplicantCountDto(rp.id, count(srp.id)) from RunnerPost rp left outer join fetch SupporterRunnerPost srp on srp.runnerPost.id = rp.id where rp.id in :runnerPostIds group by rp.id + order by rp.id """) - List countApplicantsByRunnerPostIds(@Param("runnerPostIds") final List runnerPostIds); + List countApplicantsByRunnerPostIds(@Param("runnerPostIds") final List runnerPostIds); @Query(""" select rp @@ -28,7 +44,7 @@ select coalesce(count(srp.id), 0) join fetch Runner r on r.id = rp.runner.id join fetch Member m on m.id = r.member.id join fetch RunnerPostTag rpt on rpt.runnerPost.id = rp.id - + where rpt.tag.tagReducedName = :tagReducedName and rp.reviewStatus = :reviewStatus """) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java new file mode 100644 index 000000000..f66b63354 --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java @@ -0,0 +1,46 @@ +package touch.baton.domain.runnerpost.repository.dto; + +import java.util.Objects; + +public class ApplicantCountDto { + + private Long runnerPostId; + private Long applicantCount; + + public ApplicantCountDto() { + } + + public ApplicantCountDto(final Long runnerPostId, final Long applicantCount) { + this.runnerPostId = runnerPostId; + this.applicantCount = (long) applicantCount; + } + + public Long getRunnerPostId() { + return runnerPostId; + } + + public Long getApplicantCount() { + return applicantCount; + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ApplicantCountDto that = (ApplicantCountDto) o; + return applicantCount == that.applicantCount && Objects.equals(runnerPostId, that.runnerPostId); + } + + @Override + public int hashCode() { + return Objects.hash(runnerPostId, applicantCount); + } + + @Override + public String toString() { + return "ApplicantCountDto{" + + "runnerPostId=" + runnerPostId + + ", applicantCount=" + applicantCount + + '}'; + } +} diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java new file mode 100644 index 000000000..d37994659 --- /dev/null +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java @@ -0,0 +1,34 @@ +package touch.baton.domain.runnerpost.repository.dto; + +import java.util.Map; +import java.util.Objects; + +public class ApplicantCountMappingDto { + + private final Map applicantCounts; + + public ApplicantCountMappingDto(final Map applicantCounts) { + this.applicantCounts = applicantCounts; + } + + public Long getApplicantCountByRunnerPostId(final Long runnerPostId) { + return applicantCounts.get(runnerPostId); + } + + public Map getApplicantCounts() { + return applicantCounts; + } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + final ApplicantCountMappingDto that = (ApplicantCountMappingDto) o; + return Objects.equals(applicantCounts, that.applicantCounts); + } + + @Override + public int hashCode() { + return Objects.hash(applicantCounts); + } +} diff --git a/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java b/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java index 9f617ab7b..d72b87374 100644 --- a/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java +++ b/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java @@ -1,17 +1,18 @@ package touch.baton.assure.repository; import touch.baton.domain.runnerpost.repository.RunnerPostReadRepository; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountDto; import java.util.List; public interface TestRunnerPostReadRepository extends RunnerPostReadRepository { default Long countApplicantByRunnerPostId(final Long runnerPostId) { - final List foundApplicants = countApplicantsByRunnerPostIds(List.of(runnerPostId)); + final List foundApplicants = countApplicantsByRunnerPostIds(List.of(runnerPostId)); if (foundApplicants.isEmpty()) { throw new IllegalArgumentException("테스트에서 러너 게시글 식별자값으로 서포터 지원자 수 조회에 실패하였습니다."); } - return foundApplicants.get(0); + return foundApplicants.get(0).getApplicantCount(); } } diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepositoryTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepositoryTest.java index ac977f104..888d458c8 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepositoryTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepositoryTest.java @@ -10,6 +10,8 @@ import touch.baton.domain.member.Member; import touch.baton.domain.runner.Runner; import touch.baton.domain.runnerpost.RunnerPost; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountDto; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountMappingDto; import touch.baton.domain.runnerpost.vo.ReviewStatus; import touch.baton.domain.supporter.Supporter; import touch.baton.domain.supporter.SupporterRunnerPost; @@ -26,6 +28,7 @@ import java.time.LocalDateTime; import java.util.List; +import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; import static touch.baton.fixture.vo.DeadlineFixture.deadline; @@ -68,17 +71,75 @@ void countApplicantsByRunnerPostIds() { em.close(); // when - final List actual = runnerPostReadRepository.countApplicantsByRunnerPostIds(List.of( - runnerPostOne.getId(), + final List actual = runnerPostReadRepository.countApplicantsByRunnerPostIds(List.of( runnerPostTwo.getId(), runnerPostThree.getId(), runnerPostFour.getId(), runnerPostFive.getId(), - runnerPostSix.getId() + runnerPostSix.getId(), + runnerPostOne.getId() )); // then - final List expected = List.of(3L, 2L, 1L, 0L, 0L, 0L); + final List expected = List.of( + new ApplicantCountDto(runnerPostTwo.getId(), 2L), + new ApplicantCountDto(runnerPostThree.getId(), 1L), + new ApplicantCountDto(runnerPostFour.getId(), 0L), + new ApplicantCountDto(runnerPostFive.getId(), 0L), + new ApplicantCountDto(runnerPostSix.getId(), 0L), + new ApplicantCountDto(runnerPostOne.getId(), 3L) + ); + + assertThat(actual).containsExactlyInAnyOrderElementsOf(expected); + } + + @DisplayName("러너 게시글 식별자값 목록으로 서포터 지원자 수 매핑 정보 조회에 성공한다.") + @Test + void findApplicantCountMappingByRunnerPostIds() { + // given + final Runner hyenaRunner = persistRunner(MemberFixture.createHyena()); + final Supporter ditooSupporter = persistSupporter(MemberFixture.createDitoo()); + final Supporter ethanSupporter = persistSupporter(MemberFixture.createEthan()); + final Supporter judySupporter = persistSupporter(MemberFixture.createJudy()); + + final RunnerPost runnerPostOne = persistRunnerPost(hyenaRunner); + final RunnerPost runnerPostTwo = persistRunnerPost(hyenaRunner); + final RunnerPost runnerPostThree = persistRunnerPost(hyenaRunner); + final RunnerPost runnerPostFour = persistRunnerPost(hyenaRunner); + final RunnerPost runnerPostFive = persistRunnerPost(hyenaRunner); + final RunnerPost runnerPostSix = persistRunnerPost(hyenaRunner); + + persistApplicant(ditooSupporter, runnerPostOne); + persistApplicant(ethanSupporter, runnerPostOne); + persistApplicant(judySupporter, runnerPostOne); + + persistApplicant(ditooSupporter, runnerPostTwo); + persistApplicant(ethanSupporter, runnerPostTwo); + + persistApplicant(ditooSupporter, runnerPostThree); + + em.flush(); + em.close(); + + // when + final ApplicantCountMappingDto actual = runnerPostReadRepository.findApplicantCountMappingByRunnerPostIds(List.of( + runnerPostTwo.getId(), + runnerPostThree.getId(), + runnerPostFour.getId(), + runnerPostFive.getId(), + runnerPostSix.getId(), + runnerPostOne.getId() + )); + + // then + final ApplicantCountMappingDto expected = new ApplicantCountMappingDto(Map.of( + runnerPostTwo.getId(), 2L, + runnerPostThree.getId(), 1L, + runnerPostFour.getId(), 0L, + runnerPostFive.getId(), 0L, + runnerPostSix.getId(), 0L, + runnerPostOne.getId(), 3L + )); assertThat(actual).isEqualTo(expected); } diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java index 84cf953be..545b97e23 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java @@ -9,16 +9,13 @@ import org.springframework.data.domain.Sort; import touch.baton.config.RepositoryTestConfig; import touch.baton.domain.member.Member; -import touch.baton.domain.member.repository.MemberRepository; import touch.baton.domain.runner.Runner; -import touch.baton.domain.runner.repository.RunnerRepository; import touch.baton.domain.runnerpost.RunnerPost; import touch.baton.domain.runnerpost.repository.RunnerPostRepository; import touch.baton.domain.runnerpost.vo.IsReviewed; import touch.baton.domain.tag.RunnerPostTag; import touch.baton.domain.tag.Tag; import touch.baton.domain.tag.repository.RunnerPostTagRepository; -import touch.baton.domain.tag.repository.TagRepository; import touch.baton.fixture.domain.MemberFixture; import touch.baton.fixture.domain.RunnerFixture; import touch.baton.fixture.domain.RunnerPostFixture; @@ -44,18 +41,9 @@ class RunnerPostRepositoryReadTest extends RepositoryTestConfig { - @Autowired - private MemberRepository memberRepository; - - @Autowired - private RunnerRepository runnerRepository; - @Autowired private RunnerPostRepository runnerPostRepository; - @Autowired - private TagRepository tagRepository; - @Autowired private RunnerPostTagRepository runnerPostTagRepository; @@ -94,6 +82,9 @@ void findRunnerPostTagsById_exist() { runnerPost.addAllRunnerPostTags(List.of(javaRunnerPostTag, springRunnerPostTag)); + em.flush(); + em.close(); + // when final List expected = runnerPostTagRepository.joinTagByRunnerPostId(runnerPost.getId()); @@ -110,6 +101,9 @@ void findByRunnerId() { final Runner runner = RunnerFixture.createRunner(ditoo); em.persist(runner); + em.close(); + em.flush(); + final RunnerPost runnerPost = RunnerPostFixture.create(title("제 코드를 리뷰해주세요"), implementedContents("제 코드의 내용은 이렇습니다."), curiousContents("저는 이것이 궁금합니다."), From c0323a40171c1d9d0b786070d2006c90ada37476 Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 15:57:38 +0900 Subject: [PATCH 10/14] =?UTF-8?q?refactor:=20=EB=A7=A4=ED=95=91=EB=90=9C?= =?UTF-8?q?=20=EC=84=9C=ED=8F=AC=ED=84=B0=20=EC=A7=80=EC=9B=90=EC=9E=90=20?= =?UTF-8?q?=EC=88=98=20=EA=B0=9D=EC=B2=B4=EB=A5=BC=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=84=9C=EB=B9=84=EC=8A=A4,=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RunnerPostReadController.java | 28 ++++++++++--------- .../service/RunnerPostReadService.java | 5 ++-- .../read/RunnerPostReadSearchApiTest.java | 7 +++-- .../service/RunnerPostReadServiceTest.java | 10 +++++-- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostReadController.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostReadController.java index 1b5be9ead..8d1558e8d 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostReadController.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/RunnerPostReadController.java @@ -14,12 +14,12 @@ import touch.baton.domain.common.response.PageResponse; import touch.baton.domain.runnerpost.RunnerPost; import touch.baton.domain.runnerpost.controller.response.RunnerPostResponse; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountMappingDto; import touch.baton.domain.runnerpost.service.RunnerPostReadService; import touch.baton.domain.runnerpost.service.RunnerPostService; import touch.baton.domain.runnerpost.vo.ReviewStatus; import java.util.List; -import java.util.stream.IntStream; import static org.springframework.data.domain.Sort.Direction.DESC; @@ -38,20 +38,14 @@ public ResponseEntity> readRunnerPostsBy @RequestParam final ReviewStatus reviewStatus ) { final Page pageRunnerPosts = getPageRunnerPosts(pageable, tagName, reviewStatus); + final ApplicantCountMappingDto applicantCountMapping = getApplicantCountMapping(pageRunnerPosts); - final List foundRunnerPostIds = pageRunnerPosts.stream() - .map(RunnerPost::getId) - .toList(); + final List responses = pageRunnerPosts.getContent().stream() + .map(runnerPost -> { + final Long foundApplicantCount = applicantCountMapping.getApplicantCountByRunnerPostId(runnerPost.getId()); - final List foundApplicantCounts = runnerPostReadService.readApplicantCountsByRunnerPostIds(foundRunnerPostIds); - final List responses = IntStream.range(0, foundApplicantCounts.size()) - .mapToObj(index -> { - final RunnerPost current = pageRunnerPosts.getContent().get(index); - final Long applicantCount = foundApplicantCounts.get(index); - - return RunnerPostResponse.Simple.from(current, applicantCount); - } - ).toList(); + return RunnerPostResponse.Simple.from(runnerPost, foundApplicantCount); + }).toList(); final PageImpl pageResponse = new PageImpl<>(responses, pageable, pageRunnerPosts.getTotalElements()); @@ -66,4 +60,12 @@ private Page getPageRunnerPosts(final Pageable pageable, final Strin return runnerPostReadService.readRunnerPostByTagNameAndReviewStatus(pageable, tagName, reviewStatus); } + + private ApplicantCountMappingDto getApplicantCountMapping(final Page pageRunnerPosts) { + final List foundRunnerPostIds = pageRunnerPosts.stream() + .map(RunnerPost::getId) + .toList(); + + return runnerPostReadService.readApplicantCountMappingByRunnerPostIds(foundRunnerPostIds); + } } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostReadService.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostReadService.java index 5456d5636..13d6a27d1 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostReadService.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/service/RunnerPostReadService.java @@ -7,6 +7,7 @@ import org.springframework.transaction.annotation.Transactional; import touch.baton.domain.runnerpost.RunnerPost; import touch.baton.domain.runnerpost.repository.RunnerPostReadRepository; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountMappingDto; import touch.baton.domain.runnerpost.vo.ReviewStatus; import touch.baton.domain.tag.vo.TagReducedName; @@ -28,7 +29,7 @@ public Page readRunnerPostByTagNameAndReviewStatus(final Pageable pa return runnerPostReadRepository.findByTagReducedNameAndReviewStatus(pageable, tagReducedName, reviewStatus); } - public List readApplicantCountsByRunnerPostIds(final List runnerPostIds) { - return runnerPostReadRepository.countApplicantsByRunnerPostIds(runnerPostIds); + public ApplicantCountMappingDto readApplicantCountMappingByRunnerPostIds(final List runnerPostIds) { + return runnerPostReadRepository.findApplicantCountMappingByRunnerPostIds(runnerPostIds); } } diff --git a/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadSearchApiTest.java b/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadSearchApiTest.java index 0b7cb5287..da8d9975e 100644 --- a/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadSearchApiTest.java +++ b/backend/baton/src/test/java/touch/baton/document/runnerpost/read/RunnerPostReadSearchApiTest.java @@ -12,6 +12,7 @@ import touch.baton.domain.runner.Runner; import touch.baton.domain.runnerpost.RunnerPost; import touch.baton.domain.runnerpost.controller.RunnerPostReadController; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountMappingDto; import touch.baton.domain.runnerpost.service.RunnerPostReadService; import touch.baton.domain.runnerpost.service.RunnerPostService; import touch.baton.domain.runnerpost.vo.Deadline; @@ -24,6 +25,7 @@ import java.time.LocalDateTime; import java.util.List; +import java.util.Map; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList; @@ -51,6 +53,7 @@ class RunnerPostReadSearchApiTest extends RestdocsConfig { @MockBean private RunnerPostReadService runnerPostReadService; + @MockBean private RunnerPostService runnerPostService; @@ -81,8 +84,8 @@ void readRunnerPostsByTagNamesAndReviewStatus() throws Exception { when(runnerPostReadService.readRunnerPostByTagNameAndReviewStatus(any(Pageable.class), anyString(), any(ReviewStatus.class))) .thenReturn(pageRunnerPosts); - when(runnerPostReadService.readApplicantCountsByRunnerPostIds(anyList())) - .thenReturn(List.of(0L)); + when(runnerPostReadService.readApplicantCountMappingByRunnerPostIds(anyList())) + .thenReturn(new ApplicantCountMappingDto(Map.of(1L, 0L))); // then mockMvc.perform(get("/api/v1/posts/runner/tags/search") diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostReadServiceTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostReadServiceTest.java index e1fea3589..52d9fdd7e 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostReadServiceTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/service/RunnerPostReadServiceTest.java @@ -10,6 +10,7 @@ import touch.baton.domain.member.Member; import touch.baton.domain.runner.Runner; import touch.baton.domain.runnerpost.RunnerPost; +import touch.baton.domain.runnerpost.repository.dto.ApplicantCountMappingDto; import touch.baton.domain.runnerpost.vo.ReviewStatus; import touch.baton.domain.supporter.Supporter; import touch.baton.domain.tag.Tag; @@ -22,6 +23,7 @@ import java.time.LocalDateTime; import java.util.List; +import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; @@ -138,10 +140,14 @@ void readApplicantCountsByRunnerPostIds() { savedRunnerPostThree.getId() ); - final List actual = runnerPostReadService.readApplicantCountsByRunnerPostIds(runnerPostIds); + final ApplicantCountMappingDto actual = runnerPostReadService.readApplicantCountMappingByRunnerPostIds(runnerPostIds); // then - final List expected = List.of(3L, 0L, 2L); + final ApplicantCountMappingDto expected = new ApplicantCountMappingDto(Map.of( + savedRunnerPostOne.getId(), 3L, + savedRunnerPostTwo.getId(), 0L, + savedRunnerPostThree.getId(), 2L + )); assertThat(actual).isEqualTo(expected); } From 02bea413788f8233f5014a103f0110b44ddf313f Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 16:02:54 +0900 Subject: [PATCH 11/14] =?UTF-8?q?style:=20=EA=B3=B5=EB=B0=B1=20=EB=B0=8F?= =?UTF-8?q?=20=EA=B0=9C=ED=96=89=20=EC=8A=A4=ED=83=80=EC=9D=BC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnerpost/controller/response/RunnerPostResponse.java | 2 +- .../domain/runnerpost/repository/RunnerPostReadRepository.java | 1 - .../domain/runnerpost/repository/dto/ApplicantCountDto.java | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java index 2db4fffb1..2d1ea2467 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/controller/response/RunnerPostResponse.java @@ -139,7 +139,7 @@ public static SimpleInMyPage from(final RunnerPost runnerPost, runnerPost.getWatchedCount().getValue(), applicantCount, runnerPost.getReviewStatus().name(), - runnerPost.getIsReviewed().getValue() + runnerPost.getIsReviewed().getValue() ); } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java index c3fdeb3f5..5bbcde757 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java @@ -44,7 +44,6 @@ default ApplicantCountMappingDto findApplicantCountMappingByRunnerPostIds(final join fetch Runner r on r.id = rp.runner.id join fetch Member m on m.id = r.member.id join fetch RunnerPostTag rpt on rpt.runnerPost.id = rp.id - where rpt.tag.tagReducedName = :tagReducedName and rp.reviewStatus = :reviewStatus """) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java index f66b63354..74d4f2af3 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java @@ -5,6 +5,7 @@ public class ApplicantCountDto { private Long runnerPostId; + private Long applicantCount; public ApplicantCountDto() { From 462fccd746c75000d6ce1d907df9720d01dc162c Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 16:03:47 +0900 Subject: [PATCH 12/14] =?UTF-8?q?style:=20toString=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runnerpost/repository/dto/ApplicantCountDto.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java index 74d4f2af3..64bacb079 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java @@ -36,12 +36,4 @@ public boolean equals(final Object o) { public int hashCode() { return Objects.hash(runnerPostId, applicantCount); } - - @Override - public String toString() { - return "ApplicantCountDto{" + - "runnerPostId=" + runnerPostId + - ", applicantCount=" + applicantCount + - '}'; - } } From 2aff82d710c19463a2bb75ed9866a06e0aff0a03 Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 16:25:37 +0900 Subject: [PATCH 13/14] =?UTF-8?q?refactor:=20dto=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=EB=A5=BC=20=EB=A0=88=EC=BD=94=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/RunnerPostReadRepository.java | 5 +-- .../repository/dto/ApplicantCountDto.java | 37 +------------------ .../dto/ApplicantCountMappingDto.java | 26 +------------ .../TestRunnerPostReadRepository.java | 2 +- 4 files changed, 5 insertions(+), 65 deletions(-) diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java index 5bbcde757..734b105df 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/RunnerPostReadRepository.java @@ -21,8 +21,8 @@ default ApplicantCountMappingDto findApplicantCountMappingByRunnerPostIds(final final Map applicantCountMapping = countApplicantsByRunnerPostIds(runnerPostIds) .stream() .collect(Collectors.toMap( - applicantCountDto -> applicantCountDto.getRunnerPostId(), - applicantCountDto -> applicantCountDto.getApplicantCount() + ApplicantCountDto::runnerPostId, + ApplicantCountDto::applicantCount )); return new ApplicantCountMappingDto(applicantCountMapping); @@ -34,7 +34,6 @@ default ApplicantCountMappingDto findApplicantCountMappingByRunnerPostIds(final left outer join fetch SupporterRunnerPost srp on srp.runnerPost.id = rp.id where rp.id in :runnerPostIds group by rp.id - order by rp.id """) List countApplicantsByRunnerPostIds(@Param("runnerPostIds") final List runnerPostIds); diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java index 64bacb079..3191616c7 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountDto.java @@ -1,39 +1,4 @@ package touch.baton.domain.runnerpost.repository.dto; -import java.util.Objects; - -public class ApplicantCountDto { - - private Long runnerPostId; - - private Long applicantCount; - - public ApplicantCountDto() { - } - - public ApplicantCountDto(final Long runnerPostId, final Long applicantCount) { - this.runnerPostId = runnerPostId; - this.applicantCount = (long) applicantCount; - } - - public Long getRunnerPostId() { - return runnerPostId; - } - - public Long getApplicantCount() { - return applicantCount; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final ApplicantCountDto that = (ApplicantCountDto) o; - return applicantCount == that.applicantCount && Objects.equals(runnerPostId, that.runnerPostId); - } - - @Override - public int hashCode() { - return Objects.hash(runnerPostId, applicantCount); - } +public record ApplicantCountDto(Long runnerPostId, Long applicantCount) { } diff --git a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java index d37994659..64d26021b 100644 --- a/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java +++ b/backend/baton/src/main/java/touch/baton/domain/runnerpost/repository/dto/ApplicantCountMappingDto.java @@ -1,34 +1,10 @@ package touch.baton.domain.runnerpost.repository.dto; import java.util.Map; -import java.util.Objects; -public class ApplicantCountMappingDto { - - private final Map applicantCounts; - - public ApplicantCountMappingDto(final Map applicantCounts) { - this.applicantCounts = applicantCounts; - } +public record ApplicantCountMappingDto(Map applicantCounts) { public Long getApplicantCountByRunnerPostId(final Long runnerPostId) { return applicantCounts.get(runnerPostId); } - - public Map getApplicantCounts() { - return applicantCounts; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - final ApplicantCountMappingDto that = (ApplicantCountMappingDto) o; - return Objects.equals(applicantCounts, that.applicantCounts); - } - - @Override - public int hashCode() { - return Objects.hash(applicantCounts); - } } diff --git a/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java b/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java index d72b87374..3e1d5244d 100644 --- a/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java +++ b/backend/baton/src/test/java/touch/baton/assure/repository/TestRunnerPostReadRepository.java @@ -13,6 +13,6 @@ default Long countApplicantByRunnerPostId(final Long runnerPostId) { throw new IllegalArgumentException("테스트에서 러너 게시글 식별자값으로 서포터 지원자 수 조회에 실패하였습니다."); } - return foundApplicants.get(0).getApplicantCount(); + return foundApplicants.get(0).applicantCount(); } } From fe9d48b64f073237a323ea0118f8ee90873198fd Mon Sep 17 00:00:00 2001 From: hyena Date: Wed, 20 Sep 2023 16:29:42 +0900 Subject: [PATCH 14/14] =?UTF-8?q?test:=20entityManager=20flush,=20close=20?= =?UTF-8?q?=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/read/RunnerPostRepositoryReadTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java index 545b97e23..16ccbc670 100644 --- a/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java +++ b/backend/baton/src/test/java/touch/baton/domain/runnerpost/repository/read/RunnerPostRepositoryReadTest.java @@ -101,8 +101,8 @@ void findByRunnerId() { final Runner runner = RunnerFixture.createRunner(ditoo); em.persist(runner); - em.close(); em.flush(); + em.close(); final RunnerPost runnerPost = RunnerPostFixture.create(title("제 코드를 리뷰해주세요"), implementedContents("제 코드의 내용은 이렇습니다."),