From d9ba843dfba1f9f615838398efdaa658359a642e Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Wed, 17 Jun 2026 17:14:04 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20?= =?UTF-8?q?=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC=EC=97=90=20=EB=8F=99?= =?UTF-8?q?=ED=96=89,=20=EC=A4=91=EA=B3=A0=EA=B1=B0=EB=9E=98=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 - PostCategory enum에 동행, 중고거래 추가 - post 테이블 category ENUM 컬럼 마이그레이션 (V52) - 신규 카테고리 게시글 생성 및 카테고리별 조회 필터링 테스트 추가 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../community/post/domain/PostCategory.java | 2 +- ...panion_and_used_trade_to_post_category.sql | 2 + .../post/service/PostCommandServiceTest.java | 18 +++++++ .../post/service/PostQueryServiceTest.java | 50 +++++++++++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/db/migration/V52__add_companion_and_used_trade_to_post_category.sql diff --git a/src/main/java/com/example/solidconnection/community/post/domain/PostCategory.java b/src/main/java/com/example/solidconnection/community/post/domain/PostCategory.java index 76b003bc5..0b1598bd2 100644 --- a/src/main/java/com/example/solidconnection/community/post/domain/PostCategory.java +++ b/src/main/java/com/example/solidconnection/community/post/domain/PostCategory.java @@ -5,7 +5,7 @@ import java.util.stream.Collectors; public enum PostCategory { - 전체, 자유, 질문; + 전체, 자유, 질문, 동행, 중고거래; private static final Set NAMES = Arrays.stream(values()) .map(Enum::name) diff --git a/src/main/resources/db/migration/V52__add_companion_and_used_trade_to_post_category.sql b/src/main/resources/db/migration/V52__add_companion_and_used_trade_to_post_category.sql new file mode 100644 index 000000000..5be62db68 --- /dev/null +++ b/src/main/resources/db/migration/V52__add_companion_and_used_trade_to_post_category.sql @@ -0,0 +1,2 @@ +ALTER TABLE post + MODIFY COLUMN category ENUM ('자유', '전체', '질문', '동행', '중고거래') NULL; diff --git a/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java b/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java index 309797032..18642c091 100644 --- a/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java +++ b/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java @@ -38,6 +38,8 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.bean.override.mockito.MockitoBean; @@ -164,6 +166,22 @@ class 게시글_생성_테스트 { ); } + @ParameterizedTest + @ValueSource(strings = {"자유", "질문", "동행", "중고거래"}) + @Transactional + void 전체를_제외한_카테고리로_게시글을_생성한다(String category) { + // given + PostCreateRequest request = createPostCreateRequest(category); + List imageFiles = List.of(); + + // when + PostCreateResponse response = postCommandService.createPost(user1.getId(), request, imageFiles); + + // then + Post savedPost = postRepository.findById(response.id()).orElseThrow(); + assertThat(savedPost.getCategory()).isEqualTo(PostCategory.valueOf(category)); + } + @Test void 전체_카테고리로_생성하면_예외가_발생한다() { // given diff --git a/src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java b/src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java index 66803d688..6d8dd67f1 100644 --- a/src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java +++ b/src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java @@ -135,6 +135,56 @@ void setUp() { ); } + @Test + void 동행_카테고리로_조회시_해당_카테고리의_게시글만_조회한다() { + // given + Post 동행_게시글 = postFixture.게시글( + "동행 제목", + "동행 내용", + false, + PostCategory.동행, + boardFixture.자유게시판(), + user + ); + + // when + List actualResponses = postQueryService.findPostsByCodeAndPostCategoryOrderByCreatedAtDesc( + BoardCode.FREE.name(), + PostCategory.동행.name(), + null + ); + + // then + assertThat(actualResponses) + .extracting(PostListResponse::id) + .containsExactly(동행_게시글.getId()); + } + + @Test + void 중고거래_카테고리로_조회시_해당_카테고리의_게시글만_조회한다() { + // given + Post 중고거래_게시글 = postFixture.게시글( + "중고거래 제목", + "중고거래 내용", + false, + PostCategory.중고거래, + boardFixture.자유게시판(), + user + ); + + // when + List actualResponses = postQueryService.findPostsByCodeAndPostCategoryOrderByCreatedAtDesc( + BoardCode.FREE.name(), + PostCategory.중고거래.name(), + null + ); + + // then + assertThat(actualResponses) + .extracting(PostListResponse::id) + .containsExactly(중고거래_게시글.getId()); + } + @Test void 전체_카테고리로_조회시_해당_게시판의_모든_게시글을_조회한다() { // given From 2a7c764a5437b80f974fae4dc098dcddb27e72ff Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Thu, 18 Jun 2026 00:09:05 +0900 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=EC=84=B1=EA=B3=B5=EC=A0=81=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=99=80=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=EB=90=98=EB=8A=94=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20=EC=83=9D=EC=84=B1=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../post/service/PostCommandServiceTest.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java b/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java index 18642c091..309797032 100644 --- a/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java +++ b/src/test/java/com/example/solidconnection/community/post/service/PostCommandServiceTest.java @@ -38,8 +38,6 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.context.bean.override.mockito.MockitoBean; @@ -166,22 +164,6 @@ class 게시글_생성_테스트 { ); } - @ParameterizedTest - @ValueSource(strings = {"자유", "질문", "동행", "중고거래"}) - @Transactional - void 전체를_제외한_카테고리로_게시글을_생성한다(String category) { - // given - PostCreateRequest request = createPostCreateRequest(category); - List imageFiles = List.of(); - - // when - PostCreateResponse response = postCommandService.createPost(user1.getId(), request, imageFiles); - - // then - Post savedPost = postRepository.findById(response.id()).orElseThrow(); - assertThat(savedPost.getCategory()).isEqualTo(PostCategory.valueOf(category)); - } - @Test void 전체_카테고리로_생성하면_예외가_발생한다() { // given From 6acc02850ef3d94e4e86a2ea1acc9208a64ab8d5 Mon Sep 17 00:00:00 2001 From: sukangpunch Date: Thu, 18 Jun 2026 13:30:49 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20flyway=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EC=B6=A9=EB=8F=8C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sql => V53__add_companion_and_used_trade_to_post_category.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V52__add_companion_and_used_trade_to_post_category.sql => V53__add_companion_and_used_trade_to_post_category.sql} (100%) diff --git a/src/main/resources/db/migration/V52__add_companion_and_used_trade_to_post_category.sql b/src/main/resources/db/migration/V53__add_companion_and_used_trade_to_post_category.sql similarity index 100% rename from src/main/resources/db/migration/V52__add_companion_and_used_trade_to_post_category.sql rename to src/main/resources/db/migration/V53__add_companion_and_used_trade_to_post_category.sql