Skip to content

Commit 1318cfe

Browse files
authored
[Fix] 스토리 본문 내용 NULL 허용
2 parents f062817 + 449d315 commit 1318cfe

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

src/main/java/eatda/domain/story/Story.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void validateStoreCategory(StoreCategory storeCategory) {
142142
}
143143

144144
private void validateDescription(String description) {
145-
if (description == null || description.isBlank()) {
145+
if (description != null && description.isBlank()) {
146146
throw new BusinessException(BusinessErrorCode.INVALID_STORY_DESCRIPTION);
147147
}
148148
}

src/main/java/eatda/exception/BusinessErrorCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public enum BusinessErrorCode {
4545
PRESIGNED_URL_GENERATION_FAILED("SERVER004", "Presigned URL 생성에 실패했습니다.", HttpStatus.INTERNAL_SERVER_ERROR),
4646

4747
//story
48-
INVALID_STORY_DESCRIPTION("STY001", "스토리 본문은 필수입니다."),
48+
INVALID_STORY_DESCRIPTION("STY001", "스토리 본문은 빈 문자열일 수 없습니다."),
4949
INVALID_STORY_IMAGE_KEY("STY002", "스토리 이미지 Key는 필수입니다."),
5050
STORY_MEMBER_REQUIRED("STY003", "스토리 작성 시 회원 정보는 필수입니다."),
5151
STORY_STORE_REQUIRED("STY004", "스토리 작성 시 가게 정보는 필수입니다."),

src/test/java/eatda/document/store/CheerDocumentTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class RegisterCheer {
4949
- request body 예시
5050
```json
5151
{
52-
"storeKakaoId": "123", // 가게 카카오 ID
53-
"storeName": "농민백암순대 본점", // 가게 이름
54-
"description": "너무 맛있어요! 준환님 추천 맛집!" // 응원 내용
52+
"storeKakaoId": "123", // 가게 카카오 ID (필수)
53+
"storeName": "농민백암순대 본점", // 가게 이름 (필수)
54+
"description": "너무 맛있어요! 준환님 추천 맛집!" // 응원 내용 (필수)
5555
}
5656
```
5757
""";

src/test/java/eatda/document/story/StoryDocumentTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class RegisterStory {
4141
- request body 예시
4242
```json
4343
{
44-
"storeKakaoId": "123", // 가게 카카오 ID
45-
"storeName": "농민백암순대 본점", // 가게 이름
46-
"description": "너무 맛있어요! 준환님 추천 맛집!" // 스토리 내용
44+
"storeKakaoId": "123", // 가게 카카오 ID (필수)
45+
"storeName": "농민백암순대 본점", // 가게 이름 (필수)
46+
"description": "너무 맛있어요! 준환님 추천 맛집!" // 스토리 내용 (null 허용)
4747
}
4848
```
4949
""";
@@ -60,7 +60,7 @@ class RegisterStory {
6060
).requestBodyField("request",
6161
fieldWithPath("storeName").description("가게 이름"),
6262
fieldWithPath("storeKakaoId").description("가게의 카카오 ID"),
63-
fieldWithPath("description").description("스토리 내용 (필수)")
63+
fieldWithPath("description").description("스토리 내용 (필수)").optional()
6464
);
6565

6666
RestDocsResponse responseDocument = response()

src/test/java/eatda/domain/story/StoryTest.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,15 @@ class ValidateStore {
117117
@Nested
118118
class ValidateStory {
119119

120+
@Test
121+
void 설명은_null_이어도_예외가_발생하지_않는다() {
122+
Story story = defaultStoryBuilder.description(null).build();
123+
124+
assertThat(story.getDescription()).isNull();
125+
}
126+
120127
@ParameterizedTest
121-
@NullAndEmptySource
122-
@ValueSource(strings = {"\t", " "})
128+
@ValueSource(strings = {"\t", " ", ""})
123129
void 설명이_비어있으면_예외가_발생한다(String emptyDescription) {
124130
assertThatThrownBy(() -> defaultStoryBuilder
125131
.description(emptyDescription)
@@ -136,5 +142,16 @@ class ValidateStory {
136142
).isInstanceOf(BusinessException.class)
137143
.hasMessage(BusinessErrorCode.INVALID_STORY_IMAGE_KEY.getMessage());
138144
}
145+
146+
@Test
147+
void 이미지가_키가_비어있으면_예외가_발생한다() {
148+
ImageKey emptyImageKey = new ImageKey(null);
149+
150+
assertThatThrownBy(() -> defaultStoryBuilder
151+
.imageKey(emptyImageKey)
152+
.build()
153+
).isInstanceOf(BusinessException.class)
154+
.hasMessage(BusinessErrorCode.INVALID_STORY_IMAGE_KEY.getMessage());
155+
}
139156
}
140157
}

0 commit comments

Comments
 (0)