Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/eatda/domain/story/Story.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void validateStoreCategory(StoreCategory storeCategory) {
}

private void validateDescription(String description) {
if (description == null || description.isBlank()) {
if (description != null && description.isBlank()) {
throw new BusinessException(BusinessErrorCode.INVALID_STORY_DESCRIPTION);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eatda/exception/BusinessErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public enum BusinessErrorCode {
PRESIGNED_URL_GENERATION_FAILED("SERVER004", "Presigned URL 생성에 실패했습니다.", HttpStatus.INTERNAL_SERVER_ERROR),

//story
INVALID_STORY_DESCRIPTION("STY001", "스토리 본문은 필수입니다."),
INVALID_STORY_DESCRIPTION("STY001", "스토리 본문은 빈 문자열일 수 없습니다."),
INVALID_STORY_IMAGE_KEY("STY002", "스토리 이미지 Key는 필수입니다."),
STORY_MEMBER_REQUIRED("STY003", "스토리 작성 시 회원 정보는 필수입니다."),
STORY_STORE_REQUIRED("STY004", "스토리 작성 시 가게 정보는 필수입니다."),
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/eatda/document/store/CheerDocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class RegisterCheer {
- request body 예시
```json
{
"storeKakaoId": "123", // 가게 카카오 ID
"storeName": "농민백암순대 본점", // 가게 이름
"description": "너무 맛있어요! 준환님 추천 맛집!" // 응원 내용
"storeKakaoId": "123", // 가게 카카오 ID (필수)
"storeName": "농민백암순대 본점", // 가게 이름 (필수)
"description": "너무 맛있어요! 준환님 추천 맛집!" // 응원 내용 (필수)
}
```
""";
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/eatda/document/story/StoryDocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class RegisterStory {
- request body 예시
```json
{
"storeKakaoId": "123", // 가게 카카오 ID
"storeName": "농민백암순대 본점", // 가게 이름
"description": "너무 맛있어요! 준환님 추천 맛집!" // 스토리 내용
"storeKakaoId": "123", // 가게 카카오 ID (필수)
"storeName": "농민백암순대 본점", // 가게 이름 (필수)
"description": "너무 맛있어요! 준환님 추천 맛집!" // 스토리 내용 (null 허용)
}
```
""";
Expand All @@ -60,7 +60,7 @@ class RegisterStory {
).requestBodyField("request",
fieldWithPath("storeName").description("가게 이름"),
fieldWithPath("storeKakaoId").description("가게의 카카오 ID"),
fieldWithPath("description").description("스토리 내용 (필수)")
fieldWithPath("description").description("스토리 내용 (필수)").optional()
);

RestDocsResponse responseDocument = response()
Expand Down
21 changes: 19 additions & 2 deletions src/test/java/eatda/domain/story/StoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ class ValidateStore {
@Nested
class ValidateStory {

@Test
void 설명은_null_이어도_예외가_발생하지_않는다() {
Story story = defaultStoryBuilder.description(null).build();

assertThat(story.getDescription()).isNull();
}

@ParameterizedTest
@NullAndEmptySource
@ValueSource(strings = {"\t", " "})
@ValueSource(strings = {"\t", " ", ""})
void 설명이_비어있으면_예외가_발생한다(String emptyDescription) {
assertThatThrownBy(() -> defaultStoryBuilder
.description(emptyDescription)
Expand All @@ -136,5 +142,16 @@ class ValidateStory {
).isInstanceOf(BusinessException.class)
.hasMessage(BusinessErrorCode.INVALID_STORY_IMAGE_KEY.getMessage());
}

@Test
void 이미지가_키가_비어있으면_예외가_발생한다() {
ImageKey emptyImageKey = new ImageKey(null);

assertThatThrownBy(() -> defaultStoryBuilder
.imageKey(emptyImageKey)
.build()
).isInstanceOf(BusinessException.class)
.hasMessage(BusinessErrorCode.INVALID_STORY_IMAGE_KEY.getMessage());
}
}
}