From e59f2b360dd53f54fc82b243722fc0f225a0f3ff Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Sat, 9 Aug 2025 14:22:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20url=20->=20postThumbnailUrl=20?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solidconnection/community/post/dto/PostListResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/solidconnection/community/post/dto/PostListResponse.java b/src/main/java/com/example/solidconnection/community/post/dto/PostListResponse.java index 89fb20aab..7c4871419 100644 --- a/src/main/java/com/example/solidconnection/community/post/dto/PostListResponse.java +++ b/src/main/java/com/example/solidconnection/community/post/dto/PostListResponse.java @@ -15,7 +15,7 @@ public record PostListResponse( ZonedDateTime createdAt, ZonedDateTime updatedAt, String postCategory, - String url + String postThumbnailUrl ) { public static PostListResponse from(Post post) { From a4a4cd8cc1c8aeed392c3bd85e47154d7579adc2 Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Sat, 9 Aug 2025 14:22:49 +0900 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=EC=A0=84=EC=B2=B4=20=EA=B2=8C?= =?UTF-8?q?=EC=8B=9C=EA=B8=80=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=B2=AB?= =?UTF-8?q?=20=EB=B2=88=EC=A7=B8=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20?= =?UTF-8?q?=EC=8D=B8=EB=84=A4=EC=9D=BC=EB=A1=9C=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=ED=95=98=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/service/PostQueryServiceTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) 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 2377847d6..8b09da293 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 @@ -166,4 +166,35 @@ void setUp() { () -> assertThat(redisService.isKeyExists(validateKey)).isTrue() ); } + + @Test + void 게시글_목록_조회시_첫번째_이미지를_썸네일로_반환한다() { + // given + String firstImageUrl = "first-thumbnail-url"; + String secondImageUrl = "second-thumbnail-url"; + postImageFixture.게시글_이미지(firstImageUrl, post1); + postImageFixture.게시글_이미지(secondImageUrl, post1); + + // when + List actualResponses = postQueryService.findPostsByCodeAndPostCategory( + BoardCode.FREE.name(), + PostCategory.전체.name() + ); + + // then + PostListResponse post1Response = actualResponses.stream() + .filter(p -> p.id().equals(post1.getId())) + .findFirst() + .orElseThrow(); + + PostListResponse post3Response = actualResponses.stream() + .filter(p -> p.id().equals(post3.getId())) + .findFirst() + .orElseThrow(); + + assertAll( + () -> assertThat(post1Response.postThumbnailUrl()).isEqualTo(firstImageUrl), + () -> assertThat(post3Response.postThumbnailUrl()).isNull() + ); + } } From 0ee3050ffec90e200d1afef26c69d11e59b4ceed Mon Sep 17 00:00:00 2001 From: seonghyeok Date: Mon, 11 Aug 2025 15:35:00 +0900 Subject: [PATCH 3/3] =?UTF-8?q?test:=20=ED=95=98=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EA=B0=80=20=EB=91=90=20=EA=B0=9C?= =?UTF-8?q?=EC=9D=98=20=EB=8F=99=EC=9E=91=EC=9D=84=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0,=20=ED=95=98=EB=82=98?= =?UTF-8?q?=EC=9D=98=20=EB=8F=99=EC=9E=91=EB=A7=8C=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../post/service/PostQueryServiceTest.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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 8b09da293..f5e1bb45b 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 @@ -182,19 +182,28 @@ void setUp() { ); // then - PostListResponse post1Response = actualResponses.stream() + PostListResponse postResponse = actualResponses.stream() .filter(p -> p.id().equals(post1.getId())) .findFirst() .orElseThrow(); - PostListResponse post3Response = actualResponses.stream() + assertThat(postResponse.postThumbnailUrl()).isEqualTo(firstImageUrl); + } + + @Test + void 게시글에_이미지가_없다면_썸네일로_null을_반환한다() { + // when + List actualResponses = postQueryService.findPostsByCodeAndPostCategory( + BoardCode.FREE.name(), + PostCategory.전체.name() + ); + + // then + PostListResponse postResponse = actualResponses.stream() .filter(p -> p.id().equals(post3.getId())) .findFirst() .orElseThrow(); - assertAll( - () -> assertThat(post1Response.postThumbnailUrl()).isEqualTo(firstImageUrl), - () -> assertThat(post3Response.postThumbnailUrl()).isNull() - ); + assertThat(postResponse.postThumbnailUrl()).isNull(); } }