diff --git a/src/main/java/com/kusitms/samsion/domain/user/application/dto/response/MyPetResponse.java b/src/main/java/com/kusitms/samsion/domain/user/application/dto/response/MyPetResponse.java index aeecc02..f0a0f94 100644 --- a/src/main/java/com/kusitms/samsion/domain/user/application/dto/response/MyPetResponse.java +++ b/src/main/java/com/kusitms/samsion/domain/user/application/dto/response/MyPetResponse.java @@ -13,14 +13,17 @@ public class MyPetResponse { private String petType; private int petAge; + private String petImageUrl; + @Builder - public MyPetResponse(String userNickname, String petName, String profileImageUrl, String description, String petType, int petAge) { + public MyPetResponse(String userNickname, String petName, String profileImageUrl, String description, String petType, int petAge, String petImageUrl) { this.petName = petName; this.userNickname = userNickname; this.profileImageUrl = profileImageUrl; this.description = description; this.petType = petType; this.petAge = petAge; + this.petImageUrl = petImageUrl; } } diff --git a/src/main/java/com/kusitms/samsion/domain/user/application/mapper/MyPetMapper.java b/src/main/java/com/kusitms/samsion/domain/user/application/mapper/MyPetMapper.java index b79a806..4c2bcac 100644 --- a/src/main/java/com/kusitms/samsion/domain/user/application/mapper/MyPetMapper.java +++ b/src/main/java/com/kusitms/samsion/domain/user/application/mapper/MyPetMapper.java @@ -9,25 +9,26 @@ @Mapper public class MyPetMapper { - public static MyPetResponse mapToMyPetResponse(User user){ - MyPet mypet = user.getMypet(); - return MyPetResponse.builder() - .userNickname(user.getNickname()) - .petName(mypet.getPetName()) - .profileImageUrl(user.getProfileImageUrl()) - .description(mypet.getDescription()) - .petType(mypet.getPetType()) - .petAge(mypet.getPetAge()) - .build(); - } + public static MyPetResponse mapToMyPetResponse(User user) { + MyPet mypet = user.getMypet(); + return MyPetResponse.builder() + .userNickname(user.getNickname()) + .petName(mypet.getPetName()) + .profileImageUrl(user.getProfileImageUrl()) + .description(mypet.getDescription()) + .petType(mypet.getPetType()) + .petAge(mypet.getPetAge()) + .petImageUrl(mypet.getPetImageUrl()) + .build(); + } - public static MyPet mapToMyPetUpdateRequest(MyPetUpdateRequest request, String imageUrl){ - return MyPet.builder() - .petName(request.getPetName()) - .petType(request.getPetType()) - .petAge(request.getPetAge()) - .petImageUrl(imageUrl) - .description(request.getDescription()) - .build(); - } + public static MyPet mapToMyPetUpdateRequest(MyPetUpdateRequest request, String imageUrl) { + return MyPet.builder() + .petName(request.getPetName()) + .petType(request.getPetType()) + .petAge(request.getPetAge()) + .petImageUrl(imageUrl) + .description(request.getDescription()) + .build(); + } } diff --git a/src/main/resources/static/docs/index.html b/src/main/resources/static/docs/index.html index 1c510fc..be37ec9 100644 --- a/src/main/resources/static/docs/index.html +++ b/src/main/resources/static/docs/index.html @@ -914,7 +914,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 181
+Content-Length: 208
{
"userNickname" : "test",
@@ -922,7 +922,8 @@
@@ -973,6 +974,11 @@ String
반려동물 종류
petImageUrl
String
반려동물 이미지 URL
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 219
+Content-Length: 252
{
"userNickname" : "testUpdateNickname",
@@ -1095,7 +1101,8 @@
@@ -1146,6 +1153,11 @@ String
반려동물 종류
petImageUrl
String
반려동물 이미지 URL
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 201
+Content-Length: 192
{
"content" : [ {
@@ -1294,7 +1306,7 @@ POST /question/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer testAccessToken
-Content-Length: 53
+Content-Length: 51
Host: localhost:8080
{
@@ -1389,7 +1401,7 @@ PUT /question/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: Bearer testAccessToken
-Content-Length: 53
+Content-Length: 51
Host: localhost:8080
{
@@ -1596,7 +1608,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 61
+Content-Length: 58
{
"empathyCount" : 1,
@@ -1649,7 +1661,7 @@ POST /album/1/comment HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: access token
-Content-Length: 48
+Content-Length: 46
Host: localhost:8080
{
@@ -1731,7 +1743,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 181
+Content-Length: 174
{
"commentId" : 1,
@@ -1804,7 +1816,7 @@ POST /album/1/comment/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: access token
-Content-Length: 53
+Content-Length: 51
Host: localhost:8080
{
@@ -1890,7 +1902,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 186
+Content-Length: 179
{
"commentId" : 2,
@@ -1963,7 +1975,7 @@ PUT /album/1/comment/1 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Authorization: access token
-Content-Length: 54
+Content-Length: 52
Host: localhost:8080
{
@@ -2049,7 +2061,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 187
+Content-Length: 180
{
"commentId" : 1,
@@ -2268,7 +2280,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 509
+Content-Length: 489
{
"content" : [ {
@@ -2450,7 +2462,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 26
+Content-Length: 24
{
"commentCount" : 1
@@ -2513,7 +2525,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 224
+Content-Length: 213
{
"content" : [ {
@@ -2716,7 +2728,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 357
+Content-Length: 346
{
"imageUrlList" : [ "testAlbumImageUrl" ],
@@ -3218,7 +3230,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 357
+Content-Length: 346
{
"imageUrlList" : [ "testAlbumImageUrl" ],
@@ -3412,7 +3424,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 224
+Content-Length: 213
{
"content" : [ {
@@ -3653,7 +3665,7 @@
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
-Content-Length: 379
+Content-Length: 364
{
"content" : [ {
@@ -3945,7 +3957,7 @@
diff --git a/src/test/java/com/kusitms/samsion/domain/user/presentation/UserControllerTest.java b/src/test/java/com/kusitms/samsion/domain/user/presentation/UserControllerTest.java
index 8f353d5..8e64c32 100644
--- a/src/test/java/com/kusitms/samsion/domain/user/presentation/UserControllerTest.java
+++ b/src/test/java/com/kusitms/samsion/domain/user/presentation/UserControllerTest.java
@@ -1,12 +1,11 @@
package com.kusitms.samsion.domain.user.presentation;
-import static org.mockito.BDDMockito.*;
-import static org.springframework.restdocs.headers.HeaderDocumentation.*;
-import static org.springframework.restdocs.payload.PayloadDocumentation.*;
-import static org.springframework.restdocs.request.RequestDocumentation.*;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-
+import com.kusitms.samsion.common.config.CommonRestDocs;
+import com.kusitms.samsion.common.consts.ApplicationConst;
+import com.kusitms.samsion.common.consts.TestConst;
+import com.kusitms.samsion.domain.user.application.dto.response.MyPetResponse;
+import com.kusitms.samsion.domain.user.application.service.MyPetInfoUseCase;
+import com.kusitms.samsion.domain.user.application.service.MyPetUpdateUseCase;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
@@ -16,12 +15,16 @@
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
-import com.kusitms.samsion.common.consts.ApplicationConst;
-import com.kusitms.samsion.common.consts.TestConst;
-import com.kusitms.samsion.domain.user.application.dto.response.MyPetResponse;
-import com.kusitms.samsion.domain.user.application.service.MyPetInfoUseCase;
-import com.kusitms.samsion.domain.user.application.service.MyPetUpdateUseCase;
-import com.kusitms.samsion.common.config.CommonRestDocs;
+import static org.mockito.BDDMockito.any;
+import static org.mockito.BDDMockito.given;
+import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName;
+import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders;
+import static org.springframework.restdocs.payload.PayloadDocumentation.*;
+import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
+import static org.springframework.restdocs.request.RequestDocumentation.requestParameters;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(UserController.class)
@DisplayName("UserController 테스트")
@@ -42,6 +45,7 @@ public class UserControllerTest extends CommonRestDocs {
.petName(TestConst.TEST_PET_NAME)
.petAge(TestConst.TEST_PET_AGE)
.petType(TestConst.TEST_PET_TYPE)
+ .petImageUrl(TestConst.TEST_PET_IMAGE_URL)
.build();
MockHttpServletRequestBuilder request = get("/user/mypet").header(ApplicationConst.ACCESS_TOKEN_HEADER, TestConst.TEST_ACCESS_TOKEN);
given(myPetInfoUseCase.getMyPetInfo()).willReturn(myPetResponse);
@@ -60,7 +64,8 @@ public class UserControllerTest extends CommonRestDocs {
fieldWithPath("profileImageUrl").description("사용자 이미지 URL"),
fieldWithPath("description").description("반려동물 설명"),
fieldWithPath("petAge").description("반려동물 나이"),
- fieldWithPath("petType").description("반려동물 종류")
+ fieldWithPath("petType").description("반려동물 종류"),
+ fieldWithPath("petImageUrl").description("반려동물 이미지 URL")
)
)
);
@@ -79,6 +84,7 @@ public class UserControllerTest extends CommonRestDocs {
.petName(TestConst.TEST_UPDATE_PET_NAME)
.petAge(TestConst.TEST_UPDATE_PET_AGE)
.petType(TestConst.TEST_UPDATE_PET_TYPE)
+ .petImageUrl(TestConst.TEST_UPDATE_PET_IMAGE_URL)
.build();
given(myPetUpdateUseCase.updateMyPetInfo(any())).willReturn(myPetResponse);
@@ -116,7 +122,8 @@ public class UserControllerTest extends CommonRestDocs {
fieldWithPath("profileImageUrl").description("사용자 이미지 URL"),
fieldWithPath("description").description("반려동물 설명"),
fieldWithPath("petAge").description("반려동물 나이"),
- fieldWithPath("petType").description("반려동물 종류")
+ fieldWithPath("petType").description("반려동물 종류"),
+ fieldWithPath("petImageUrl").description("반려동물 이미지 URL")
)
)
);