-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-entity 유저 프로필 이미지 추가
- Loading branch information
Showing
12 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/java/com/ajou/hertz/common/properties/HertzProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.ajou.hertz.common.properties; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties("hertz") | ||
public record HertzProperties(String userDefaultProfileImageUrl) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/ajou/hertz/domain/user/entity/UserProfileImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.ajou.hertz.domain.user.entity; | ||
|
||
import com.ajou.hertz.common.entity.FileEntity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.OneToOne; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@Entity | ||
public class UserProfileImage extends FileEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "user_profile_image_id", nullable = false) | ||
private Long id; | ||
|
||
@JoinColumn(name = "user_id", nullable = false) | ||
@OneToOne(fetch = FetchType.LAZY) | ||
private User user; | ||
|
||
private UserProfileImage(Long id, User user, String originalName, String storedName, String url) { | ||
super(originalName, storedName, url); | ||
this.id = id; | ||
this.user = user; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ public void securitySetUp() throws Exception { | |
private UserDto createUserDto() throws Exception { | ||
Constructor<UserDto> userResponseConstructor = UserDto.class.getDeclaredConstructor( | ||
Long.class, Set.class, String.class, String.class, String.class, | ||
LocalDate.class, Gender.class, String.class, String.class | ||
String.class, LocalDate.class, Gender.class, String.class, String.class | ||
); | ||
userResponseConstructor.setAccessible(true); | ||
return userResponseConstructor.newInstance( | ||
|
@@ -55,6 +55,7 @@ private UserDto createUserDto() throws Exception { | |
"[email protected]", | ||
"$2a$abc123", | ||
"kakao-user-id", | ||
"https://user-default-profile-image", | ||
LocalDate.of(2024, 1, 1), | ||
Gender.ETC, | ||
"01012345678", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,7 @@ private JwtTokenInfoDto createJwtTokenInfoDto() { | |
private UserDto createUserDto(long id) throws Exception { | ||
Constructor<UserDto> userResponseConstructor = UserDto.class.getDeclaredConstructor( | ||
Long.class, Set.class, String.class, String.class, String.class, | ||
LocalDate.class, Gender.class, String.class, String.class | ||
String.class, LocalDate.class, Gender.class, String.class, String.class | ||
); | ||
userResponseConstructor.setAccessible(true); | ||
return userResponseConstructor.newInstance( | ||
|
@@ -118,6 +118,7 @@ private UserDto createUserDto(long id) throws Exception { | |
"[email protected]", | ||
"$2a$abc123", | ||
"kakao-user-id", | ||
"https://user-default-profile-image", | ||
LocalDate.of(2024, 1, 1), | ||
Gender.ETC, | ||
"01012345678", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,7 +185,7 @@ private SignUpRequest createSignUpRequest() throws Exception { | |
private UserDto createUserDto(long id) throws Exception { | ||
Constructor<UserDto> userResponseConstructor = UserDto.class.getDeclaredConstructor( | ||
Long.class, Set.class, String.class, String.class, String.class, | ||
LocalDate.class, Gender.class, String.class, String.class | ||
String.class, LocalDate.class, Gender.class, String.class, String.class | ||
); | ||
userResponseConstructor.setAccessible(true); | ||
return userResponseConstructor.newInstance( | ||
|
@@ -194,6 +194,7 @@ private UserDto createUserDto(long id) throws Exception { | |
"[email protected]", | ||
"$2a$abc123", | ||
"kakao-user-id", | ||
"https://user-default-profile-image", | ||
LocalDate.of(2024, 1, 1), | ||
Gender.ETC, | ||
"01012345678", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,9 @@ | |
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
import org.springframework.test.context.event.annotation.BeforeTestMethod; | ||
|
||
import com.ajou.hertz.common.properties.HertzProperties; | ||
import com.ajou.hertz.domain.user.constant.Gender; | ||
import com.ajou.hertz.domain.user.constant.RoleType; | ||
import com.ajou.hertz.domain.user.dto.UserDto; | ||
|
@@ -41,6 +43,14 @@ class UserCommandServiceTest { | |
@Mock | ||
private PasswordEncoder passwordEncoder; | ||
|
||
@Mock | ||
private HertzProperties hertzProperties; | ||
|
||
@BeforeTestMethod | ||
public void setUp() { | ||
given(hertzProperties.userDefaultProfileImageUrl()).willReturn("https://user-default-profile-image"); | ||
} | ||
|
||
@Test | ||
void 주어진_회원_정보로_신규_회원을_등록한다() throws Exception { | ||
// given | ||
|
@@ -88,7 +98,7 @@ private void verifyEveryMocksShouldHaveNoMoreInteractions() { | |
private User createUser(Long id, String password) throws Exception { | ||
Constructor<User> userConstructor = User.class.getDeclaredConstructor( | ||
Long.class, Set.class, String.class, String.class, String.class, | ||
LocalDate.class, Gender.class, String.class, String.class | ||
String.class, LocalDate.class, Gender.class, String.class, String.class | ||
); | ||
userConstructor.setAccessible(true); | ||
return userConstructor.newInstance( | ||
|
@@ -97,6 +107,7 @@ private User createUser(Long id, String password) throws Exception { | |
"[email protected]", | ||
password, | ||
"kakao-user-id", | ||
"https://user-default-profile-image-url", | ||
LocalDate.of(2024, 1, 1), | ||
Gender.ETC, | ||
"010-1234-5678", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters