From be4c0517f6cac42a70be2b5bc414375334dd35d3 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 20:21:22 +0900 Subject: [PATCH 01/15] =?UTF-8?q?fix=20:=20OAuth=20=EC=84=9C=EB=B2=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC,=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84,=20=ED=94=84=EB=A1=9C=ED=95=84=EC=82=AC?= =?UTF-8?q?=EC=A7=84=EB=A7=8C=20=EA=B0=96=EA=B3=A0=EC=98=A8=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/auth/dto/OAuthUserInfo.java | 4 --- .../auth/mapper/AuthApiMapper.java | 4 --- .../auth/mapper/OAuthAttributeMapper.java | 26 ++++--------------- .../auth/application/AuthService.java | 8 +----- .../auth/dto/request/UserLoginRequest.java | 4 --- .../boardsignal/user/domain/entity/User.java | 20 +++++--------- 6 files changed, 12 insertions(+), 54 deletions(-) diff --git a/api/src/main/java/com/civilwar/boardsignal/auth/dto/OAuthUserInfo.java b/api/src/main/java/com/civilwar/boardsignal/auth/dto/OAuthUserInfo.java index fa79df9c..d51f7381 100644 --- a/api/src/main/java/com/civilwar/boardsignal/auth/dto/OAuthUserInfo.java +++ b/api/src/main/java/com/civilwar/boardsignal/auth/dto/OAuthUserInfo.java @@ -2,12 +2,8 @@ public record OAuthUserInfo( String email, - String name, String nickname, String imageUrl, - String birthYear, - String ageRange, - String gender, String provider, String providerId ) { diff --git a/api/src/main/java/com/civilwar/boardsignal/auth/mapper/AuthApiMapper.java b/api/src/main/java/com/civilwar/boardsignal/auth/mapper/AuthApiMapper.java index eb72cd7a..e382661a 100644 --- a/api/src/main/java/com/civilwar/boardsignal/auth/mapper/AuthApiMapper.java +++ b/api/src/main/java/com/civilwar/boardsignal/auth/mapper/AuthApiMapper.java @@ -14,12 +14,8 @@ public final class AuthApiMapper { public static UserLoginRequest toUserLoginRequest(OAuthUserInfo oAuthUserInfo) { return new UserLoginRequest( oAuthUserInfo.email(), - oAuthUserInfo.name(), oAuthUserInfo.nickname(), oAuthUserInfo.imageUrl(), - oAuthUserInfo.birthYear(), - oAuthUserInfo.ageRange(), - oAuthUserInfo.gender(), oAuthUserInfo.provider(), oAuthUserInfo.providerId() ); diff --git a/api/src/main/java/com/civilwar/boardsignal/auth/mapper/OAuthAttributeMapper.java b/api/src/main/java/com/civilwar/boardsignal/auth/mapper/OAuthAttributeMapper.java index 895610a7..929cb291 100644 --- a/api/src/main/java/com/civilwar/boardsignal/auth/mapper/OAuthAttributeMapper.java +++ b/api/src/main/java/com/civilwar/boardsignal/auth/mapper/OAuthAttributeMapper.java @@ -30,22 +30,14 @@ private static OAuthUserInfo kakaoUserInfo(Map userAttributes, Map profile = (Map) kakaoAccount.get("profile"); String email = (String) kakaoAccount.get("email"); - String name = (String) kakaoAccount.get("name"); String nickName = (String) profile.get("nickname"); String imageUrl = (String) profile.get("profile_image_url"); - String birthYear = (String) kakaoAccount.get("birthyear"); - String ageRange = (String) kakaoAccount.get("age_range"); - String gender = (String) kakaoAccount.get("gender"); String providerId = userAttributes.get("id").toString(); return new OAuthUserInfo( email, - name, nickName, imageUrl, - birthYear, - ageRange, - gender, provider, providerId ); @@ -54,26 +46,18 @@ private static OAuthUserInfo kakaoUserInfo(Map userAttributes, private static OAuthUserInfo naverUserInfo(Map userAttributes, String provider) { - Map kakaoAccount = (Map) userAttributes + Map naverAccount = (Map) userAttributes .get("response"); - String email = kakaoAccount.get("email"); - String name = kakaoAccount.get("name"); - String nickName = kakaoAccount.get("nickname"); - String imageUrl = kakaoAccount.get("profile_image"); - String birthYear = kakaoAccount.get("birthyear"); - String ageRange = kakaoAccount.get("age"); - String gender = kakaoAccount.get("gender"); - String providerId = kakaoAccount.get("id"); + String email = naverAccount.get("email"); + String nickName = naverAccount.get("nickname"); + String imageUrl = naverAccount.get("profile_image"); + String providerId = naverAccount.get("id"); return new OAuthUserInfo( email, - name, nickName, imageUrl, - birthYear, - ageRange, - gender, provider, providerId ); diff --git a/core/src/main/java/com/civilwar/boardsignal/auth/application/AuthService.java b/core/src/main/java/com/civilwar/boardsignal/auth/application/AuthService.java index 9cb5cd37..81fbf6ac 100644 --- a/core/src/main/java/com/civilwar/boardsignal/auth/application/AuthService.java +++ b/core/src/main/java/com/civilwar/boardsignal/auth/application/AuthService.java @@ -7,8 +7,6 @@ import com.civilwar.boardsignal.auth.dto.response.UserLoginResponse; import com.civilwar.boardsignal.auth.dto.response.UserLogoutResponse; import com.civilwar.boardsignal.auth.mapper.AuthMapper; -import com.civilwar.boardsignal.user.domain.constants.AgeGroup; -import com.civilwar.boardsignal.user.domain.constants.Gender; import com.civilwar.boardsignal.user.domain.entity.User; import com.civilwar.boardsignal.user.domain.repository.UserRepository; import lombok.RequiredArgsConstructor; @@ -33,14 +31,10 @@ public UserLoginResponse login(UserLoginRequest userLoginRequest) { user = userRepository.save( User.of( userLoginRequest.email(), - userLoginRequest.name(), userLoginRequest.nickname(), userLoginRequest.provider(), userLoginRequest.providerId(), - userLoginRequest.imageUrl(), - Integer.parseInt(userLoginRequest.birthYear()), - AgeGroup.of(userLoginRequest.ageRange(), userLoginRequest.provider()), - Gender.of(userLoginRequest.gender(), userLoginRequest.provider()) + userLoginRequest.imageUrl() ) ); } diff --git a/core/src/main/java/com/civilwar/boardsignal/auth/dto/request/UserLoginRequest.java b/core/src/main/java/com/civilwar/boardsignal/auth/dto/request/UserLoginRequest.java index 3d33d801..4877cc53 100644 --- a/core/src/main/java/com/civilwar/boardsignal/auth/dto/request/UserLoginRequest.java +++ b/core/src/main/java/com/civilwar/boardsignal/auth/dto/request/UserLoginRequest.java @@ -2,12 +2,8 @@ public record UserLoginRequest( String email, - String name, String nickname, String imageUrl, - String birthYear, - String ageRange, - String gender, String provider, String providerId ) { diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java index 68885743..e215bd2d 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java @@ -96,17 +96,17 @@ public class User extends BaseEntity implements UserDetails { @Column(name = "USER_SIGNAL") private int signal; - @Builder(access = AccessLevel.PRIVATE) + @Builder(access = AccessLevel.PUBLIC) private User( @NonNull String email, - @NonNull String name, + String name, @NonNull String nickname, @NonNull String provider, @NonNull String providerId, @NonNull String profileImageUrl, - @NonNull int birth, - @NonNull AgeGroup ageGroup, - @NonNull Gender gender + int birth, + AgeGroup ageGroup, + Gender gender ) { this.email = email; this.name = name; @@ -125,25 +125,17 @@ private User( public static User of( String email, - String name, String nickname, String provider, String providerId, - String profileImageUrl, - int birth, - AgeGroup ageGroup, - Gender gender + String profileImageUrl ) { return User.builder() .email(email) - .name(name) .nickname(nickname) .provider(provider) .providerId(providerId) .profileImageUrl(profileImageUrl) - .birth(birth) - .ageGroup(ageGroup) - .gender(gender) .build(); } From 8c73f21b4eb6fe4cc6035d87edfe74fe70ba9d08 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 20:27:11 +0900 Subject: [PATCH 02/15] =?UTF-8?q?fix=20:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=ED=8F=BC=EC=97=90=EC=84=9C=20=EC=84=B1=EB=B3=84,?= =?UTF-8?q?=20=EC=B6=9C=EC=83=9D=EC=97=B0=EB=8F=84=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=EB=A5=BC=20=EC=B6=94=EA=B0=80=EB=A1=9C=20=EB=B0=9B=EB=8A=94?= =?UTF-8?q?=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/user/dto/request/ApiUserModifyRequest.java | 2 ++ .../com/civilwar/boardsignal/user/mapper/UserApiMapper.java | 2 ++ .../civilwar/boardsignal/user/application/UserService.java | 5 +++++ .../com/civilwar/boardsignal/user/domain/entity/User.java | 6 ++++++ .../boardsignal/user/dto/request/UserModifyRequest.java | 2 ++ 5 files changed, 17 insertions(+) diff --git a/api/src/main/java/com/civilwar/boardsignal/user/dto/request/ApiUserModifyRequest.java b/api/src/main/java/com/civilwar/boardsignal/user/dto/request/ApiUserModifyRequest.java index a77d5d98..566129e7 100644 --- a/api/src/main/java/com/civilwar/boardsignal/user/dto/request/ApiUserModifyRequest.java +++ b/api/src/main/java/com/civilwar/boardsignal/user/dto/request/ApiUserModifyRequest.java @@ -4,6 +4,8 @@ public record ApiUserModifyRequest( String nickName, + String gender, + int birth, String line, String station, List categories diff --git a/api/src/main/java/com/civilwar/boardsignal/user/mapper/UserApiMapper.java b/api/src/main/java/com/civilwar/boardsignal/user/mapper/UserApiMapper.java index cb4e2b7b..7ce03ac6 100644 --- a/api/src/main/java/com/civilwar/boardsignal/user/mapper/UserApiMapper.java +++ b/api/src/main/java/com/civilwar/boardsignal/user/mapper/UserApiMapper.java @@ -25,6 +25,8 @@ public static UserModifyRequest toUserModifyRequest(Long userId, userId, apiUserModifyRequest.nickName(), userCategories, + apiUserModifyRequest.gender(), + apiUserModifyRequest.birth(), apiUserModifyRequest.line(), apiUserModifyRequest.station(), image diff --git a/core/src/main/java/com/civilwar/boardsignal/user/application/UserService.java b/core/src/main/java/com/civilwar/boardsignal/user/application/UserService.java index 2b9ec913..fa603132 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/application/UserService.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/application/UserService.java @@ -5,6 +5,8 @@ import com.civilwar.boardsignal.common.exception.NotFoundException; import com.civilwar.boardsignal.image.domain.ImageRepository; import com.civilwar.boardsignal.room.domain.repository.RoomRepository; +import com.civilwar.boardsignal.user.domain.constants.AgeGroup; +import com.civilwar.boardsignal.user.domain.constants.Gender; import com.civilwar.boardsignal.user.domain.entity.User; import com.civilwar.boardsignal.user.domain.entity.UserCategory; import com.civilwar.boardsignal.user.domain.repository.UserRepository; @@ -50,6 +52,9 @@ public UserModifyResponse modifyUser(UserModifyRequest userModifyRequest) { findUser.updateUser( userModifyRequest.nickName(), userModifyRequest.categories(), + Gender.toGender(userModifyRequest.gender()), + userModifyRequest.birth(), + AgeGroup.convert(userModifyRequest.birth(), now.get()), userModifyRequest.line(), userModifyRequest.station(), profileImageUrl diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java index e215bd2d..0ac16856 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java @@ -142,11 +142,17 @@ public static User of( public void updateUser( String nickname, List categories, + Gender gender, + int birth, + AgeGroup ageGroup, String line, String station, String profileImageUrl ) { this.nickname = nickname; + this.gender = gender; + this.birth = birth; + this.ageGroup = ageGroup; this.line = line; this.station = station; this.userCategories.clear(); diff --git a/core/src/main/java/com/civilwar/boardsignal/user/dto/request/UserModifyRequest.java b/core/src/main/java/com/civilwar/boardsignal/user/dto/request/UserModifyRequest.java index c1d1878d..a7ba13a4 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/dto/request/UserModifyRequest.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/dto/request/UserModifyRequest.java @@ -9,6 +9,8 @@ public record UserModifyRequest( Long id, String nickName, List categories, + String gender, + int birth, String line, String station, MultipartFile image From 3968d9dea2aea3b941f16e7c3d851961f4a6306b Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 20:27:34 +0900 Subject: [PATCH 03/15] =?UTF-8?q?fix=20:=20=EC=B6=9C=EC=83=9D=EC=97=B0?= =?UTF-8?q?=EB=8F=84=EB=A5=BC=20=ED=86=B5=ED=95=B4=20=EC=97=B0=EB=A0=B9?= =?UTF-8?q?=EB=8C=80=EB=A5=BC=20=EA=B3=84=EC=82=B0=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/domain/constants/AgeGroup.java | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java index 2493e81e..228e9ff6 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java @@ -3,6 +3,7 @@ import static com.civilwar.boardsignal.user.exception.UserErrorCode.NOT_FOUND_AGE_GROUP; import com.civilwar.boardsignal.common.exception.NotFoundException; +import java.time.LocalDateTime; import java.util.Arrays; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -11,21 +12,23 @@ @RequiredArgsConstructor public enum AgeGroup { - UNDER_CHILDREN("1~9", "1-9", "미취학 아동"), - CHILDREN("10~14", "10-14", "어린이"), - TEENAGER("14~19", "14-19", "청소년"), - TWENTY("20~29", "20-29", "20대"), - THIRTY("30~39", "30-39", "30대"), - FORTY("40~49", "40-49", "40대"), - FIFTY("50~59", "50-59", "50대"), - SIXTY("60~69", "60-69", "60대"), - SEVENTY("70~79", "70-79", "70대"), - EIGHTY("80~89", "80-89", "80대"), - NINETY("90~", "90-", "90이상"); + UNKNOWN("0", "0", "알 ㅅ 없음", 0), + UNDER_CHILDREN("1~9", "1-9", "미취학 아동", 9), + CHILDREN("10~14", "10-14", "어린이", 14), + TEENAGER("14~19", "14-19", "청소년", 19), + TWENTY("20~29", "20-29", "20대", 29), + THIRTY("30~39", "30-39", "30대", 39), + FORTY("40~49", "40-49", "40대",49), + FIFTY("50~59", "50-59", "50대", 59), + SIXTY("60~69", "60-69", "60대", 69), + SEVENTY("70~79", "70-79", "70대", 79), + EIGHTY("80~89", "80-89", "80대", 89), + NINETY("90~", "90-", "90이상", 100); private final String kakaoType; private final String naverType; private final String description; + private final int maxAge; public static AgeGroup of(String input, String provider) { return Arrays.stream(values()) @@ -41,4 +44,18 @@ private boolean isEqual(String input, String provider) { return input.equalsIgnoreCase(this.naverType); } } + + public static AgeGroup convert(int birthYear, LocalDateTime now) { + AgeGroup userAgeGroup = UNKNOWN; + int age = now.getYear()-birthYear+1; + + for (AgeGroup a : values()) { + //현재 연령대의 사용자의 나이가 포함된다면 + if (a.getMaxAge()>=age) { + userAgeGroup = a; + } + } + return userAgeGroup; + + } } From c519f052e4ad56609e527c8832e83b86ac47503b Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 20:36:54 +0900 Subject: [PATCH 04/15] =?UTF-8?q?fix=20:=20User=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9E=90=20public=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/civilwar/boardsignal/user/domain/entity/User.java | 2 +- .../java/com/civilwar/boardsignal/user/UserFixture.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java index 0ac16856..a7ef3843 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java @@ -97,7 +97,7 @@ public class User extends BaseEntity implements UserDetails { private int signal; @Builder(access = AccessLevel.PUBLIC) - private User( + public User( @NonNull String email, String name, @NonNull String nickname, diff --git a/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java b/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java index 294b7ea2..61bba41a 100644 --- a/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java +++ b/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java @@ -14,7 +14,7 @@ public class UserFixture { public static User getUserFixture(String providerId, String imageUrl) { String provider = OAuthProvider.KAKAO.getType(); - return User.of( + return new User( "abc1234@gmail.com", "최인준", "injuning", @@ -30,7 +30,7 @@ public static User getUserFixture(String providerId, String imageUrl) { public static User getUserFixture2(String providerId, String imageUrl) { String provider = OAuthProvider.KAKAO.getType(); - return User.of( + return new User( "abc12345678@naver.com", "김강훈", "macbook", From be9629e971d440bfa057e4948380da860870e9bf Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 20:37:56 +0900 Subject: [PATCH 05/15] =?UTF-8?q?fix=20:=20service=20test=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/auth/application/AuthServiceTest.java | 8 -------- .../boardsignal/user/application/UserServiceTest.java | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java b/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java index 7c874c01..a09220d7 100644 --- a/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java +++ b/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java @@ -48,11 +48,7 @@ void loginTest1() { UserLoginRequest userLoginRequest = new UserLoginRequest( "abc1234@gmail.com", "최인준", - "injuning", "testURL", - String.valueOf(2000), - AgeGroup.TWENTY.getKakaoType(), - Gender.MALE.getKakaoType(), OAuthProvider.KAKAO.getType(), providerId ); @@ -84,10 +80,6 @@ void loginTest2() { "abc1234@gmail.com", "최인준", "injuning", - "testURL", - String.valueOf(2000), - AgeGroup.TWENTY.getKakaoType(), - Gender.MALE.getKakaoType(), OAuthProvider.KAKAO.getType(), providerId ); diff --git a/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java b/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java index 5e48e409..01058445 100644 --- a/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java +++ b/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java @@ -7,13 +7,16 @@ import com.civilwar.boardsignal.common.MultipartFileFixture; import com.civilwar.boardsignal.image.domain.ImageRepository; import com.civilwar.boardsignal.user.UserFixture; +import com.civilwar.boardsignal.user.domain.constants.Gender; import com.civilwar.boardsignal.user.domain.entity.User; import com.civilwar.boardsignal.user.domain.repository.UserRepository; import com.civilwar.boardsignal.user.dto.request.UserModifyRequest; import com.civilwar.boardsignal.user.dto.response.UserModifyResponse; import java.io.IOException; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; +import java.util.function.Supplier; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -31,6 +34,8 @@ class UserServiceTest { private UserRepository userRepository; @Mock private ImageRepository imageRepository; + @Mock + private Supplier now; @InjectMocks private UserService userService; @@ -48,6 +53,8 @@ void joinUserTest() throws IOException { id, "injuning", List.of(Category.FAMILY, Category.PARTY), + Gender.MALE.getDescription(), + 2000, "2호선", "사당역", imageFixture @@ -55,6 +62,7 @@ void joinUserTest() throws IOException { User userFixture = UserFixture.getUserFixture(providerId, testUrl); Boolean isJoined = userFixture.getIsJoined(); + when(now.get()).thenReturn(LocalDateTime.of(2024,11,20,0,0,0)); when(imageRepository.save(imageFixture)).thenReturn(testUrl); when(userRepository.findById(id)).thenReturn(Optional.of(userFixture)); ReflectionTestUtils.setField(userFixture, "id", id); From bfa07f0611380fa1ec26f6d92dcc8289c06a5ab6 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 20:46:06 +0900 Subject: [PATCH 06/15] =?UTF-8?q?fix=20:=20controller=20test=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/AuthApiControllerTest.java | 35 ------------------- .../room/presentation/RoomControllerTest.java | 18 ++-------- .../presentation/UserApiControllerTest.java | 8 +++-- 3 files changed, 9 insertions(+), 52 deletions(-) diff --git a/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java index 3dedb203..e52b3d3a 100644 --- a/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java @@ -95,41 +95,6 @@ void logoutTest2() throws Exception { .andExpect(jsonPath("$.logoutResult").value(false)); } - @Test - @Transactional - @DisplayName("[AccessToken의 사용자 정보를 반환한다.]") - void getLoginUserInfoTest() throws Exception { - //given - User loginUserEntity = userRepository.findById(loginUser.getId()) - .orElseThrow(); - - String updateNickname = "업데이트된 닉네임"; - List categories = List.of(Category.CUSTOMIZABLE, Category.PARTY); - String subwayLine = "2호선"; - String subwayStation = "사당역"; - String image = "update image"; - loginUserEntity.updateUser(updateNickname, categories, subwayLine, subwayStation, image); - - LocalDateTime now = LocalDateTime.of(2024, 3, 4, 9, 27, 0); - given(nowTime.get()).willReturn(now); - - int expectedAge = nowTime.get().getYear() - loginUser.getBirth() + 1; - - //then - mockMvc.perform(get("/api/v1/auth") - .header(AUTHORIZATION, accessToken)) - .andExpect(jsonPath("$.id").value(loginUser.getId())) - .andExpect(jsonPath("$.email").value(loginUser.getEmail())) - .andExpect(jsonPath("$.nickname").value(updateNickname)) - .andExpect(jsonPath("$.ageGroup").value(loginUser.getAgeGroup().getDescription())) - .andExpect(jsonPath("$.gender").value(loginUser.getGender().getDescription())) - .andExpect(jsonPath("$.isJoined").value(true)) - .andExpect(jsonPath("$.age").value(expectedAge)) - .andExpect(jsonPath("$.subwayLine").value(subwayLine)) - .andExpect(jsonPath("$.subwayStation").value(subwayStation)) - .andExpect(jsonPath("$.categories.size()").value(2)); - } - @Test @DisplayName("[인증이 안 된 사용자가 접근 시 401 에러와 전용 에러 메시지 & 코드를 반환한다.]") void exceptionHandlingTest() throws Exception { diff --git a/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java index 365086d4..faff3099 100644 --- a/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java @@ -781,14 +781,10 @@ void participantRoomTest3() throws Exception { roomRepository.save(room); User user = User.of("email", - "name", "nickName", "provider", "providerId", - "testURL", - 1998, - AgeGroup.TWENTY, - Gender.MALE); + "testURL"); User savedUser = userRepository.save(user); Token token = tokenProvider.createToken(savedUser.getId(), Role.USER); @@ -829,14 +825,10 @@ void participantRoomTest4() throws Exception { roomRepository.save(room); User user = User.of("email", - "name", "nickName", "provider", "providerId", - "testURL", - 2020, - AgeGroup.TWENTY, - Gender.MALE); + "testURL"); User savedUser = userRepository.save(user); Token token = tokenProvider.createToken(savedUser.getId(), Role.USER); @@ -877,14 +869,10 @@ void participantRoomTest5() throws Exception { roomRepository.save(room); User user = User.of("email", - "name", "nickName", "provider", "providerId", - "testURL", - 1998, - AgeGroup.TWENTY, - Gender.MALE); + "testURL"); User savedUser = userRepository.save(user); blackListRepository.save(RoomBlackList.of(room.getId(), savedUser.getId())); diff --git a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java index 69d77983..02a7db0f 100644 --- a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java @@ -20,6 +20,8 @@ import com.civilwar.boardsignal.review.domain.entity.ReviewEvaluation; import com.civilwar.boardsignal.review.domain.repository.ReviewRepository; import com.civilwar.boardsignal.user.UserFixture; +import com.civilwar.boardsignal.user.domain.constants.AgeGroup; +import com.civilwar.boardsignal.user.domain.constants.Gender; import com.civilwar.boardsignal.user.domain.constants.OAuthProvider; import com.civilwar.boardsignal.user.domain.constants.Role; import com.civilwar.boardsignal.user.domain.entity.User; @@ -61,6 +63,8 @@ void joinUserTest() throws Exception { ApiUserModifyRequest apiUserModifyRequest = new ApiUserModifyRequest( "injuning", + Gender.MALE.getDescription(), + 2000, "2호선", "사당역", List.of("가족게임", "파티게임") @@ -202,7 +206,7 @@ void validNicknameTest1() throws Exception { void validNicknameTest2() throws Exception { //given String existName = loginUser.getName(); - loginUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), "2호선", "사당역", "testURL"); + loginUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), Gender.MALE, 2000, AgeGroup.TWENTY, "2호선", "사당역", "testURL"); userRepository.save(loginUser); ValidNicknameRequest validNicknameRequest = new ValidNicknameRequest(existName); @@ -240,7 +244,7 @@ void validNicknameTest4() throws Exception { User anotherUser = UserFixture.getUserFixture("providerId", "testURL"); String existName = anotherUser.getName(); userRepository.save(anotherUser); - anotherUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), "2호선", "사당역", "testURL"); + anotherUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), Gender.MALE, 2000, AgeGroup.TWENTY, "2호선", "사당역", "testURL"); userRepository.save(loginUser); ValidNicknameRequest validNicknameRequest = new ValidNicknameRequest(existName); From d94bc8c0b23cc5a26ef18c2bcff6686a94a82cc5 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 20:47:22 +0900 Subject: [PATCH 07/15] =?UTF-8?q?style=20:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=B7=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/AuthApiControllerTest.java | 4 ---- .../room/presentation/RoomControllerTest.java | 1 - .../presentation/UserApiControllerTest.java | 6 +++-- .../user/domain/constants/AgeGroup.java | 22 +++++++++---------- .../auth/application/AuthServiceTest.java | 2 -- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java index e52b3d3a..5f2ebc0e 100644 --- a/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/auth/presentation/AuthApiControllerTest.java @@ -1,6 +1,5 @@ package com.civilwar.boardsignal.auth.presentation; -import static org.mockito.BDDMockito.given; import static org.springframework.http.HttpHeaders.AUTHORIZATION; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -10,7 +9,6 @@ import com.civilwar.boardsignal.auth.domain.model.Token; import com.civilwar.boardsignal.auth.exception.AuthErrorCode; import com.civilwar.boardsignal.auth.infrastructure.JwtTokenProvider; -import com.civilwar.boardsignal.boardgame.domain.constant.Category; import com.civilwar.boardsignal.common.support.ApiTestSupport; import com.civilwar.boardsignal.user.UserFixture; import com.civilwar.boardsignal.user.domain.constants.Role; @@ -18,13 +16,11 @@ import com.civilwar.boardsignal.user.domain.repository.UserRepository; import jakarta.servlet.http.Cookie; import java.time.LocalDateTime; -import java.util.List; import java.util.function.Supplier; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.transaction.annotation.Transactional; @DisplayName("[AuthApiController 테스트]") class AuthApiControllerTest extends ApiTestSupport { diff --git a/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java index faff3099..74691e37 100644 --- a/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/room/presentation/RoomControllerTest.java @@ -40,7 +40,6 @@ import com.civilwar.boardsignal.room.dto.response.ParticipantJpaDto; import com.civilwar.boardsignal.room.infrastructure.repository.MeetingInfoJpaRepository; import com.civilwar.boardsignal.user.UserFixture; -import com.civilwar.boardsignal.user.domain.constants.AgeGroup; import com.civilwar.boardsignal.user.domain.constants.Gender; import com.civilwar.boardsignal.user.domain.constants.Role; import com.civilwar.boardsignal.user.domain.entity.User; diff --git a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java index 02a7db0f..b40438ba 100644 --- a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java @@ -206,7 +206,8 @@ void validNicknameTest1() throws Exception { void validNicknameTest2() throws Exception { //given String existName = loginUser.getName(); - loginUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), Gender.MALE, 2000, AgeGroup.TWENTY, "2호선", "사당역", "testURL"); + loginUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), Gender.MALE, 2000, + AgeGroup.TWENTY, "2호선", "사당역", "testURL"); userRepository.save(loginUser); ValidNicknameRequest validNicknameRequest = new ValidNicknameRequest(existName); @@ -244,7 +245,8 @@ void validNicknameTest4() throws Exception { User anotherUser = UserFixture.getUserFixture("providerId", "testURL"); String existName = anotherUser.getName(); userRepository.save(anotherUser); - anotherUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), Gender.MALE, 2000, AgeGroup.TWENTY, "2호선", "사당역", "testURL"); + anotherUser.updateUser(existName, List.of(Category.CUSTOMIZABLE), Gender.MALE, 2000, + AgeGroup.TWENTY, "2호선", "사당역", "testURL"); userRepository.save(loginUser); ValidNicknameRequest validNicknameRequest = new ValidNicknameRequest(existName); diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java index 228e9ff6..2af57cb8 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java @@ -18,7 +18,7 @@ public enum AgeGroup { TEENAGER("14~19", "14-19", "청소년", 19), TWENTY("20~29", "20-29", "20대", 29), THIRTY("30~39", "30-39", "30대", 39), - FORTY("40~49", "40-49", "40대",49), + FORTY("40~49", "40-49", "40대", 49), FIFTY("50~59", "50-59", "50대", 59), SIXTY("60~69", "60-69", "60대", 69), SEVENTY("70~79", "70-79", "70대", 79), @@ -37,25 +37,25 @@ public static AgeGroup of(String input, String provider) { .orElseThrow(() -> new NotFoundException(NOT_FOUND_AGE_GROUP)); } - private boolean isEqual(String input, String provider) { - if (provider.equals(OAuthProvider.KAKAO.getType())) { - return input.equalsIgnoreCase(this.kakaoType); - } else { - return input.equalsIgnoreCase(this.naverType); - } - } - public static AgeGroup convert(int birthYear, LocalDateTime now) { AgeGroup userAgeGroup = UNKNOWN; - int age = now.getYear()-birthYear+1; + int age = now.getYear() - birthYear + 1; for (AgeGroup a : values()) { //현재 연령대의 사용자의 나이가 포함된다면 - if (a.getMaxAge()>=age) { + if (a.getMaxAge() >= age) { userAgeGroup = a; } } return userAgeGroup; } + + private boolean isEqual(String input, String provider) { + if (provider.equals(OAuthProvider.KAKAO.getType())) { + return input.equalsIgnoreCase(this.kakaoType); + } else { + return input.equalsIgnoreCase(this.naverType); + } + } } diff --git a/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java b/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java index a09220d7..645c616d 100644 --- a/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java +++ b/core/src/test/java/com/civilwar/boardsignal/auth/application/AuthServiceTest.java @@ -12,8 +12,6 @@ import com.civilwar.boardsignal.auth.dto.response.IssueTokenResponse; import com.civilwar.boardsignal.auth.dto.response.UserLoginResponse; import com.civilwar.boardsignal.user.UserFixture; -import com.civilwar.boardsignal.user.domain.constants.AgeGroup; -import com.civilwar.boardsignal.user.domain.constants.Gender; import com.civilwar.boardsignal.user.domain.constants.OAuthProvider; import com.civilwar.boardsignal.user.domain.constants.Role; import com.civilwar.boardsignal.user.domain.entity.User; From 2142779ff7fe0b0bbf942ec2255b196e45a92a6a Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 21:00:27 +0900 Subject: [PATCH 08/15] =?UTF-8?q?fix=20:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=A6=AC=EB=8B=A4=EC=9D=B4=EB=A0=89=ED=8A=B8=20=ED=94=84?= =?UTF-8?q?=EB=A1=A0=ED=8A=B8=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=9E=84?= =?UTF-8?q?=EC=8B=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/auth/handler/OAuth2LoginSuccessHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java b/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java index 67c5d3fe..b9e3bba9 100644 --- a/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java +++ b/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java @@ -25,7 +25,8 @@ @RequiredArgsConstructor public class OAuth2LoginSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { - private final String DOMAIN = "https://team-civilwar-boardsignal-fe.pages.dev"; + private final String DOMAIN = "localhost:5173"; +// "https://team-civilwar-boardsignal-fe.pages.dev"; private final String REFRESHTOKEN_NAME = "RefreshToken_Id"; private final AuthService authService; From 466c25ca9beda385c50f95e30cef89a3572604bc Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 21:19:00 +0900 Subject: [PATCH 09/15] =?UTF-8?q?fix=20:=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/auth/handler/OAuth2LoginSuccessHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java b/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java index b9e3bba9..f6c2fefd 100644 --- a/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java +++ b/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java @@ -25,7 +25,7 @@ @RequiredArgsConstructor public class OAuth2LoginSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { - private final String DOMAIN = "localhost:5173"; + private final String DOMAIN = "http://localhost:5173"; // "https://team-civilwar-boardsignal-fe.pages.dev"; private final String REFRESHTOKEN_NAME = "RefreshToken_Id"; From 71ecd2163fadcd7586af0fddef26c8371eafc922 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 22:04:46 +0900 Subject: [PATCH 10/15] =?UTF-8?q?fix=20:=20=EC=83=9D=EC=84=B1=EC=9E=90=20p?= =?UTF-8?q?rivate=20=EB=B3=80=EA=B2=BD=20&=20=EC=A0=95=EC=A0=81=20?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/user/domain/entity/User.java | 26 ++++++++++++++++++- .../boardsignal/user/UserFixture.java | 4 +-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java index a7ef3843..6eb06dae 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java @@ -97,7 +97,7 @@ public class User extends BaseEntity implements UserDetails { private int signal; @Builder(access = AccessLevel.PUBLIC) - public User( + private User( @NonNull String email, String name, @NonNull String nickname, @@ -139,6 +139,30 @@ public static User of( .build(); } + public static User of( + String email, + String name, + String nickname, + String provider, + String providerId, + String profileImageUrl, + int birth, + AgeGroup ageGroup, + Gender gender + ) { + return User.builder() + .email(email) + .name(name) + .nickname(nickname) + .provider(provider) + .providerId(providerId) + .profileImageUrl(profileImageUrl) + .birth(birth) + .ageGroup(ageGroup) + .gender(gender) + .build(); + } + public void updateUser( String nickname, List categories, diff --git a/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java b/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java index 61bba41a..294b7ea2 100644 --- a/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java +++ b/core/src/testFixtures/java/com/civilwar/boardsignal/user/UserFixture.java @@ -14,7 +14,7 @@ public class UserFixture { public static User getUserFixture(String providerId, String imageUrl) { String provider = OAuthProvider.KAKAO.getType(); - return new User( + return User.of( "abc1234@gmail.com", "최인준", "injuning", @@ -30,7 +30,7 @@ public static User getUserFixture(String providerId, String imageUrl) { public static User getUserFixture2(String providerId, String imageUrl) { String provider = OAuthProvider.KAKAO.getType(); - return new User( + return User.of( "abc12345678@naver.com", "김강훈", "macbook", From ed95a4ad4198269b08589145b87e716852fc4285 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 22:15:40 +0900 Subject: [PATCH 11/15] =?UTF-8?q?fix=20:=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20&=20AgeGroup=20=EB=B3=80=ED=99=98=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/user/domain/constants/AgeGroup.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java index 2af57cb8..9fb8e24c 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/constants/AgeGroup.java @@ -12,7 +12,7 @@ @RequiredArgsConstructor public enum AgeGroup { - UNKNOWN("0", "0", "알 ㅅ 없음", 0), + UNKNOWN("0", "0", "알 수 없음", 0), UNDER_CHILDREN("1~9", "1-9", "미취학 아동", 9), CHILDREN("10~14", "10-14", "어린이", 14), TEENAGER("14~19", "14-19", "청소년", 19), @@ -39,12 +39,14 @@ public static AgeGroup of(String input, String provider) { public static AgeGroup convert(int birthYear, LocalDateTime now) { AgeGroup userAgeGroup = UNKNOWN; - int age = now.getYear() - birthYear + 1; + //사용자 나이 + int userAge = now.getYear() - birthYear + 1; for (AgeGroup a : values()) { - //현재 연령대의 사용자의 나이가 포함된다면 - if (a.getMaxAge() >= age) { + //현재 연령대에 사용자의 나이가 포함된다면 + if (a.getMaxAge() >= userAge) { userAgeGroup = a; + break; } } return userAgeGroup; From 8da65dd27ce276a26c95261ea852339842805a8f Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 22:16:01 +0900 Subject: [PATCH 12/15] =?UTF-8?q?test=20:=20=EC=97=B0=EB=A0=B9=EB=8C=80=20?= =?UTF-8?q?=EB=B3=80=ED=99=98=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/presentation/UserApiControllerTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java index b40438ba..62c3d3e3 100644 --- a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java @@ -1,6 +1,7 @@ package com.civilwar.boardsignal.user.presentation; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.*; import static org.springframework.http.HttpHeaders.AUTHORIZATION; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; @@ -30,10 +31,14 @@ import com.civilwar.boardsignal.user.dto.request.ValidNicknameRequest; import java.io.FileInputStream; import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; import java.util.List; +import java.util.function.Supplier; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.mockito.BDDMockito; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; @@ -49,12 +54,16 @@ class UserApiControllerTest extends ApiTestSupport { private TokenProvider tokenProvider; @Autowired private WishRepository wishRepository; + @MockBean + private Supplier now; @Test @DisplayName("[회원은 정보를 수정 할 수 있다]") void joinUserTest() throws Exception { //given + given(now.get()).willReturn(LocalDateTime.of(2024, 4, 16, 0, 0, 0)); + User userFixture = UserFixture.getUserFixture(OAuthProvider.KAKAO.getType(), "testURL"); userRepository.save(userFixture); @@ -64,7 +73,7 @@ void joinUserTest() throws Exception { ApiUserModifyRequest apiUserModifyRequest = new ApiUserModifyRequest( "injuning", Gender.MALE.getDescription(), - 2000, + 1970, "2호선", "사당역", List.of("가족게임", "파티게임") @@ -103,6 +112,7 @@ void joinUserTest() throws Exception { assertThat(findUser.getNickname()).isEqualTo(apiUserModifyRequest.nickName()); assertThat(findUser.getLine()).isEqualTo(apiUserModifyRequest.line()); assertThat(findUser.getStation()).isEqualTo(apiUserModifyRequest.station()); + assertThat(findUser.getAgeGroup()).isEqualTo(AgeGroup.FIFTY); } From 6f3657be35baa5de34c22f468cfb575cec755c48 Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 22:17:10 +0900 Subject: [PATCH 13/15] =?UTF-8?q?style=20:=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=B7=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/auth/handler/OAuth2LoginSuccessHandler.java | 2 +- .../boardsignal/user/presentation/UserApiControllerTest.java | 3 +-- .../civilwar/boardsignal/user/application/UserServiceTest.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java b/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java index f6c2fefd..3606fd4e 100644 --- a/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java +++ b/api/src/main/java/com/civilwar/boardsignal/auth/handler/OAuth2LoginSuccessHandler.java @@ -26,7 +26,7 @@ public class OAuth2LoginSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { private final String DOMAIN = "http://localhost:5173"; -// "https://team-civilwar-boardsignal-fe.pages.dev"; + // "https://team-civilwar-boardsignal-fe.pages.dev"; private final String REFRESHTOKEN_NAME = "RefreshToken_Id"; private final AuthService authService; diff --git a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java index 62c3d3e3..162ef4e9 100644 --- a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java @@ -1,7 +1,7 @@ package com.civilwar.boardsignal.user.presentation; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.*; +import static org.mockito.BDDMockito.given; import static org.springframework.http.HttpHeaders.AUTHORIZATION; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; @@ -36,7 +36,6 @@ import java.util.function.Supplier; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.mockito.BDDMockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpMethod; diff --git a/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java b/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java index 01058445..5a680ebc 100644 --- a/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java +++ b/core/src/test/java/com/civilwar/boardsignal/user/application/UserServiceTest.java @@ -62,7 +62,7 @@ void joinUserTest() throws IOException { User userFixture = UserFixture.getUserFixture(providerId, testUrl); Boolean isJoined = userFixture.getIsJoined(); - when(now.get()).thenReturn(LocalDateTime.of(2024,11,20,0,0,0)); + when(now.get()).thenReturn(LocalDateTime.of(2024, 11, 20, 0, 0, 0)); when(imageRepository.save(imageFixture)).thenReturn(testUrl); when(userRepository.findById(id)).thenReturn(Optional.of(userFixture)); ReflectionTestUtils.setField(userFixture, "id", id); From ea68a8cab039b72caa92afb5ae077d5b0c7435aa Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Tue, 16 Apr 2024 22:44:45 +0900 Subject: [PATCH 14/15] =?UTF-8?q?fix=20:=20=EB=88=84=EB=9D=BD=EB=90=9C=20m?= =?UTF-8?q?ocking=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boardsignal/user/presentation/UserApiControllerTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java index 162ef4e9..9d7ec5f2 100644 --- a/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java +++ b/api/src/test/java/com/civilwar/boardsignal/user/presentation/UserApiControllerTest.java @@ -119,6 +119,8 @@ void joinUserTest() throws Exception { @DisplayName("유저의 자신의 프로필을 조회할 수 있다.") void getUserProfileTest() throws Exception { //given + given(now.get()).willReturn(LocalDateTime.of(2024, 4, 16, 0, 0, 0)); + List evaluationFixture = ReviewFixture.getEvaluationFixture(); Review review = ReviewFixture.getReviewFixture(100L, loginUser.getId(), 1L, evaluationFixture); @@ -158,6 +160,8 @@ void getUserProfileTest() throws Exception { @DisplayName("타인의 프로필을 조회할 수 있다.") void getUserProfileTest2() throws Exception { //given + given(now.get()).willReturn(LocalDateTime.of(2024, 4, 16, 0, 0, 0)); + User anotherUser = UserFixture.getUserFixture2("providerId", "testUrl"); userRepository.save(anotherUser); List evaluationFixture = ReviewFixture.getEvaluationFixture(); From 7d896e5e4a05bec5cd0c50ee3cf1ebd262dc0b7c Mon Sep 17 00:00:00 2001 From: kkangh00n Date: Wed, 17 Apr 2024 20:35:57 +0900 Subject: [PATCH 15/15] =?UTF-8?q?edit=20:=20OAuth=20=EC=84=9C=EB=B2=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=B0=9B=EB=8A=94=20=EB=8B=89=EB=84=A4?= =?UTF-8?q?=EC=9E=84=EC=9D=84,=20=EC=9D=B4=EB=A6=84=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=EC=97=90=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/civilwar/boardsignal/user/domain/entity/User.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java index 6eb06dae..7a1610cb 100644 --- a/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java +++ b/core/src/main/java/com/civilwar/boardsignal/user/domain/entity/User.java @@ -96,11 +96,11 @@ public class User extends BaseEntity implements UserDetails { @Column(name = "USER_SIGNAL") private int signal; - @Builder(access = AccessLevel.PUBLIC) + @Builder(access = AccessLevel.PRIVATE) private User( @NonNull String email, - String name, - @NonNull String nickname, + @NonNull String name, + String nickname, @NonNull String provider, @NonNull String providerId, @NonNull String profileImageUrl, @@ -132,7 +132,7 @@ public static User of( ) { return User.builder() .email(email) - .nickname(nickname) + .name(nickname) .provider(provider) .providerId(providerId) .profileImageUrl(profileImageUrl)