-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyPageServiceTest.java
More file actions
97 lines (78 loc) · 3.22 KB
/
MyPageServiceTest.java
File metadata and controls
97 lines (78 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.dilly.mypage.application;
import static org.assertj.core.api.Assertions.assertThat;
import com.dilly.global.IntegrationTestSupport;
import com.dilly.global.WithCustomMockUser;
import com.dilly.member.domain.Member;
import com.dilly.member.domain.ProfileImage;
import com.dilly.member.dto.request.ProfileRequest;
import com.dilly.member.dto.response.ProfileResponse;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
class MyPageServiceTest extends IntegrationTestSupport {
@DisplayName("나의 프로필을 조회한다.")
@Test
@WithCustomMockUser
void getProfile() {
// given
Member member = memberService.getMember();
// when
ProfileResponse response = myPageService.getProfile();
// then
assertThat(response.id()).isEqualTo(member.getId());
assertThat(response.provider()).isEqualTo(member.getProvider().toString().toLowerCase());
assertThat(response.nickname()).isEqualTo(member.getNickname());
assertThat(response.imgUrl()).isEqualTo(member.getProfileImg().getImgUrl());
}
@Nested
@DisplayName("나의 프로필을 수정한다.")
class updateProfile {
private final String newNickname = "닉네임변경";
@DisplayName("닉네임과 프로필 이미지를 수정한다.")
@Test
@WithCustomMockUser
void updateNicknameAndProfileImage() {
// given
ProfileRequest profileRequest = ProfileRequest.builder()
.nickname(newNickname)
.profileImg(2L)
.build();
// when
ProfileResponse response = myPageService.updateProfile(profileRequest);
// then
assertThat(response.nickname()).isEqualTo(newNickname);
assertThat(response.imgUrl()).isEqualTo("www.example2.com");
}
@DisplayName("닉네임만 수정한다.")
@Test
@WithCustomMockUser
void updateNickname() {
// given
ProfileRequest profileRequest = ProfileRequest.builder()
.nickname(newNickname)
.build();
// when
ProfileResponse response = myPageService.updateProfile(profileRequest);
// then
assertThat(response.nickname()).isEqualTo(newNickname);
assertThat(response.imgUrl()).isEqualTo("www.example1.com");
}
@DisplayName("프로필 이미지만 수정한다.")
@Test
@WithCustomMockUser
void updateProfileImage() {
// given
Long memberId = SecurityUtil.getMemberId();
Member member = memberReader.findById(memberId);
ProfileRequest profileRequest = ProfileRequest.builder()
.profileImg(2L)
.build();
ProfileImage profileImage = profileImageReader.findById(profileRequest.profileImg());
// when
ProfileResponse response = myPageService.updateProfile(profileRequest);
// then
assertThat(response.nickname()).isEqualTo(member.getNickname());
assertThat(response.imgUrl()).isEqualTo(profileImage.getImgUrl());
}
}
}