Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
0ff5c51
feat: SiteUserFixture에 유저 생성 메서드 추가
Gyuhyeok99 May 12, 2025
f7436ae
refactor: 대학 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 May 12, 2025
0ea67a9
refactor: 유저 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 May 12, 2025
82e8126
refactor: 점수 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 May 12, 2025
0e6c585
refactor: 동시성 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 May 12, 2025
6e13ea6
refactor: 인증 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 May 12, 2025
64627fd
refactor: 어드민 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 May 12, 2025
94037f5
refactor: 커스텀 관련 테스트 유저 데이터 Fixture 메서드로 변경
Gyuhyeok99 May 12, 2025
313cf65
refactor: SiteUserFixtureBuilder에서 비밀번호 인코딩 처리 통일
Gyuhyeok99 May 13, 2025
05e9733
refactor: 재사용성 없는 fixture 제거
Gyuhyeok99 May 18, 2025
86de879
refactor: 테스트 유저 메서드명 사용자()로 통일
Gyuhyeok99 May 18, 2025
0d06904
refactor: 테스트 어드민 메서드명 관리자()로 통일
Gyuhyeok99 May 18, 2025
65dfc47
refactor: Repository 테스트는 fixture 대신 entity 사용하도록 변경
Gyuhyeok99 May 18, 2025
75f6294
refactor: 커스텀 프로필 사용자로 이름 변경
Gyuhyeok99 May 19, 2025
a4f5d17
refactor: 커스텀 프로필 생성 함수 private로 변경
Gyuhyeok99 May 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,6 +62,9 @@ class MyPageServiceTest {
@Autowired
private UniversityInfoForApplyFixture universityInfoForApplyFixture;

@Autowired
private SiteUserFixtureBuilder siteUserFixtureBuilder;

private SiteUser 테스트_유저;

@BeforeEach
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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();
}
}