Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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());
}
}
}