|
35 | 35 | import com.ajou.hertz.domain.user.controller.UserController;
|
36 | 36 | import com.ajou.hertz.domain.user.dto.UserDto;
|
37 | 37 | import com.ajou.hertz.domain.user.dto.request.SignUpRequest;
|
| 38 | +import com.ajou.hertz.domain.user.dto.request.UpdateProfileImageUrlRequest; |
38 | 39 | import com.ajou.hertz.domain.user.service.UserCommandService;
|
39 | 40 | import com.ajou.hertz.domain.user.service.UserQueryService;
|
40 | 41 | import com.ajou.hertz.util.ReflectionUtils;
|
@@ -212,6 +213,33 @@ public void securitySetUp() throws Exception {
|
212 | 213 | verifyEveryMocksShouldHaveNoMoreInteractions();
|
213 | 214 | }
|
214 | 215 |
|
| 216 | + @Test |
| 217 | + void 주어진_id와_새로운_프로필_이미지로_프로필_이미지를_변경한다() throws Exception { |
| 218 | + // given |
| 219 | + long userId = 1L; |
| 220 | + String profileImageUrl = "https://example.com/new_profile_image.jpg"; |
| 221 | + UpdateProfileImageUrlRequest updateProfileImageUrlRequest = new UpdateProfileImageUrlRequest(profileImageUrl); |
| 222 | + UserDetails userDetails = createTestUser(userId); |
| 223 | + UserDto updatedUserDto = createUserDto(userId); |
| 224 | + given(userCommandService.updateProfileImageUrl(userId, profileImageUrl)).willReturn(updatedUserDto); |
| 225 | + given(userQueryService.getDtoById(userId)).willReturn(createUserDto(userId)); |
| 226 | + |
| 227 | + // when & then |
| 228 | + mvc.perform( |
| 229 | + put("/api/users/me/profile-image") |
| 230 | + .header(API_VERSION_HEADER_NAME, 1) |
| 231 | + .contentType(MediaType.APPLICATION_JSON) |
| 232 | + .content(objectMapper.writeValueAsString(updateProfileImageUrlRequest)) |
| 233 | + .with(user(userDetails)) |
| 234 | + ) |
| 235 | + .andExpect(status().isOk()) |
| 236 | + .andExpect(jsonPath("$.profileImageUrl").value(updatedUserDto.getProfileImageUrl())); |
| 237 | + |
| 238 | + then(userCommandService).should().updateProfileImageUrl(userId, profileImageUrl); |
| 239 | + then(userQueryService).should().getDtoById(userId); |
| 240 | + verifyEveryMocksShouldHaveNoMoreInteractions(); |
| 241 | + } |
| 242 | + |
215 | 243 | private void verifyEveryMocksShouldHaveNoMoreInteractions() {
|
216 | 244 | then(userCommandService).shouldHaveNoMoreInteractions();
|
217 | 245 | then(userQueryService).shouldHaveNoMoreInteractions();
|
|
0 commit comments