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/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