-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 유저 관련 통합 테스트 데이터 fixture 메서드로 변경 #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Gyuhyeok99
merged 15 commits into
solid-connection:develop
from
Gyuhyeok99:refactor/318-siteuser-test-fixture-module
May 19, 2025
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0ff5c51
feat: SiteUserFixture에 유저 생성 메서드 추가
Gyuhyeok99 f7436ae
refactor: 대학 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 0ea67a9
refactor: 유저 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 82e8126
refactor: 점수 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 0e6c585
refactor: 동시성 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 6e13ea6
refactor: 인증 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 64627fd
refactor: 어드민 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 94037f5
refactor: 커스텀 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 313cf65
refactor: SiteUserFixtureBuilder에서 비밀번호 인코딩 처리 통일
Gyuhyeok99 05e9733
refactor: 재사용성 없는 fixture 제거
Gyuhyeok99 86de879
refactor: 테스트 유저 메서드명 사용자()로 통일
Gyuhyeok99 0d06904
refactor: 테스트 어드민 메서드명 관리자()로 통일
Gyuhyeok99 65dfc47
refactor: Repository 테스트는 fixture 대신 entity 사용하도록 변경
Gyuhyeok99 75f6294
refactor: 커스텀 프로필 사용자로 이름 변경
Gyuhyeok99 a4f5d17
refactor: 커스텀 프로필 생성 함수 private로 변경
Gyuhyeok99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -56,28 +56,6 @@ public class SiteUserFixture { | |
| .create(); | ||
| } | ||
|
|
||
| public SiteUser 중복_닉네임_테스트_유저() { | ||
| return siteUserFixtureBuilder.siteUser() | ||
| .email("[email protected]") | ||
| .authType(AuthType.EMAIL) | ||
| .nickname("중복닉네임") | ||
| .profileImageUrl("profileImageUrl") | ||
| .role(Role.MENTEE) | ||
| .password("password123") | ||
| .create(); | ||
| } | ||
|
|
||
| public SiteUser 커스텀_프로필_테스트_유저() { | ||
| return siteUserFixtureBuilder.siteUser() | ||
| .email("[email protected]") | ||
| .authType(AuthType.EMAIL) | ||
| .nickname("커스텀프로필") | ||
| .profileImageUrl("profile/profileImageUrl") | ||
| .role(Role.MENTEE) | ||
| .password("customPassword123") | ||
| .create(); | ||
| } | ||
|
|
||
| public SiteUser 테스트_어드민() { | ||
| return siteUserFixtureBuilder.siteUser() | ||
| .email("[email protected]") | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,13 +3,16 @@ | |
| import com.example.solidconnection.custom.exception.CustomException; | ||
| import com.example.solidconnection.s3.S3Service; | ||
| import com.example.solidconnection.s3.UploadedFileUrlResponse; | ||
| import com.example.solidconnection.siteuser.domain.AuthType; | ||
| import com.example.solidconnection.siteuser.domain.SiteUser; | ||
| import com.example.solidconnection.siteuser.dto.MyPageResponse; | ||
| import com.example.solidconnection.siteuser.fixture.SiteUserFixture; | ||
| import com.example.solidconnection.siteuser.fixture.SiteUserFixtureBuilder; | ||
| import com.example.solidconnection.siteuser.repository.LikedUniversityRepository; | ||
| import com.example.solidconnection.siteuser.repository.SiteUserRepository; | ||
| import com.example.solidconnection.support.TestContainerSpringBootTest; | ||
| import com.example.solidconnection.type.ImgType; | ||
| import com.example.solidconnection.type.Role; | ||
| import com.example.solidconnection.university.domain.LikedUniversity; | ||
| import com.example.solidconnection.university.dto.UniversityInfoForApplyPreviewResponse; | ||
| import com.example.solidconnection.university.fixture.UniversityInfoForApplyFixture; | ||
|
|
@@ -59,6 +62,9 @@ class MyPageServiceTest { | |
| @Autowired | ||
| private UniversityInfoForApplyFixture universityInfoForApplyFixture; | ||
|
|
||
| @Autowired | ||
| private SiteUserFixtureBuilder siteUserFixtureBuilder; | ||
|
|
||
| private SiteUser 테스트_유저; | ||
|
|
||
| @BeforeEach | ||
|
|
@@ -132,7 +138,7 @@ class 프로필_이미지_수정_테스트 { | |
| @Test | ||
| void 프로필을_처음_수정하는_것이_아니라면_이전_이미지를_삭제한다() { | ||
| // given | ||
| SiteUser 커스텀_프로필_테스트_유저 = siteUserFixture.커스텀_프로필_테스트_유저(); | ||
| SiteUser 커스텀_프로필_테스트_유저 = createSiteUserWithCustomProfile(); | ||
| MockMultipartFile imageFile = createValidImageFile(); | ||
| given(s3Service.uploadFile(any(), eq(ImgType.PROFILE))) | ||
| .willReturn(new UploadedFileUrlResponse("newProfileImageUrl")); | ||
|
|
@@ -172,11 +178,10 @@ void setUp() { | |
| @Test | ||
| void 중복된_닉네임으로_변경하면_예외_응답을_반환한다() { | ||
| // given | ||
| SiteUser 중복_닉네임_테스트_유저 = siteUserFixture.중복_닉네임_테스트_유저(); | ||
| MockMultipartFile imageFile = createValidImageFile(); | ||
| SiteUser existingUser = siteUserFixture.테스트_유저(1, "existing nickname"); | ||
|
|
||
| // when & then | ||
| assertThatCode(() -> myPageService.updateMyPageInfo(테스트_유저, imageFile, 중복_닉네임_테스트_유저.getNickname())) | ||
| assertThatCode(() -> myPageService.updateMyPageInfo(테스트_유저, null, existingUser.getNickname())) | ||
| .isInstanceOf(CustomException.class) | ||
| .hasMessage(NICKNAME_ALREADY_EXISTED.getMessage()); | ||
| } | ||
|
|
@@ -222,4 +227,15 @@ private String createExpectedErrorMessage(LocalDateTime modifiedAt) { | |
| ); | ||
| return CAN_NOT_CHANGE_NICKNAME_YET.getMessage() + " : " + formatLastModifiedAt; | ||
| } | ||
|
|
||
| public SiteUser createSiteUserWithCustomProfile() { | ||
| return siteUserFixtureBuilder.siteUser() | ||
| .email("[email protected]") | ||
| .authType(AuthType.EMAIL) | ||
| .nickname("커스텀프로필") | ||
| .profileImageUrl("profile/profileImageUrl") | ||
| .role(Role.MENTEE) | ||
| .password("customPassword123") | ||
| .create(); | ||
| } | ||
Gyuhyeok99 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.