-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [fix] 추가정보 닉네임 2차 validation * [feat] 닉네임 관련 에러코드 추가 * [test] 추가정보 닉네임 Validation 단위테스트 추가 * [style] 미사용 패턴 제거 * [style] 컨벤션에 따른 닉네임 검증 메서드 네이밍 변경
- Loading branch information
Showing
3 changed files
with
76 additions
and
2 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
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 |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import com.dnd.gongmuin.member.domain.JobCategory; | ||
import com.dnd.gongmuin.member.domain.JobGroup; | ||
import com.dnd.gongmuin.member.domain.Member; | ||
import com.dnd.gongmuin.member.exception.MemberErrorCode; | ||
import com.dnd.gongmuin.member.repository.MemberRepository; | ||
import com.dnd.gongmuin.notification.repository.NotificationRepository; | ||
import com.dnd.gongmuin.post_interaction.repository.InteractionRepository; | ||
|
@@ -129,6 +130,63 @@ void signUp() { | |
); | ||
} | ||
|
||
@DisplayName("추가정보 업데이트할 때 닉네임이 중복이라면 예외가 발생한다.") | ||
@Test | ||
void throwExceptionWhenSignUpWithDuplicatedNickName() { | ||
// given | ||
AdditionalInfoRequest request = new AdditionalInfoRequest("[email protected]", "김신규", "공업", "일반기계"); | ||
MockHttpServletResponse mockResponse = new MockHttpServletResponse(); | ||
|
||
Member member = MemberFixture.member3(); | ||
|
||
given(memberRepository.findBySocialEmail(member.getSocialEmail())).willReturn( | ||
Optional.of(member)); | ||
given(memberRepository.existsByNickname(request.nickname())).willReturn(Boolean.TRUE); | ||
|
||
// when // then | ||
assertThatThrownBy(() -> authService.signUp(request, member.getSocialEmail(), mockResponse)) | ||
.isInstanceOf(RuntimeException.class) | ||
.hasMessage(MemberErrorCode.DUPLICATED_NICKNAME.getMessage()); | ||
} | ||
|
||
@DisplayName("추가정보 업데이트할 때 공백이 포함된 닉네임이라면 예외가 발생한다.") | ||
@Test | ||
void throwExceptionWhenSignUpWithWhiteSpaceNickName() { | ||
// given | ||
AdditionalInfoRequest request = new AdditionalInfoRequest("[email protected]", " 김신규", "공업", "일반기계"); | ||
MockHttpServletResponse mockResponse = new MockHttpServletResponse(); | ||
|
||
Member member = MemberFixture.member3(); | ||
|
||
given(memberRepository.findBySocialEmail(member.getSocialEmail())).willReturn( | ||
Optional.of(member)); | ||
given(memberRepository.existsByNickname(request.nickname())).willReturn(Boolean.FALSE); | ||
|
||
// when // then | ||
assertThatThrownBy(() -> authService.signUp(request, member.getSocialEmail(), mockResponse)) | ||
.isInstanceOf(RuntimeException.class) | ||
.hasMessage(MemberErrorCode.INVALID_NICKNAME.getMessage()); | ||
} | ||
|
||
@DisplayName("추가정보 업데이트할 때 유효하지 않은 닉네임이라면 예외가 발생한다.") | ||
@Test | ||
void throwExceptionWhenSignUpWithInvalidNickName() { | ||
// given | ||
AdditionalInfoRequest request = new AdditionalInfoRequest("[email protected]", "abcㄱㄴ123", "공업", "일반기계"); | ||
MockHttpServletResponse mockResponse = new MockHttpServletResponse(); | ||
|
||
Member member = MemberFixture.member3(); | ||
|
||
given(memberRepository.findBySocialEmail(member.getSocialEmail())).willReturn( | ||
Optional.of(member)); | ||
given(memberRepository.existsByNickname(request.nickname())).willReturn(Boolean.FALSE); | ||
|
||
// when // then | ||
assertThatThrownBy(() -> authService.signUp(request, member.getSocialEmail(), mockResponse)) | ||
.isInstanceOf(RuntimeException.class) | ||
.hasMessage(MemberErrorCode.INVALID_NICKNAME.getMessage()); | ||
} | ||
|
||
@DisplayName("로그인 회원은 로그아웃 할 수 있다.") | ||
@Test | ||
void logout() { | ||
|