-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: ShelterPassword 검증 테스트코드를 작성한다.
- Loading branch information
Showing
2 changed files
with
89 additions
and
1 deletion.
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
88 changes: 88 additions & 0 deletions
88
src/test/java/com/clova/anifriends/domain/shelter/wrapper/ShelterPasswordTest.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,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 ShelterPassword(password)); | ||
|
||
// then | ||
assertThat(exception).isInstanceOf(ShelterBadRequestException.class); | ||
} | ||
|
||
@Test | ||
@DisplayName("예외(ShelterNotFoundException): 비밀번호가 blank인 경우") | ||
void throwExceptionWhenPasswordIsBlank() { | ||
// given | ||
password = null; | ||
|
||
// when | ||
Exception exception = catchException( | ||
() -> new ShelterPassword(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); | ||
} | ||
} | ||
} |