diff --git a/backend/src/main/java/reviewme/review/service/ReviewPreviewGenerator.java b/backend/src/main/java/reviewme/review/service/ReviewPreviewGenerator.java index d0d49781d..e0cbebc71 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewPreviewGenerator.java +++ b/backend/src/main/java/reviewme/review/service/ReviewPreviewGenerator.java @@ -6,6 +6,7 @@ public class ReviewPreviewGenerator { private static final int PREVIEW_LENGTH = 150; + private static final String ELLIPSIS = "..."; public String generatePreview(List reviewTextAnswers) { if (reviewTextAnswers.isEmpty()) { @@ -13,7 +14,7 @@ public String generatePreview(List reviewTextAnswers) { } String answer = reviewTextAnswers.get(0).getContent(); if (answer.length() > PREVIEW_LENGTH) { - return answer.substring(0, PREVIEW_LENGTH); + return answer.substring(0, PREVIEW_LENGTH) + ELLIPSIS; } return answer; } diff --git a/backend/src/test/java/reviewme/review/service/ReviewPreviewGeneratorTest.java b/backend/src/test/java/reviewme/review/service/ReviewPreviewGeneratorTest.java index f63c47b5f..206fade70 100644 --- a/backend/src/test/java/reviewme/review/service/ReviewPreviewGeneratorTest.java +++ b/backend/src/test/java/reviewme/review/service/ReviewPreviewGeneratorTest.java @@ -11,7 +11,7 @@ class ReviewPreviewGeneratorTest { @Test - void 답변_내용이_미리보기_최대_글자를_넘는_경우_미리보기_길이만큼_잘라서_반환한다() { + void 답변_내용이_미리보기_최대_글자를_넘는_경우_미리보기_길이만큼_자르고_말줄임표를_붙여_반환한다() { // given ReviewPreviewGenerator reviewPreviewGenerator = new ReviewPreviewGenerator(); String answer = "*".repeat(151); @@ -21,7 +21,7 @@ class ReviewPreviewGeneratorTest { String actual = reviewPreviewGenerator.generatePreview(List.of(textAnswer)); // then - assertThat(actual).hasSize(150); + assertThat(actual).isEqualTo("*".repeat(150) + "..."); } @ParameterizedTest