|
13 | 13 | import apptive.team5.subscribe.repository.SubscribeRepository; |
14 | 14 | import apptive.team5.user.domain.UserEntity; |
15 | 15 | import apptive.team5.user.domain.UserRoleType; |
16 | | -import apptive.team5.user.dto.UserResponse; |
17 | | -import apptive.team5.user.dto.UserSearchResponse; |
18 | | -import apptive.team5.user.dto.UserStaticsResponse; |
19 | | -import apptive.team5.user.dto.UserTagUpdateRequest; |
| 16 | +import apptive.team5.user.dto.*; |
20 | 17 | import apptive.team5.user.repository.UserRepository; |
21 | 18 | import apptive.team5.util.TestSecurityContextHolderInjection; |
22 | 19 | import apptive.team5.util.TestUtil; |
@@ -191,6 +188,39 @@ void changeUserTagFail() throws Exception { |
191 | 188 |
|
192 | 189 | } |
193 | 190 |
|
| 191 | + @DisplayName("회원 name 변경 성공") |
| 192 | + @Test |
| 193 | + void changeUserNameSuccess() throws Exception { |
| 194 | + |
| 195 | + // given |
| 196 | + UserEntity user = TestUtil.makeUserEntity(); |
| 197 | + userRepository.save(user); |
| 198 | + TestSecurityContextHolderInjection.inject(user.getId(), user.getRoleType()); |
| 199 | + UserNameUpdateRequest userNameUpdateRequest = new UserNameUpdateRequest("이진원"); |
| 200 | + |
| 201 | + |
| 202 | + // when |
| 203 | + MockHttpServletResponse response = mockMvc.perform(patch("/api/users/my/names") |
| 204 | + .contentType(MediaType.APPLICATION_JSON) |
| 205 | + .content(objectMapper.writeValueAsString(userNameUpdateRequest)) |
| 206 | + .with(securityContext(SecurityContextHolder.getContext())) |
| 207 | + ) |
| 208 | + .andExpect(status().isOk()) |
| 209 | + .andReturn().getResponse(); |
| 210 | + |
| 211 | + // then |
| 212 | + String content = response.getContentAsString(); |
| 213 | + |
| 214 | + UserResponse userResponse = objectMapper.readValue(content, UserResponse.class); |
| 215 | + |
| 216 | + |
| 217 | + assertSoftly(softly -> { |
| 218 | + softly.assertThat(userResponse.userId()).isEqualTo(user.getId()); |
| 219 | + softly.assertThat(userResponse.username()).isEqualTo(userNameUpdateRequest.username()); |
| 220 | + }); |
| 221 | + |
| 222 | + } |
| 223 | + |
194 | 224 | @DisplayName("tag를 통해 유저 조회 성공") |
195 | 225 | @Test |
196 | 226 | void getUserByTagSuccess() throws Exception { |
|
0 commit comments