From 158e07d311d63869a5e30753587e9d150d723369 Mon Sep 17 00:00:00 2001 From: tlarbals824 Date: Thu, 25 May 2023 17:00:37 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EB=B0=98=ED=99=98=EC=8B=9C=20=ED=8E=AB?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20url=20=ED=8F=AC=ED=95=A8=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/MyPetResponse.java | 5 +- .../user/application/mapper/MyPetMapper.java | 41 +++++++------- src/main/resources/static/docs/index.html | 56 +++++++++++-------- .../user/presentation/UserControllerTest.java | 37 +++++++----- 4 files changed, 81 insertions(+), 58 deletions(-) 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 7937d41..26378a1 100644 --- a/src/main/resources/static/docs/index.html +++ b/src/main/resources/static/docs/index.html @@ -908,7 +908,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 181
+Content-Length: 208
 
 {
   "userNickname" : "test",
@@ -916,7 +916,8 @@ 

@@ -967,6 +968,11 @@

String

반려동물 종류

+ +

petImageUrl

+

String

+

반려동물 이미지 URL

+ @@ -1081,7 +1087,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 219
+Content-Length: 252
 
 {
   "userNickname" : "testUpdateNickname",
@@ -1089,7 +1095,8 @@ 

@@ -1140,6 +1147,11 @@

String

반려동물 종류

+ +

petImageUrl

+

String

+

반려동물 이미지 URL

+ @@ -1213,7 +1225,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 201
+Content-Length: 192
 
 {
   "content" : [ {
@@ -1288,7 +1300,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 { @@ -1383,7 +1395,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 { @@ -1590,7 +1602,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 61
+Content-Length: 58
 
 {
   "empathyCount" : 1,
@@ -1643,7 +1655,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 { @@ -1725,7 +1737,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 181
+Content-Length: 174
 
 {
   "commentId" : 1,
@@ -1798,7 +1810,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 { @@ -1884,7 +1896,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 186
+Content-Length: 179
 
 {
   "commentId" : 2,
@@ -1957,7 +1969,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 { @@ -2043,7 +2055,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 187
+Content-Length: 180
 
 {
   "commentId" : 1,
@@ -2262,7 +2274,7 @@ 

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 509
+Content-Length: 489
 
 {
   "content" : [ {
@@ -2444,7 +2456,7 @@ 

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 26
+Content-Length: 24
 
 {
   "commentCount" : 1
@@ -2507,7 +2519,7 @@ 

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 224
+Content-Length: 213
 
 {
   "content" : [ {
@@ -2710,7 +2722,7 @@ 

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 357
+Content-Length: 346
 
 {
   "imageUrlList" : [ "testAlbumImageUrl" ],
@@ -3212,7 +3224,7 @@ 

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 357
+Content-Length: 346
 
 {
   "imageUrlList" : [ "testAlbumImageUrl" ],
@@ -3406,7 +3418,7 @@ 

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 224
+Content-Length: 213
 
 {
   "content" : [ {
@@ -3647,7 +3659,7 @@ 

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 379
+Content-Length: 364
 
 {
   "content" : [ {
@@ -3755,7 +3767,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") ) ) );