-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe6b7c8
commit d9b3d3a
Showing
4 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/java/com/baro/memofolder/domain/MemoFolderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.baro.memofolder.domain; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatCode; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import com.baro.member.domain.Member; | ||
import com.baro.memofolder.exception.MemoFolderException; | ||
import com.baro.memofolder.exception.MemoFolderExceptionType; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@DisplayNameGeneration(ReplaceUnderscores.class) | ||
@SuppressWarnings("NonAsciiCharacters") | ||
class MemoFolderTest { | ||
|
||
@Test | ||
void 메모_폴더의_소유자가_일치한다() { | ||
// given | ||
Member member = new Member(1L, "name", "email", "nickname", "oAuthId", "oAuthServiceType"); | ||
MemoFolder memoFolder = MemoFolder.of(member, "폴더이름"); | ||
|
||
// when & then | ||
assertThatCode(() -> memoFolder.matchOwner(1L)) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@Test | ||
void 메모_폴더의_소유자가_일치하지_않는다() { | ||
// given | ||
Member member = new Member(1L, "name", "email", "nickname", "oAuthId", "oAuthServiceType"); | ||
MemoFolder memoFolder = MemoFolder.of(member, "폴더이름"); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> memoFolder.matchOwner(999L)) | ||
.isInstanceOf(MemoFolderException.class) | ||
.extracting("exceptionType") | ||
.isEqualTo(MemoFolderExceptionType.NOT_MATCH_OWNER); | ||
} | ||
|
||
@Test | ||
void 메모_폴더의_이름을_변경한다() { | ||
// given | ||
Member member = new Member(1L, "name", "email", "nickname", "oAuthId", "oAuthServiceType"); | ||
MemoFolder memoFolder = MemoFolder.of(member, "폴더이름"); | ||
|
||
// when & then | ||
assertThatCode(() -> memoFolder.rename("변경된폴더이름")) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@Test | ||
void 메모_폴더_이름_변경시_최대_길이_검증() { | ||
// given | ||
Member member = new Member(1L, "name", "email", "nickname", "oAuthId", "oAuthServiceType"); | ||
MemoFolder memoFolder = MemoFolder.of(member, "폴더이름"); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> memoFolder.rename("1".repeat(11))) | ||
.isInstanceOf(MemoFolderException.class) | ||
.extracting("exceptionType") | ||
.isEqualTo(MemoFolderExceptionType.OVER_MAX_SIZE_NAME); | ||
} | ||
|
||
@Test | ||
void 메모_폴더_이름_변경시_빈_문자열_검증() { | ||
// given | ||
Member member = new Member(1L, "name", "email", "nickname", "oAuthId", "oAuthServiceType"); | ||
MemoFolder memoFolder = MemoFolder.of(member, "폴더이름"); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> memoFolder.rename("")) | ||
.isInstanceOf(MemoFolderException.class) | ||
.extracting("exceptionType") | ||
.isEqualTo(MemoFolderExceptionType.EMPTY_NAME); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters