From 169245064eab691f522139a9d58b45ffeabb4c33 Mon Sep 17 00:00:00 2001 From: seungyeop-lee Date: Mon, 22 Jul 2024 17:03:33 +0900 Subject: [PATCH 1/7] =?UTF-8?q?refactor:=20UserFactory=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/user/logic/UserLogic.java | 3 ++- .../dto/UserSignUpFromSocialCommand.java | 5 ++-- .../domain/user/model/DefaultUserFactory.java | 25 +++++++++++++++++++ .../server/api/domain/user/model/User.java | 18 ++++--------- .../api/domain/user/model/UserFactory.java | 8 ++++++ 5 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java create mode 100644 server/api/src/main/java/vook/server/api/domain/user/model/UserFactory.java diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java index 82b580ad..64e0706d 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java @@ -17,6 +17,7 @@ @RequiredArgsConstructor public class UserLogic { + private final UserFactory userFactory; private final UserRepository repository; private final SocialUserRepository socialUserRepository; private final UserInfoRepository userInfoRepository; @@ -28,7 +29,7 @@ public Optional findByProvider(@NotBlank String provider, @NotBlank public SocialUser signUpFromSocial(@Valid UserSignUpFromSocialCommand command) { User user = repository .findByEmail(command.email()) - .orElseGet(() -> repository.save(command.toNewUser())); + .orElseGet(() -> repository.save(command.toNewUser(userFactory))); SocialUser savedSocialUser = socialUserRepository.save(command.toSocialUser(user)); user.addSocialUser(savedSocialUser); diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java b/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java index adcab37e..968b282b 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java @@ -5,6 +5,7 @@ import lombok.Builder; import vook.server.api.domain.user.model.SocialUser; import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.UserFactory; @Builder public record UserSignUpFromSocialCommand( @@ -22,7 +23,7 @@ public SocialUser toSocialUser(User user) { return SocialUser.forNewOf(provider, providerUserId, user); } - public User toNewUser() { - return User.forSignUpFromSocialOf(email); + public User toNewUser(UserFactory userFactory) { + return userFactory.createForSignUpFromSocialOf(email); } } diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java new file mode 100644 index 00000000..6db93e7d --- /dev/null +++ b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java @@ -0,0 +1,25 @@ +package vook.server.api.domain.user.model; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotEmpty; +import lombok.RequiredArgsConstructor; +import vook.server.api.globalcommon.annotation.ModelFactory; + +import java.util.ArrayList; +import java.util.UUID; + +@ModelFactory +@RequiredArgsConstructor +public class DefaultUserFactory implements UserFactory { + + @Override + public User createForSignUpFromSocialOf(@NotEmpty @Email String email) { + return User.builder() + .uid(UUID.randomUUID().toString()) + .email(email) + .status(UserStatus.SOCIAL_LOGIN_COMPLETED) + .onboardingCompleted(false) + .socialUsers(new ArrayList<>()) + .build(); + } +} diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/User.java b/server/api/src/main/java/vook/server/api/domain/user/model/User.java index 7568b8b3..fe5d6b15 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/User.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/User.java @@ -1,17 +1,19 @@ package vook.server.api.domain.user.model; import jakarta.persistence.*; -import lombok.Getter; +import lombok.*; import vook.server.api.domain.user.exception.*; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import java.util.UUID; @Getter @Entity @Table(name = "users") +@Builder(access = AccessLevel.PACKAGE) +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PACKAGE) public class User { @Id @@ -38,23 +40,13 @@ public class User { private LocalDateTime withdrawnAt; + @Builder.Default @OneToMany(mappedBy = "user", fetch = FetchType.LAZY) private List socialUsers = new ArrayList<>(); @OneToOne(mappedBy = "user") private UserInfo userInfo; - public static User forSignUpFromSocialOf( - String email - ) { - User user = new User(); - user.uid = UUID.randomUUID().toString(); - user.email = email; - user.status = UserStatus.SOCIAL_LOGIN_COMPLETED; - user.onboardingCompleted = false; - return user; - } - public void addSocialUser(SocialUser socialUser) { socialUsers.add(socialUser); } diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/UserFactory.java new file mode 100644 index 00000000..938c98f4 --- /dev/null +++ b/server/api/src/main/java/vook/server/api/domain/user/model/UserFactory.java @@ -0,0 +1,8 @@ +package vook.server.api.domain.user.model; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotEmpty; + +public interface UserFactory { + User createForSignUpFromSocialOf(@NotEmpty @Email String email); +} From 60cac6e1cd607b65721dac961eb6f4361da49346 Mon Sep 17 00:00:00 2001 From: seungyeop-lee Date: Mon, 22 Jul 2024 17:12:43 +0900 Subject: [PATCH 2/7] =?UTF-8?q?refactor:=20SocialUserFactory=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/user/logic/UserLogic.java | 9 +++---- .../dto/UserSignUpFromSocialCommand.java | 14 ++++------- .../user/model/DefaultSocialUserFactory.java | 25 +++++++++++++++++++ .../domain/user/model/DefaultUserFactory.java | 2 -- .../api/domain/user/model/SocialUser.java | 17 +++---------- .../domain/user/model/SocialUserFactory.java | 13 ++++++++++ 6 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 server/api/src/main/java/vook/server/api/domain/user/model/DefaultSocialUserFactory.java create mode 100644 server/api/src/main/java/vook/server/api/domain/user/model/SocialUserFactory.java diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java index 64e0706d..8ad7d4aa 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java @@ -2,6 +2,7 @@ import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import lombok.RequiredArgsConstructor; import vook.server.api.domain.user.exception.UserNotFoundException; @@ -18,6 +19,7 @@ public class UserLogic { private final UserFactory userFactory; + private final SocialUserFactory socialUserFactory; private final UserRepository repository; private final SocialUserRepository socialUserRepository; private final UserInfoRepository userInfoRepository; @@ -26,15 +28,12 @@ public Optional findByProvider(@NotBlank String provider, @NotBlank return socialUserRepository.findByProviderAndProviderUserId(provider, providerUserId); } - public SocialUser signUpFromSocial(@Valid UserSignUpFromSocialCommand command) { + public SocialUser signUpFromSocial(@NotNull @Valid UserSignUpFromSocialCommand command) { User user = repository .findByEmail(command.email()) .orElseGet(() -> repository.save(command.toNewUser(userFactory))); - SocialUser savedSocialUser = socialUserRepository.save(command.toSocialUser(user)); - user.addSocialUser(savedSocialUser); - - return savedSocialUser; + return socialUserRepository.save(command.toSocialUser(socialUserFactory, user)); } public User getByUid(@NotBlank String uid) { diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java b/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java index 968b282b..44d39d23 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java @@ -1,29 +1,25 @@ package vook.server.api.domain.user.logic.dto; import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotBlank; import lombok.Builder; import vook.server.api.domain.user.model.SocialUser; +import vook.server.api.domain.user.model.SocialUserFactory; import vook.server.api.domain.user.model.User; import vook.server.api.domain.user.model.UserFactory; @Builder public record UserSignUpFromSocialCommand( - @NotBlank String provider, - - @NotBlank String providerUserId, @Email - @NotBlank String email ) { - public SocialUser toSocialUser(User user) { - return SocialUser.forNewOf(provider, providerUserId, user); + public User toNewUser(UserFactory factory) { + return factory.createForSignUpFromSocialOf(email); } - public User toNewUser(UserFactory userFactory) { - return userFactory.createForSignUpFromSocialOf(email); + public SocialUser toSocialUser(SocialUserFactory factory, User user) { + return factory.createForNewOf(provider, providerUserId, user); } } diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultSocialUserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultSocialUserFactory.java new file mode 100644 index 00000000..fc7a0d28 --- /dev/null +++ b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultSocialUserFactory.java @@ -0,0 +1,25 @@ +package vook.server.api.domain.user.model; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import vook.server.api.globalcommon.annotation.ModelFactory; + +@ModelFactory +public class DefaultSocialUserFactory implements SocialUserFactory { + + @Override + public SocialUser createForNewOf( + @NotEmpty String provider, + @NotEmpty String providerUserId, + @NotNull User user + ) { + SocialUser socialUser = SocialUser.builder() + .provider(provider) + .providerUserId(providerUserId) + .user(user) + .build(); + + user.addSocialUser(socialUser); + return socialUser; + } +} diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java index 6db93e7d..a269f62b 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java @@ -2,14 +2,12 @@ import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotEmpty; -import lombok.RequiredArgsConstructor; import vook.server.api.globalcommon.annotation.ModelFactory; import java.util.ArrayList; import java.util.UUID; @ModelFactory -@RequiredArgsConstructor public class DefaultUserFactory implements UserFactory { @Override diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUser.java b/server/api/src/main/java/vook/server/api/domain/user/model/SocialUser.java index 821e6bb1..373657b4 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUser.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/SocialUser.java @@ -1,7 +1,7 @@ package vook.server.api.domain.user.model; import jakarta.persistence.*; -import lombok.Getter; +import lombok.*; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -11,6 +11,9 @@ @Entity @Table(name = "social_user") @EntityListeners(AuditingEntityListener.class) +@Builder(access = AccessLevel.PACKAGE) +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PACKAGE) public class SocialUser { @Id @@ -28,16 +31,4 @@ public class SocialUser { @ManyToOne @JoinColumn(name = "user_id") private User user; - - public static SocialUser forNewOf( - String provider, - String providerUserId, - User user - ) { - SocialUser socialUser = new SocialUser(); - socialUser.provider = provider; - socialUser.providerUserId = providerUserId; - socialUser.user = user; - return socialUser; - } } diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/SocialUserFactory.java new file mode 100644 index 00000000..fbb20839 --- /dev/null +++ b/server/api/src/main/java/vook/server/api/domain/user/model/SocialUserFactory.java @@ -0,0 +1,13 @@ +package vook.server.api.domain.user.model; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; + +public interface SocialUserFactory { + + SocialUser createForNewOf( + @NotEmpty String provider, + @NotEmpty String providerUserId, + @NotNull User user + ); +} From aff289842cc1cfe5652da5bbec3cefbba8e47560 Mon Sep 17 00:00:00 2001 From: seungyeop-lee Date: Mon, 22 Jul 2024 17:22:29 +0900 Subject: [PATCH 3/7] =?UTF-8?q?refactor:=20UserInfoFactory=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/user/logic/UserLogic.java | 13 +++++---- .../user/model/DefaultUserInfoFactory.java | 27 +++++++++++++++++++ .../api/domain/user/model/UserInfo.java | 17 +++--------- .../domain/user/model/UserInfoFactory.java | 13 +++++++++ 4 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserInfoFactory.java create mode 100644 server/api/src/main/java/vook/server/api/domain/user/model/UserInfoFactory.java diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java index 8ad7d4aa..886999ad 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java @@ -20,6 +20,7 @@ public class UserLogic { private final UserFactory userFactory; private final SocialUserFactory socialUserFactory; + private final UserInfoFactory userInfoFactory; private final UserRepository repository; private final SocialUserRepository socialUserRepository; private final UserInfoRepository userInfoRepository; @@ -42,14 +43,12 @@ public User getByUid(@NotBlank String uid) { public void register(@Valid UserRegisterCommand command) { User user = getUserByUid(command.userUid()); - user.validateRegisterProcessReady(); - - UserInfo userInfo = userInfoRepository.save(UserInfo.forRegisterOf( + UserInfo userInfo = userInfoFactory.createForRegisterOf( command.nickname(), - user, - command.marketingEmailOptIn() - )); - user.register(userInfo); + command.marketingEmailOptIn(), + user + ); + userInfoRepository.save(userInfo); } public void onboarding(@Valid UserOnboardingCommand command) { diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserInfoFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserInfoFactory.java new file mode 100644 index 00000000..41cf9635 --- /dev/null +++ b/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserInfoFactory.java @@ -0,0 +1,27 @@ +package vook.server.api.domain.user.model; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import vook.server.api.globalcommon.annotation.ModelFactory; + +@ModelFactory +public class DefaultUserInfoFactory implements UserInfoFactory { + + @Override + public UserInfo createForRegisterOf( + @NotEmpty String nickname, + @NotNull Boolean marketingEmailOptIn, + @NotNull User user + ) { + user.validateRegisterProcessReady(); + + UserInfo userInfo = UserInfo.builder() + .nickname(nickname) + .marketingEmailOptIn(marketingEmailOptIn) + .user(user) + .build(); + user.register(userInfo); + + return userInfo; + } +} diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfo.java b/server/api/src/main/java/vook/server/api/domain/user/model/UserInfo.java index becef057..2d5babb4 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfo.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/UserInfo.java @@ -1,11 +1,14 @@ package vook.server.api.domain.user.model; import jakarta.persistence.*; -import lombok.Getter; +import lombok.*; @Getter @Entity @Table(name = "user_info") +@Builder(access = AccessLevel.PACKAGE) +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PACKAGE) public class UserInfo { @Id @@ -29,18 +32,6 @@ public class UserInfo { @JoinColumn(name = "user_id") private User user; - public static UserInfo forRegisterOf( - String nickname, - User user, - Boolean marketingEmailOptIn - ) { - UserInfo result = new UserInfo(); - result.nickname = nickname; - result.user = user; - result.marketingEmailOptIn = marketingEmailOptIn; - return result; - } - public void addOnboardingInfo(Funnel funnel, Job job) { this.funnel = funnel; this.job = job; diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfoFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/UserInfoFactory.java new file mode 100644 index 00000000..62c81279 --- /dev/null +++ b/server/api/src/main/java/vook/server/api/domain/user/model/UserInfoFactory.java @@ -0,0 +1,13 @@ +package vook.server.api.domain.user.model; + +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; + +public interface UserInfoFactory { + + UserInfo createForRegisterOf( + @NotEmpty String nickname, + @NotNull Boolean marketingEmailOptIn, + @NotNull User user + ); +} From 88b59d13541453b1e98dab1384740c8d29cc0bb5 Mon Sep 17 00:00:00 2001 From: seungyeop-lee Date: Mon, 22 Jul 2024 17:33:40 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactory:=20User=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80=EC=82=AC=EB=A5=BC=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EB=82=B4=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/api/domain/user/logic/UserLogic.java | 14 +++----------- .../vook/server/api/domain/user/model/User.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java index 886999ad..0b7d0c48 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java @@ -41,7 +41,7 @@ public User getByUid(@NotBlank String uid) { return getUserByUid(uid); } - public void register(@Valid UserRegisterCommand command) { + public void register(@NotNull @Valid UserRegisterCommand command) { User user = getUserByUid(command.userUid()); UserInfo userInfo = userInfoFactory.createForRegisterOf( command.nickname(), @@ -51,10 +51,8 @@ public void register(@Valid UserRegisterCommand command) { userInfoRepository.save(userInfo); } - public void onboarding(@Valid UserOnboardingCommand command) { + public void onboarding(@NotNull @Valid UserOnboardingCommand command) { User user = getUserByUid(command.userUid()); - user.validateOnboardingProcessReady(); - user.onboarding(command.funnel(), command.job()); } @@ -63,22 +61,16 @@ public void updateInfo( @NotBlank @Size(min = 1, max = 10) String nickname ) { User user = getUserByUid(uid); - user.validateRegisterProcessCompleted(); user.update(nickname); } public void withdraw(@NotBlank String uid) { User user = getUserByUid(uid); - if (user.getStatus() == UserStatus.WITHDRAWN) { - return; - } user.withdraw(); } - public void reRegister(UserRegisterCommand command) { + public void reRegister(@NotNull @Valid UserRegisterCommand command) { User user = getUserByUid(command.userUid()); - user.validateReRegisterProcessReady(); - user.reRegister(command.nickname(), command.marketingEmailOptIn()); } diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/User.java b/server/api/src/main/java/vook/server/api/domain/user/model/User.java index fe5d6b15..4fe7f21b 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/User.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/User.java @@ -58,22 +58,32 @@ public void register(UserInfo userInfo) { } public void onboarding(Funnel funnel, Job job) { + validateOnboardingProcessReady(); + this.onboardingCompleted = true; this.userInfo.addOnboardingInfo(funnel, job); this.onboardingCompletedAt = LocalDateTime.now(); } public void update(String nickname) { + validateRegisterProcessCompleted(); + this.userInfo.update(nickname); this.lastUpdatedAt = LocalDateTime.now(); } public void withdraw() { + if (this.status == UserStatus.WITHDRAWN) { + return; + } + this.status = UserStatus.WITHDRAWN; this.withdrawnAt = LocalDateTime.now(); } public void reRegister(String nickname, Boolean marketingEmailOptIn) { + validateReRegisterProcessReady(); + this.status = UserStatus.REGISTERED; this.onboardingCompleted = false; this.userInfo.reRegister(nickname, marketingEmailOptIn); From 83ac2a72b4886b94f62c96d203538134ed1e53eb Mon Sep 17 00:00:00 2001 From: seungyeop-lee Date: Mon, 22 Jul 2024 17:39:00 +0900 Subject: [PATCH 5/7] =?UTF-8?q?refactor:=20domain/user=20package=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=B0=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vook/server/api/devhelper/app/InitService.java | 6 +++--- .../server/api/domain/user/logic/UserLogic.java | 13 +++++++++---- .../logic/{dto => }/UserOnboardingCommand.java | 6 +++--- .../user/logic/{dto => }/UserRegisterCommand.java | 2 +- .../{dto => }/UserSignUpFromSocialCommand.java | 10 +++++----- .../DefaultSocialUserFactory.java | 3 ++- .../user/model/{ => social_user}/SocialUser.java | 3 ++- .../model/{ => social_user}/SocialUserFactory.java | 5 +++-- .../{ => social_user}/SocialUserRepository.java | 2 +- .../user/model/{ => user}/DefaultUserFactory.java | 2 +- .../api/domain/user/model/{ => user}/User.java | 6 +++++- .../domain/user/model/{ => user}/UserFactory.java | 2 +- .../user/model/{ => user}/UserRepository.java | 2 +- .../domain/user/model/{ => user}/UserStatus.java | 2 +- .../{ => user_info}/DefaultUserInfoFactory.java | 3 ++- .../domain/user/model/{ => user_info}/Funnel.java | 2 +- .../api/domain/user/model/{ => user_info}/Job.java | 2 +- .../user/model/{ => user_info}/UserInfo.java | 3 ++- .../model/{ => user_info}/UserInfoFactory.java | 3 ++- .../model/{ => user_info}/UserInfoRepository.java | 2 +- .../api/web/common/auth/data/VookLoginUser.java | 2 +- .../common/auth/oauth2/VookOAuth2UserService.java | 4 ++-- .../server/api/web/user/UserRestController.java | 2 +- .../api/web/user/reqres/UserInfoResponse.java | 4 ++-- .../api/web/user/reqres/UserOnboardingRequest.java | 4 ++-- .../api/web/user/reqres/UserRegisterRequest.java | 2 +- .../web/user/usecase/OnboardingUserUseCase.java | 6 +++--- .../api/domain/user/logic/UserLogicTest.java | 11 ++++------- .../vocabulary/logic/term/TermLogicTest.java | 2 +- .../logic/vocabulary/VocabularyLogicTest.java | 2 +- .../api/testhelper/creator/TestUserCreator.java | 14 +++++++------- .../testhelper/creator/TestVocabularyCreator.java | 2 +- .../web/term/usecase/CreateTermUseCaseTest.java | 2 +- .../web/term/usecase/RetrieveTermUseCaseTest.java | 2 +- .../web/term/usecase/SearchTermUseCaseTest.java | 2 +- .../web/term/usecase/UpdateTermUseCaseTest.java | 2 +- .../user/usecase/OnboardingUserUseCaseTest.java | 6 +++--- .../web/user/usecase/WithdrawUserUseCaseTest.java | 4 ++-- .../usecase/CreateVocabularyUseCaseTest.java | 2 +- .../usecase/DeleteVocabularyUseCaseTest.java | 2 +- .../usecase/RetrieveVocabularyUseCaseTest.java | 2 +- .../usecase/UpdateVocabularyUseCaseTest.java | 2 +- 42 files changed, 86 insertions(+), 74 deletions(-) rename server/api/src/main/java/vook/server/api/domain/user/logic/{dto => }/UserOnboardingCommand.java (56%) rename server/api/src/main/java/vook/server/api/domain/user/logic/{dto => }/UserRegisterCommand.java (89%) rename server/api/src/main/java/vook/server/api/domain/user/logic/{dto => }/UserSignUpFromSocialCommand.java (62%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => social_user}/DefaultSocialUserFactory.java (86%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => social_user}/SocialUser.java (87%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => social_user}/SocialUserFactory.java (72%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => social_user}/SocialUserRepository.java (83%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user}/DefaultUserFactory.java (93%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user}/User.java (92%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user}/UserFactory.java (80%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user}/UserRepository.java (88%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user}/UserStatus.java (78%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user_info}/DefaultUserInfoFactory.java (87%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user_info}/Funnel.java (83%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user_info}/Job.java (79%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user_info}/UserInfo.java (91%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user_info}/UserInfoFactory.java (73%) rename server/api/src/main/java/vook/server/api/domain/user/model/{ => user_info}/UserInfoRepository.java (72%) diff --git a/server/api/src/main/java/vook/server/api/devhelper/app/InitService.java b/server/api/src/main/java/vook/server/api/devhelper/app/InitService.java index f27e7b8d..68cc45bd 100644 --- a/server/api/src/main/java/vook/server/api/devhelper/app/InitService.java +++ b/server/api/src/main/java/vook/server/api/devhelper/app/InitService.java @@ -11,9 +11,9 @@ import vook.server.api.domain.template_vocabulary.model.TemplateTermRepository; import vook.server.api.domain.template_vocabulary.model.TemplateVocabularyRepository; import vook.server.api.domain.template_vocabulary.model.TemplateVocabularyType; -import vook.server.api.domain.user.model.SocialUserRepository; -import vook.server.api.domain.user.model.UserInfoRepository; -import vook.server.api.domain.user.model.UserRepository; +import vook.server.api.domain.user.model.social_user.SocialUserRepository; +import vook.server.api.domain.user.model.user.UserRepository; +import vook.server.api.domain.user.model.user_info.UserInfoRepository; import vook.server.api.domain.vocabulary.model.term.TermRepository; import vook.server.api.infra.search.demo.MeilisearchDemoTermSearchService; import vook.server.api.infra.vocabulary.cache.UserVocabularyCacheRepository; diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java index 0b7d0c48..36b59c00 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserLogic.java @@ -6,10 +6,15 @@ import jakarta.validation.constraints.Size; import lombok.RequiredArgsConstructor; import vook.server.api.domain.user.exception.UserNotFoundException; -import vook.server.api.domain.user.logic.dto.UserOnboardingCommand; -import vook.server.api.domain.user.logic.dto.UserRegisterCommand; -import vook.server.api.domain.user.logic.dto.UserSignUpFromSocialCommand; -import vook.server.api.domain.user.model.*; +import vook.server.api.domain.user.model.social_user.SocialUser; +import vook.server.api.domain.user.model.social_user.SocialUserFactory; +import vook.server.api.domain.user.model.social_user.SocialUserRepository; +import vook.server.api.domain.user.model.user.User; +import vook.server.api.domain.user.model.user.UserFactory; +import vook.server.api.domain.user.model.user.UserRepository; +import vook.server.api.domain.user.model.user_info.UserInfo; +import vook.server.api.domain.user.model.user_info.UserInfoFactory; +import vook.server.api.domain.user.model.user_info.UserInfoRepository; import vook.server.api.globalcommon.annotation.DomainLogic; import java.util.Optional; diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserOnboardingCommand.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserOnboardingCommand.java similarity index 56% rename from server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserOnboardingCommand.java rename to server/api/src/main/java/vook/server/api/domain/user/logic/UserOnboardingCommand.java index e5f90ac2..490547ec 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserOnboardingCommand.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserOnboardingCommand.java @@ -1,9 +1,9 @@ -package vook.server.api.domain.user.logic.dto; +package vook.server.api.domain.user.logic; import jakarta.validation.constraints.NotBlank; import lombok.Builder; -import vook.server.api.domain.user.model.Funnel; -import vook.server.api.domain.user.model.Job; +import vook.server.api.domain.user.model.user_info.Funnel; +import vook.server.api.domain.user.model.user_info.Job; @Builder public record UserOnboardingCommand( diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserRegisterCommand.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserRegisterCommand.java similarity index 89% rename from server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserRegisterCommand.java rename to server/api/src/main/java/vook/server/api/domain/user/logic/UserRegisterCommand.java index 53b3ba71..a2702ec7 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserRegisterCommand.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserRegisterCommand.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.logic.dto; +package vook.server.api.domain.user.logic; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java b/server/api/src/main/java/vook/server/api/domain/user/logic/UserSignUpFromSocialCommand.java similarity index 62% rename from server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java rename to server/api/src/main/java/vook/server/api/domain/user/logic/UserSignUpFromSocialCommand.java index 44d39d23..c68c141a 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/logic/dto/UserSignUpFromSocialCommand.java +++ b/server/api/src/main/java/vook/server/api/domain/user/logic/UserSignUpFromSocialCommand.java @@ -1,11 +1,11 @@ -package vook.server.api.domain.user.logic.dto; +package vook.server.api.domain.user.logic; import jakarta.validation.constraints.Email; import lombok.Builder; -import vook.server.api.domain.user.model.SocialUser; -import vook.server.api.domain.user.model.SocialUserFactory; -import vook.server.api.domain.user.model.User; -import vook.server.api.domain.user.model.UserFactory; +import vook.server.api.domain.user.model.social_user.SocialUser; +import vook.server.api.domain.user.model.social_user.SocialUserFactory; +import vook.server.api.domain.user.model.user.User; +import vook.server.api.domain.user.model.user.UserFactory; @Builder public record UserSignUpFromSocialCommand( diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultSocialUserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/DefaultSocialUserFactory.java similarity index 86% rename from server/api/src/main/java/vook/server/api/domain/user/model/DefaultSocialUserFactory.java rename to server/api/src/main/java/vook/server/api/domain/user/model/social_user/DefaultSocialUserFactory.java index fc7a0d28..b48a308b 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultSocialUserFactory.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/DefaultSocialUserFactory.java @@ -1,7 +1,8 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.social_user; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import vook.server.api.domain.user.model.user.User; import vook.server.api.globalcommon.annotation.ModelFactory; @ModelFactory diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUser.java b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUser.java similarity index 87% rename from server/api/src/main/java/vook/server/api/domain/user/model/SocialUser.java rename to server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUser.java index 373657b4..bea87bd4 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUser.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUser.java @@ -1,9 +1,10 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.social_user; import jakarta.persistence.*; import lombok.*; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import vook.server.api.domain.user.model.user.User; import java.time.LocalDateTime; diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUserFactory.java similarity index 72% rename from server/api/src/main/java/vook/server/api/domain/user/model/SocialUserFactory.java rename to server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUserFactory.java index fbb20839..fc3c13b5 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUserFactory.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUserFactory.java @@ -1,10 +1,11 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.social_user; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import vook.server.api.domain.user.model.user.User; public interface SocialUserFactory { - + SocialUser createForNewOf( @NotEmpty String provider, @NotEmpty String providerUserId, diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUserRepository.java b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUserRepository.java similarity index 83% rename from server/api/src/main/java/vook/server/api/domain/user/model/SocialUserRepository.java rename to server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUserRepository.java index 6add4125..a3138c01 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/SocialUserRepository.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/social_user/SocialUserRepository.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.social_user; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/user/DefaultUserFactory.java similarity index 93% rename from server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user/DefaultUserFactory.java index a269f62b..ed9dfcf9 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserFactory.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user/DefaultUserFactory.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotEmpty; diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/User.java b/server/api/src/main/java/vook/server/api/domain/user/model/user/User.java similarity index 92% rename from server/api/src/main/java/vook/server/api/domain/user/model/User.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user/User.java index 4fe7f21b..2bdaad8f 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/User.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user/User.java @@ -1,8 +1,12 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user; import jakarta.persistence.*; import lombok.*; import vook.server.api.domain.user.exception.*; +import vook.server.api.domain.user.model.social_user.SocialUser; +import vook.server.api.domain.user.model.user_info.Funnel; +import vook.server.api.domain.user.model.user_info.Job; +import vook.server.api.domain.user.model.user_info.UserInfo; import java.time.LocalDateTime; import java.util.ArrayList; diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/user/UserFactory.java similarity index 80% rename from server/api/src/main/java/vook/server/api/domain/user/model/UserFactory.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user/UserFactory.java index 938c98f4..46b552ab 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/UserFactory.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user/UserFactory.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotEmpty; diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserRepository.java b/server/api/src/main/java/vook/server/api/domain/user/model/user/UserRepository.java similarity index 88% rename from server/api/src/main/java/vook/server/api/domain/user/model/UserRepository.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user/UserRepository.java index 70ef5916..40b34613 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/UserRepository.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user/UserRepository.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserStatus.java b/server/api/src/main/java/vook/server/api/domain/user/model/user/UserStatus.java similarity index 78% rename from server/api/src/main/java/vook/server/api/domain/user/model/UserStatus.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user/UserStatus.java index 4028716f..678a130f 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/UserStatus.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user/UserStatus.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user; public enum UserStatus { SOCIAL_LOGIN_COMPLETED, // 소셜로그인 완료됨 diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserInfoFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/DefaultUserInfoFactory.java similarity index 87% rename from server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserInfoFactory.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user_info/DefaultUserInfoFactory.java index 41cf9635..31df12b3 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/DefaultUserInfoFactory.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/DefaultUserInfoFactory.java @@ -1,7 +1,8 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user_info; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import vook.server.api.domain.user.model.user.User; import vook.server.api.globalcommon.annotation.ModelFactory; @ModelFactory diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/Funnel.java b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/Funnel.java similarity index 83% rename from server/api/src/main/java/vook/server/api/domain/user/model/Funnel.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user_info/Funnel.java index fdfe3ec1..4c822902 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/Funnel.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/Funnel.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user_info; public enum Funnel { //X diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/Job.java b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/Job.java similarity index 79% rename from server/api/src/main/java/vook/server/api/domain/user/model/Job.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user_info/Job.java index e069ad34..2a1a29de 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/Job.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/Job.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user_info; public enum Job { //기획자 diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfo.java b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfo.java similarity index 91% rename from server/api/src/main/java/vook/server/api/domain/user/model/UserInfo.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfo.java index 2d5babb4..12068a17 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfo.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfo.java @@ -1,7 +1,8 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user_info; import jakarta.persistence.*; import lombok.*; +import vook.server.api.domain.user.model.user.User; @Getter @Entity diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfoFactory.java b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfoFactory.java similarity index 73% rename from server/api/src/main/java/vook/server/api/domain/user/model/UserInfoFactory.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfoFactory.java index 62c81279..b6faad2f 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfoFactory.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfoFactory.java @@ -1,7 +1,8 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user_info; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; +import vook.server.api.domain.user.model.user.User; public interface UserInfoFactory { diff --git a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfoRepository.java b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfoRepository.java similarity index 72% rename from server/api/src/main/java/vook/server/api/domain/user/model/UserInfoRepository.java rename to server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfoRepository.java index 70de759e..c77c03f1 100644 --- a/server/api/src/main/java/vook/server/api/domain/user/model/UserInfoRepository.java +++ b/server/api/src/main/java/vook/server/api/domain/user/model/user_info/UserInfoRepository.java @@ -1,4 +1,4 @@ -package vook.server.api.domain.user.model; +package vook.server.api.domain.user.model.user_info; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/server/api/src/main/java/vook/server/api/web/common/auth/data/VookLoginUser.java b/server/api/src/main/java/vook/server/api/web/common/auth/data/VookLoginUser.java index dcf637a8..1a778b86 100644 --- a/server/api/src/main/java/vook/server/api/web/common/auth/data/VookLoginUser.java +++ b/server/api/src/main/java/vook/server/api/web/common/auth/data/VookLoginUser.java @@ -4,7 +4,7 @@ import lombok.ToString; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.oauth2.core.user.OAuth2User; -import vook.server.api.domain.user.model.SocialUser; +import vook.server.api.domain.user.model.social_user.SocialUser; import java.util.Collection; import java.util.List; diff --git a/server/api/src/main/java/vook/server/api/web/common/auth/oauth2/VookOAuth2UserService.java b/server/api/src/main/java/vook/server/api/web/common/auth/oauth2/VookOAuth2UserService.java index f1068c2b..dae1543f 100644 --- a/server/api/src/main/java/vook/server/api/web/common/auth/oauth2/VookOAuth2UserService.java +++ b/server/api/src/main/java/vook/server/api/web/common/auth/oauth2/VookOAuth2UserService.java @@ -9,8 +9,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import vook.server.api.domain.user.logic.UserLogic; -import vook.server.api.domain.user.logic.dto.UserSignUpFromSocialCommand; -import vook.server.api.domain.user.model.SocialUser; +import vook.server.api.domain.user.logic.UserSignUpFromSocialCommand; +import vook.server.api.domain.user.model.social_user.SocialUser; import vook.server.api.web.common.auth.data.VookLoginUser; @Slf4j diff --git a/server/api/src/main/java/vook/server/api/web/user/UserRestController.java b/server/api/src/main/java/vook/server/api/web/user/UserRestController.java index 642a7c7f..a604f3f0 100644 --- a/server/api/src/main/java/vook/server/api/web/user/UserRestController.java +++ b/server/api/src/main/java/vook/server/api/web/user/UserRestController.java @@ -6,7 +6,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import vook.server.api.domain.user.logic.UserLogic; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.web.common.auth.data.VookLoginUser; import vook.server.api.web.common.response.CommonApiResponse; import vook.server.api.web.user.reqres.UserInfoResponse; diff --git a/server/api/src/main/java/vook/server/api/web/user/reqres/UserInfoResponse.java b/server/api/src/main/java/vook/server/api/web/user/reqres/UserInfoResponse.java index e1664395..7082709c 100644 --- a/server/api/src/main/java/vook/server/api/web/user/reqres/UserInfoResponse.java +++ b/server/api/src/main/java/vook/server/api/web/user/reqres/UserInfoResponse.java @@ -1,8 +1,8 @@ package vook.server.api.web.user.reqres; import lombok.Builder; -import vook.server.api.domain.user.model.User; -import vook.server.api.domain.user.model.UserStatus; +import vook.server.api.domain.user.model.user.User; +import vook.server.api.domain.user.model.user.UserStatus; @Builder public record UserInfoResponse( diff --git a/server/api/src/main/java/vook/server/api/web/user/reqres/UserOnboardingRequest.java b/server/api/src/main/java/vook/server/api/web/user/reqres/UserOnboardingRequest.java index f0ee7015..e021c4d5 100644 --- a/server/api/src/main/java/vook/server/api/web/user/reqres/UserOnboardingRequest.java +++ b/server/api/src/main/java/vook/server/api/web/user/reqres/UserOnboardingRequest.java @@ -1,7 +1,7 @@ package vook.server.api.web.user.reqres; -import vook.server.api.domain.user.model.Funnel; -import vook.server.api.domain.user.model.Job; +import vook.server.api.domain.user.model.user_info.Funnel; +import vook.server.api.domain.user.model.user_info.Job; import vook.server.api.web.user.usecase.OnboardingUserUseCase; public record UserOnboardingRequest( diff --git a/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java b/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java index 2693cfc4..4c1b1564 100644 --- a/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java +++ b/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java @@ -5,7 +5,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; -import vook.server.api.domain.user.logic.dto.UserRegisterCommand; +import vook.server.api.domain.user.logic.UserRegisterCommand; public record UserRegisterRequest( @NotBlank diff --git a/server/api/src/main/java/vook/server/api/web/user/usecase/OnboardingUserUseCase.java b/server/api/src/main/java/vook/server/api/web/user/usecase/OnboardingUserUseCase.java index 884346f9..f395ed47 100644 --- a/server/api/src/main/java/vook/server/api/web/user/usecase/OnboardingUserUseCase.java +++ b/server/api/src/main/java/vook/server/api/web/user/usecase/OnboardingUserUseCase.java @@ -5,9 +5,9 @@ import vook.server.api.domain.template_vocabulary.model.TemplateTerm; import vook.server.api.domain.template_vocabulary.model.TemplateVocabularyType; import vook.server.api.domain.user.logic.UserLogic; -import vook.server.api.domain.user.logic.dto.UserOnboardingCommand; -import vook.server.api.domain.user.model.Funnel; -import vook.server.api.domain.user.model.Job; +import vook.server.api.domain.user.logic.UserOnboardingCommand; +import vook.server.api.domain.user.model.user_info.Funnel; +import vook.server.api.domain.user.model.user_info.Job; import vook.server.api.domain.vocabulary.logic.term.TermCreateAllCommand; import vook.server.api.domain.vocabulary.logic.term.TermLogic; import vook.server.api.domain.vocabulary.logic.vocabulary.VocabularyCreateCommand; diff --git a/server/api/src/test/java/vook/server/api/domain/user/logic/UserLogicTest.java b/server/api/src/test/java/vook/server/api/domain/user/logic/UserLogicTest.java index 1ed87e26..fc1a1af4 100644 --- a/server/api/src/test/java/vook/server/api/domain/user/logic/UserLogicTest.java +++ b/server/api/src/test/java/vook/server/api/domain/user/logic/UserLogicTest.java @@ -7,13 +7,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import vook.server.api.domain.user.exception.*; -import vook.server.api.domain.user.logic.dto.UserOnboardingCommand; -import vook.server.api.domain.user.logic.dto.UserRegisterCommand; -import vook.server.api.domain.user.logic.dto.UserSignUpFromSocialCommand; -import vook.server.api.domain.user.model.Funnel; -import vook.server.api.domain.user.model.Job; -import vook.server.api.domain.user.model.User; -import vook.server.api.domain.user.model.UserStatus; +import vook.server.api.domain.user.model.user.User; +import vook.server.api.domain.user.model.user.UserStatus; +import vook.server.api.domain.user.model.user_info.Funnel; +import vook.server.api.domain.user.model.user_info.Job; import vook.server.api.globalcommon.exception.ParameterValidateException; import vook.server.api.testhelper.IntegrationTestBase; import vook.server.api.testhelper.creator.TestUserCreator; diff --git a/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/term/TermLogicTest.java b/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/term/TermLogicTest.java index 6d7faf0d..dbe06bfc 100644 --- a/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/term/TermLogicTest.java +++ b/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/term/TermLogicTest.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.exception.TermNotFoundException; import vook.server.api.domain.vocabulary.model.term.Term; import vook.server.api.domain.vocabulary.model.term.TermRepository; diff --git a/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/vocabulary/VocabularyLogicTest.java b/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/vocabulary/VocabularyLogicTest.java index cfdb5705..7fdcbbd0 100644 --- a/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/vocabulary/VocabularyLogicTest.java +++ b/server/api/src/test/java/vook/server/api/domain/vocabulary/logic/vocabulary/VocabularyLogicTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.exception.VocabularyNotFoundException; import vook.server.api.domain.vocabulary.model.term.Term; import vook.server.api.domain.vocabulary.model.term.TermRepository; diff --git a/server/api/src/test/java/vook/server/api/testhelper/creator/TestUserCreator.java b/server/api/src/test/java/vook/server/api/testhelper/creator/TestUserCreator.java index 20eddf6d..9167de40 100644 --- a/server/api/src/test/java/vook/server/api/testhelper/creator/TestUserCreator.java +++ b/server/api/src/test/java/vook/server/api/testhelper/creator/TestUserCreator.java @@ -4,13 +4,13 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import vook.server.api.domain.user.logic.UserLogic; -import vook.server.api.domain.user.logic.dto.UserOnboardingCommand; -import vook.server.api.domain.user.logic.dto.UserRegisterCommand; -import vook.server.api.domain.user.logic.dto.UserSignUpFromSocialCommand; -import vook.server.api.domain.user.model.Funnel; -import vook.server.api.domain.user.model.Job; -import vook.server.api.domain.user.model.SocialUser; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.logic.UserOnboardingCommand; +import vook.server.api.domain.user.logic.UserRegisterCommand; +import vook.server.api.domain.user.logic.UserSignUpFromSocialCommand; +import vook.server.api.domain.user.model.social_user.SocialUser; +import vook.server.api.domain.user.model.user.User; +import vook.server.api.domain.user.model.user_info.Funnel; +import vook.server.api.domain.user.model.user_info.Job; import vook.server.api.web.common.auth.app.TokenService; import vook.server.api.web.common.auth.data.GeneratedToken; diff --git a/server/api/src/test/java/vook/server/api/testhelper/creator/TestVocabularyCreator.java b/server/api/src/test/java/vook/server/api/testhelper/creator/TestVocabularyCreator.java index 96b910a4..8efabe13 100644 --- a/server/api/src/test/java/vook/server/api/testhelper/creator/TestVocabularyCreator.java +++ b/server/api/src/test/java/vook/server/api/testhelper/creator/TestVocabularyCreator.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.logic.term.TermCreateAllCommand; import vook.server.api.domain.vocabulary.logic.term.TermCreateCommand; import vook.server.api.domain.vocabulary.logic.term.TermLogic; diff --git a/server/api/src/test/java/vook/server/api/web/term/usecase/CreateTermUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/term/usecase/CreateTermUseCaseTest.java index 1931adbb..0092eb31 100644 --- a/server/api/src/test/java/vook/server/api/web/term/usecase/CreateTermUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/term/usecase/CreateTermUseCaseTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.TestFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.exception.TermLimitExceededException; import vook.server.api.domain.vocabulary.exception.VocabularyNotFoundException; import vook.server.api.domain.vocabulary.model.term.Term; diff --git a/server/api/src/test/java/vook/server/api/web/term/usecase/RetrieveTermUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/term/usecase/RetrieveTermUseCaseTest.java index bfaa13ad..e08258cc 100644 --- a/server/api/src/test/java/vook/server/api/web/term/usecase/RetrieveTermUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/term/usecase/RetrieveTermUseCaseTest.java @@ -8,7 +8,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.model.term.Term; import vook.server.api.domain.vocabulary.model.term.TermRepository; import vook.server.api.domain.vocabulary.model.vocabulary.Vocabulary; diff --git a/server/api/src/test/java/vook/server/api/web/term/usecase/SearchTermUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/term/usecase/SearchTermUseCaseTest.java index 426e8a92..96a35567 100644 --- a/server/api/src/test/java/vook/server/api/web/term/usecase/SearchTermUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/term/usecase/SearchTermUseCaseTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.model.vocabulary.Vocabulary; import vook.server.api.policy.VocabularyPolicy; import vook.server.api.testhelper.IntegrationTestBase; diff --git a/server/api/src/test/java/vook/server/api/web/term/usecase/UpdateTermUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/term/usecase/UpdateTermUseCaseTest.java index dd11da1e..1f57c48f 100644 --- a/server/api/src/test/java/vook/server/api/web/term/usecase/UpdateTermUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/term/usecase/UpdateTermUseCaseTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.exception.TermNotFoundException; import vook.server.api.domain.vocabulary.model.term.Term; import vook.server.api.domain.vocabulary.model.term.TermRepository; diff --git a/server/api/src/test/java/vook/server/api/web/user/usecase/OnboardingUserUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/user/usecase/OnboardingUserUseCaseTest.java index 92ce5999..9df401f0 100644 --- a/server/api/src/test/java/vook/server/api/web/user/usecase/OnboardingUserUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/user/usecase/OnboardingUserUseCaseTest.java @@ -5,9 +5,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import vook.server.api.domain.template_vocabulary.model.TemplateVocabularyType; -import vook.server.api.domain.user.model.Funnel; -import vook.server.api.domain.user.model.Job; -import vook.server.api.domain.user.model.UserRepository; +import vook.server.api.domain.user.model.user.UserRepository; +import vook.server.api.domain.user.model.user_info.Funnel; +import vook.server.api.domain.user.model.user_info.Job; import vook.server.api.domain.vocabulary.model.term.TermRepository; import vook.server.api.domain.vocabulary.model.vocabulary.UserUid; import vook.server.api.domain.vocabulary.model.vocabulary.VocabularyRepository; diff --git a/server/api/src/test/java/vook/server/api/web/user/usecase/WithdrawUserUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/user/usecase/WithdrawUserUseCaseTest.java index 78090417..54323815 100644 --- a/server/api/src/test/java/vook/server/api/web/user/usecase/WithdrawUserUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/user/usecase/WithdrawUserUseCaseTest.java @@ -4,8 +4,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.UserRepository; -import vook.server.api.domain.user.model.UserStatus; +import vook.server.api.domain.user.model.user.UserRepository; +import vook.server.api.domain.user.model.user.UserStatus; import vook.server.api.domain.vocabulary.model.term.TermRepository; import vook.server.api.domain.vocabulary.model.vocabulary.UserUid; import vook.server.api.domain.vocabulary.model.vocabulary.Vocabulary; diff --git a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/CreateVocabularyUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/CreateVocabularyUseCaseTest.java index 56519866..444c495f 100644 --- a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/CreateVocabularyUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/CreateVocabularyUseCaseTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.exception.VocabularyLimitExceededException; import vook.server.api.domain.vocabulary.model.vocabulary.UserUid; import vook.server.api.domain.vocabulary.model.vocabulary.Vocabulary; diff --git a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/DeleteVocabularyUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/DeleteVocabularyUseCaseTest.java index 2aa859e2..bd0f65be 100644 --- a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/DeleteVocabularyUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/DeleteVocabularyUseCaseTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.exception.VocabularyNotFoundException; import vook.server.api.domain.vocabulary.model.vocabulary.Vocabulary; import vook.server.api.domain.vocabulary.model.vocabulary.VocabularyRepository; diff --git a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/RetrieveVocabularyUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/RetrieveVocabularyUseCaseTest.java index 765b266b..f0424319 100644 --- a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/RetrieveVocabularyUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/RetrieveVocabularyUseCaseTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.model.vocabulary.Vocabulary; import vook.server.api.domain.vocabulary.model.vocabulary.VocabularyRepository; import vook.server.api.testhelper.IntegrationTestBase; diff --git a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/UpdateVocabularyUseCaseTest.java b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/UpdateVocabularyUseCaseTest.java index 81cff89c..8330b37f 100644 --- a/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/UpdateVocabularyUseCaseTest.java +++ b/server/api/src/test/java/vook/server/api/web/vocabulary/usecase/UpdateVocabularyUseCaseTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import vook.server.api.domain.user.model.User; +import vook.server.api.domain.user.model.user.User; import vook.server.api.domain.vocabulary.exception.VocabularyNotFoundException; import vook.server.api.domain.vocabulary.model.vocabulary.Vocabulary; import vook.server.api.domain.vocabulary.model.vocabulary.VocabularyRepository; From b6b0270d10bd99261d7a2156549cfbd5295d7189 Mon Sep 17 00:00:00 2001 From: seungyeop-lee Date: Mon, 22 Jul 2024 17:56:09 +0900 Subject: [PATCH 6/7] =?UTF-8?q?chore:=20user=20domain=20=EB=82=B4=20factor?= =?UTF-8?q?y=EC=9D=98=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../social_user/SocialUserFactoryTest.java | 70 +++++++++++++++++++ .../user/model/user/UserFactoryTest.java | 57 +++++++++++++++ .../model/user_info/UserInfoFactoryTest.java | 66 +++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 server/api/src/test/java/vook/server/api/domain/user/model/social_user/SocialUserFactoryTest.java create mode 100644 server/api/src/test/java/vook/server/api/domain/user/model/user/UserFactoryTest.java create mode 100644 server/api/src/test/java/vook/server/api/domain/user/model/user_info/UserInfoFactoryTest.java diff --git a/server/api/src/test/java/vook/server/api/domain/user/model/social_user/SocialUserFactoryTest.java b/server/api/src/test/java/vook/server/api/domain/user/model/social_user/SocialUserFactoryTest.java new file mode 100644 index 00000000..a37e34ff --- /dev/null +++ b/server/api/src/test/java/vook/server/api/domain/user/model/social_user/SocialUserFactoryTest.java @@ -0,0 +1,70 @@ +package vook.server.api.domain.user.model.social_user; + +import jakarta.validation.ConstraintViolationException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import vook.server.api.domain.user.model.user.User; + +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.*; + +@SpringBootTest(classes = DefaultSocialUserFactory.class) +@ContextConfiguration(classes = ValidationAutoConfiguration.class) +class SocialUserFactoryTest { + + @Autowired + SocialUserFactory factory; + + @Test + @DisplayName("소셜 유저 생성; 정상") + void createForNewOf() { + // given + User user = mock(User.class); + + // when + SocialUser socialUser = factory.createForNewOf("provider", "providerUserId", user); + + // then + assertThat(socialUser.getProvider()).isEqualTo("provider"); + assertThat(socialUser.getProviderUserId()).isEqualTo("providerUserId"); + assertThat(socialUser.getUser()).isEqualTo(user); + + verify(user, times(1)).addSocialUser(socialUser); + } + + @TestFactory + @DisplayName("소셜 유저 생성; 예외 - 소셜 유서 생성 시 유효성 검사 실패") + Stream createForNewOfFail() { + return Stream.of( + DynamicTest.dynamicTest("provider가 null", () -> { + assertThatThrownBy(() -> factory.createForNewOf(null, "providerUserId", new User())) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("provider가 빈 문자열", () -> { + assertThatThrownBy(() -> factory.createForNewOf("", "providerUserId", new User())) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("providerUserId가 null", () -> { + assertThatThrownBy(() -> factory.createForNewOf("provider", null, new User())) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("providerUserId가 빈 문자열", () -> { + assertThatThrownBy(() -> factory.createForNewOf("provider", "", new User())) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("user가 null", () -> { + assertThatThrownBy(() -> factory.createForNewOf("provider", "providerUserId", null)) + .isInstanceOf(ConstraintViolationException.class); + }) + ); + } +} diff --git a/server/api/src/test/java/vook/server/api/domain/user/model/user/UserFactoryTest.java b/server/api/src/test/java/vook/server/api/domain/user/model/user/UserFactoryTest.java new file mode 100644 index 00000000..e369d26f --- /dev/null +++ b/server/api/src/test/java/vook/server/api/domain/user/model/user/UserFactoryTest.java @@ -0,0 +1,57 @@ +package vook.server.api.domain.user.model.user; + +import jakarta.validation.ConstraintViolationException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; + +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +@SpringBootTest(classes = DefaultUserFactory.class) +@ContextConfiguration(classes = ValidationAutoConfiguration.class) +class UserFactoryTest { + + @Autowired + UserFactory factory; + + @Test + @DisplayName("유저 생성; 정상") + void createForSignUpFromSocialOf() { + // when + User user = factory.createForSignUpFromSocialOf("abc@example.com"); + + // then + assertThat(user.getUid()).isNotNull(); + assertThat(user.getEmail()).isEqualTo("abc@example.com"); + assertThat(user.getStatus()).isEqualTo(UserStatus.SOCIAL_LOGIN_COMPLETED); + assertThat(user.getOnboardingCompleted()).isFalse(); + assertThat(user.getSocialUsers()).isEmpty(); + } + + @TestFactory + @DisplayName("유저 생성; 예외 - 유저 생성 시 유효성 검사 실패") + Stream createForSignUpFromSocialOfFail() { + return Stream.of( + DynamicTest.dynamicTest("email이 null", () -> { + assertThatThrownBy(() -> factory.createForSignUpFromSocialOf(null)) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("email이 빈 문자열", () -> { + assertThatThrownBy(() -> factory.createForSignUpFromSocialOf("")) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("email이 이메일 형식이 아님", () -> { + assertThatThrownBy(() -> factory.createForSignUpFromSocialOf("abc")) + .isInstanceOf(ConstraintViolationException.class); + }) + ); + } +} diff --git a/server/api/src/test/java/vook/server/api/domain/user/model/user_info/UserInfoFactoryTest.java b/server/api/src/test/java/vook/server/api/domain/user/model/user_info/UserInfoFactoryTest.java new file mode 100644 index 00000000..3916a451 --- /dev/null +++ b/server/api/src/test/java/vook/server/api/domain/user/model/user_info/UserInfoFactoryTest.java @@ -0,0 +1,66 @@ +package vook.server.api.domain.user.model.user_info; + +import jakarta.validation.ConstraintViolationException; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import vook.server.api.domain.user.model.user.User; + +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.*; + +@SpringBootTest(classes = DefaultUserInfoFactory.class) +@ContextConfiguration(classes = ValidationAutoConfiguration.class) +class UserInfoFactoryTest { + + @Autowired + UserInfoFactory factory; + + @Test + @DisplayName("유저 정보 생성; 정상") + void createForRegisterOf() { + // given + User user = mock(User.class); + + // when + UserInfo userInfo = factory.createForRegisterOf("nickname", true, user); + + // then + assertThat(userInfo.getNickname()).isEqualTo("nickname"); + assertThat(userInfo.getMarketingEmailOptIn()).isTrue(); + assertThat(userInfo.getUser()).isEqualTo(user); + + verify(user, times(1)).validateRegisterProcessReady(); + } + + @TestFactory + @DisplayName("유저 정보 생성; 예외 - 유저 정보 생성 시 유효성 검사 실패") + Stream createForRegisterOfFail2() { + return Stream.of( + DynamicTest.dynamicTest("nickname이 null", () -> { + assertThatThrownBy(() -> factory.createForRegisterOf(null, true, mock(User.class))) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("nickname이 빈 문자열", () -> { + assertThatThrownBy(() -> factory.createForRegisterOf("", true, mock(User.class))) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("marketingEmailOptIn이 null", () -> { + assertThatThrownBy(() -> factory.createForRegisterOf("nickname", null, mock(User.class))) + .isInstanceOf(ConstraintViolationException.class); + }), + DynamicTest.dynamicTest("user가 null", () -> { + assertThatThrownBy(() -> factory.createForRegisterOf("nickname", true, null)) + .isInstanceOf(ConstraintViolationException.class); + }) + ); + } +} From 7d601fc90a7398f694d0ebc615c2e4108ae85b46 Mon Sep 17 00:00:00 2001 From: seungyeop-lee Date: Mon, 22 Jul 2024 18:37:02 +0900 Subject: [PATCH 7/7] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EC=9E=85=EB=A0=A5=20=EC=8B=9C=20=EC=95=9E?= =?UTF-8?q?=EB=92=A4=20=EA=B3=B5=EB=B0=B1=20=EB=AC=B8=EC=9E=90=20=EB=AC=B4?= =?UTF-8?q?=EC=8B=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20#166?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/vook/server/api/web/user/UserRestController.java | 2 +- .../vook/server/api/web/user/reqres/UserRegisterRequest.java | 4 +--- .../server/api/web/user/reqres/UserUpdateInfoRequest.java | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/server/api/src/main/java/vook/server/api/web/user/UserRestController.java b/server/api/src/main/java/vook/server/api/web/user/UserRestController.java index a604f3f0..9928faec 100644 --- a/server/api/src/main/java/vook/server/api/web/user/UserRestController.java +++ b/server/api/src/main/java/vook/server/api/web/user/UserRestController.java @@ -62,7 +62,7 @@ public CommonApiResponse updateInfo( @AuthenticationPrincipal VookLoginUser loginUser, @Validated @RequestBody UserUpdateInfoRequest request ) { - userLogic.updateInfo(loginUser.getUid(), request.nickname()); + userLogic.updateInfo(loginUser.getUid(), request.nickname().trim()); return CommonApiResponse.ok(); } diff --git a/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java b/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java index 4c1b1564..83c590d8 100644 --- a/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java +++ b/server/api/src/main/java/vook/server/api/web/user/reqres/UserRegisterRequest.java @@ -4,12 +4,10 @@ import jakarta.validation.constraints.AssertTrue; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; import vook.server.api.domain.user.logic.UserRegisterCommand; public record UserRegisterRequest( @NotBlank - @Size(min = 1, max = 10) String nickname, @NotNull @@ -23,7 +21,7 @@ public record UserRegisterRequest( public UserRegisterCommand toCommand(String userUid) { return UserRegisterCommand.builder() .userUid(userUid) - .nickname(nickname) + .nickname(nickname.trim()) .marketingEmailOptIn(marketingEmailOptIn) .build(); } diff --git a/server/api/src/main/java/vook/server/api/web/user/reqres/UserUpdateInfoRequest.java b/server/api/src/main/java/vook/server/api/web/user/reqres/UserUpdateInfoRequest.java index 16cb375d..af529ef9 100644 --- a/server/api/src/main/java/vook/server/api/web/user/reqres/UserUpdateInfoRequest.java +++ b/server/api/src/main/java/vook/server/api/web/user/reqres/UserUpdateInfoRequest.java @@ -1,11 +1,9 @@ package vook.server.api.web.user.reqres; import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Size; public record UserUpdateInfoRequest( @NotBlank - @Size(min = 1, max = 10) String nickname ) { }