diff --git a/src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterNameTest.java b/src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterNameTest.java index 070e8abeb..d69c3f984 100644 --- a/src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterNameTest.java +++ b/src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterNameTest.java @@ -11,7 +11,7 @@ class ShelterNameTest { @Nested - @DisplayName("VolunteerName 생성 시") + @DisplayName("ShelterName 생성 시") class newShelterNameTest { String name; diff --git a/src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterPasswordTest.java b/src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterPasswordTest.java new file mode 100644 index 000000000..d807b77e4 --- /dev/null +++ b/src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterPasswordTest.java @@ -0,0 +1,88 @@ +package com.clova.anifriends.domain.shelter.wrapper; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchException; + +import com.clova.anifriends.domain.shelter.exception.ShelterBadRequestException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +class ShelterPasswordTest { + + @Nested + @DisplayName("ShelterPassword 생성 시") + class newShelterPasswordTest { + + String password; + + @Test + @DisplayName("성공") + void newShelterPassword() { + // given + password = "asdfqwer123"; + + // when + ShelterPassword shelterPassword = new ShelterPassword(password); + + // then + assertThat(shelterPassword.getPassword()).isEqualTo(password); + } + + @Test + @DisplayName("예외(ShelterNotFoundException): 비밀번호가 null인 경우") + void throwExceptionWhenPasswordIsNull() { + // given + password = null; + + // when + Exception exception = catchException( + () -> new ShelterName(password)); + + // then + assertThat(exception).isInstanceOf(ShelterBadRequestException.class); + } + + @Test + @DisplayName("예외(ShelterNotFoundException): 비밀번호가 blank인 경우") + void throwExceptionWhenPasswordIsBlank() { + // given + password = null; + + // when + Exception exception = catchException( + () -> new ShelterName(password)); + + // then + assertThat(exception).isInstanceOf(ShelterBadRequestException.class); + } + + @Test + @DisplayName("예외(ShelterBadRequestException): 비밀번호가 6자 미만인 경우") + void throwExceptionWhenPasswordIsLessThanSix() { + // given + password = "asdf"; + + // when + Exception exception = catchException( + () -> new ShelterPassword(password)); + + // then + assertThat(exception).isInstanceOf(ShelterBadRequestException.class); + } + + @Test + @DisplayName("예외(ShelterBadRequestException): 비밀번호가 16자 초과인 경우") + void throwExceptionWhenPasswordIsOverThanSixteen() { + // given + password = "asdfqwer123asdfqwer123"; + + // when + Exception exception = catchException( + () -> new ShelterName(password)); + + // then + assertThat(exception).isInstanceOf(ShelterBadRequestException.class); + } + } +}