-
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: 기본 이름이 중복되어 생성되는 문제 해결 * test: 테스트 커버리지 문제 해결 * refactor: 이름에 대한 vo 생성 * refactor: 메서드 네이밍 수정 * fix: substring을 통한 잘못된 파싱 수정 및 테스트 검증 추가
- Loading branch information
Showing
18 changed files
with
212 additions
and
63 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
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,37 @@ | ||
package com.backend.blooming.user.domain; | ||
|
||
import com.backend.blooming.user.domain.exception.MemberException; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Embeddable | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@EqualsAndHashCode | ||
@ToString | ||
public class Name { | ||
|
||
private static final int MAX_LENGTH = 50; | ||
|
||
@Column(name = "name", unique = true, length = MAX_LENGTH, nullable = false) | ||
private String value; | ||
|
||
public Name(final String value) { | ||
validateValue(value); | ||
this.value = value; | ||
} | ||
|
||
private void validateValue(final String value) { | ||
if (value == null || value.isEmpty()) { | ||
throw new MemberException.NullOrEmptyNameException(); | ||
} | ||
if (value.length() > MAX_LENGTH) { | ||
throw new MemberException.LongerThanMaximumNameLengthException(); | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import com.backend.blooming.authentication.infrastructure.oauth.dto.UserInformationDto; | ||
import com.backend.blooming.authentication.infrastructure.oauth.kakao.dto.KakaoUserInformationDto; | ||
import com.backend.blooming.user.domain.Email; | ||
import com.backend.blooming.user.domain.Name; | ||
import com.backend.blooming.user.domain.User; | ||
import com.backend.blooming.user.infrastructure.repository.UserRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
@@ -24,8 +25,13 @@ public class AuthenticationServiceTestFixture { | |
protected String 소셜_액세스_토큰 = "social_access_token"; | ||
protected UserInformationDto 첫_로그인_사용자_소셜_정보 = | ||
new KakaoUserInformationDto("12345", new KakaoUserInformationDto.KakaoAccount("[email protected]")); | ||
protected UserInformationDto oauthid가_50자를_초과하는_사용자_소셜_정보 = | ||
new KakaoUserInformationDto( | ||
"1234567890123456789012345678901234567890123456789012345", | ||
new KakaoUserInformationDto.KakaoAccount("[email protected]") | ||
); | ||
protected UserInformationDto 기존_사용자_소셜_정보 = | ||
new KakaoUserInformationDto("12346", new KakaoUserInformationDto.KakaoAccount("test2@email.com")); | ||
new KakaoUserInformationDto("12346", new KakaoUserInformationDto.KakaoAccount("test3@email.com")); | ||
protected String 유효한_refresh_token; | ||
protected String 존재하지_않는_사용자의_refresh_token; | ||
protected String 유효하지_않는_refresh_token = "Bearer invalid_refresh_token"; | ||
|
@@ -36,7 +42,7 @@ void setUpFixture() { | |
final User 기존_사용자 = User.builder() | ||
.oAuthType(oauth_타입) | ||
.oAuthId(기존_사용자_소셜_정보.oAuthId()) | ||
.name("기존 사용자") | ||
.name(new Name("기존 사용자")) | ||
.email(new Email(기존_사용자_소셜_정보.email())) | ||
.build(); | ||
|
||
|
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import com.backend.blooming.friend.domain.Friend; | ||
import com.backend.blooming.friend.infrastructure.repository.FriendRepository; | ||
import com.backend.blooming.user.domain.Email; | ||
import com.backend.blooming.user.domain.Name; | ||
import com.backend.blooming.user.domain.User; | ||
import com.backend.blooming.user.infrastructure.repository.UserRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
@@ -45,55 +46,55 @@ void setUpFixture() { | |
final User 사용자 = User.builder() | ||
.oAuthId("12345") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자1") | ||
.name(new Name("사용자1")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 친구_요청할_사용자 = User.builder() | ||
.oAuthId("12346") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자2") | ||
.name(new Name("사용자2")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 친구_요청을_보낸_사용자 = User.builder() | ||
.oAuthId("12347") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자3") | ||
.name(new Name("사용자3")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 이미_친구_요청을_받은_사용자 = User.builder() | ||
.oAuthId("12348") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자4") | ||
.name(new Name("사용자4")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 친구_요청을_받은_사용자2 = User.builder() | ||
.oAuthId("12349") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자5") | ||
.name(new Name("사용자5")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 친구_요청을_받은_사용자3 = User.builder() | ||
.oAuthId("12350") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자6") | ||
.name(new Name("사용자6")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 친구인_사용자1 = User.builder() | ||
.oAuthId("23456") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("친구1") | ||
.name(new Name("친구1")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 친구인_사용자2 = User.builder() | ||
.oAuthId("23457") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("친구2") | ||
.name(new Name("친구2")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
final User 친구인_사용자3 = User.builder() | ||
.oAuthId("23458") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("친구3") | ||
.name(new Name("친구3")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
userRepository.saveAll(List.of( | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import com.backend.blooming.authentication.infrastructure.oauth.OAuthType; | ||
import com.backend.blooming.user.domain.Email; | ||
import com.backend.blooming.user.domain.Name; | ||
import com.backend.blooming.user.domain.User; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
|
@@ -12,19 +13,19 @@ public class FriendTestFixture { | |
protected static User 친구_요청을_한_사용자 = User.builder() | ||
.oAuthId("12345") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자1") | ||
.name(new Name("사용자1")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
protected static User 친구_요청을_받은_사용자 = User.builder() | ||
.oAuthId("12346") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자2") | ||
.name(new Name("사용자2")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
protected static User 친구_요청과_상관없는_사용자 = User.builder() | ||
.oAuthId("12347") | ||
.oAuthType(OAuthType.KAKAO) | ||
.name("사용자3") | ||
.name(new Name("사용자3")) | ||
.email(new Email("[email protected]")) | ||
.build(); | ||
|
||
|
Oops, something went wrong.