From 86e571773219b27d55a35775994cbdd79e0a0355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Tue, 26 Dec 2023 23:49:09 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20dto=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20url=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../friend/dto/response/FriendResponse.java | 1 + .../domain/friend/mapper/FriendMapper.java | 1 + .../domain/group/mapper/GroupMapper.java | 3 +- .../member/dto/response/MemberResponse.java | 3 +- .../domain/member/mapper/MemberMapper.java | 6 ++- .../controller/FriendControllerTest.java | 38 ++++++++-------- .../group/controller/GroupControllerTest.java | 44 +++++++++---------- .../controller/MemberControllerTest.java | 24 +++++----- .../member/service/MemberServiceTest.java | 4 +- .../plan/controller/PlanControllerTest.java | 44 +++++++++---------- 10 files changed, 84 insertions(+), 84 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java b/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java index 583c2e86..765ed09b 100644 --- a/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java @@ -12,4 +12,5 @@ public class FriendResponse { private UUID memberId; private String nickname; + private String profileImage; } diff --git a/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java b/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java index 0193221d..efbde02a 100644 --- a/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java @@ -20,5 +20,6 @@ public interface FriendMapper { @Mapping(target = "memberId", source = "fromMember.id") @Mapping(target = "nickname", source = "fromMember.nickname") + @Mapping(target = "profileImage", source = "fromMember.profileImage") FriendResponse toResponse(Friend friend); } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java b/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java index 8ef36ba3..7b72d055 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java @@ -23,8 +23,9 @@ public interface GroupMapper { Group toGroupEntity(MakeGroupRequest groupDto, Member leader); @Named("groupMemberToMemberResponse") - @Mapping(target = "id", source = "groupMember.member.id") + @Mapping(target = "memberId", source = "groupMember.member.id") @Mapping(target = "nickname", source = "groupMember.member.nickname") + @Mapping(target = "profileImage", source = "groupMember.member.profileImage") MemberResponse toGroupMemberResponse(GroupMember groupMember); @Named("groupMemberToMemberResponseList") diff --git a/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java b/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java index cdba3846..5895fa24 100644 --- a/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java @@ -10,6 +10,7 @@ @Builder @AllArgsConstructor public class MemberResponse { - private UUID id; + private UUID memberId; private String nickname; + private String profileImage; } diff --git a/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java b/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java index d7022063..51ceda6d 100644 --- a/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java @@ -22,6 +22,9 @@ public interface MemberMapper { @Mapping(target = "oauthInfo", source = "oauthRequest", qualifiedByName = "convertOauth") Member toMemberEntity(MemberSaveRequest request); + @Mapping(target = "memberId", source = "member.id") + @Mapping(target = "nickname", source = "member.nickname") + @Mapping(target = "profileImage", source = "member.profileImage") MemberResponse toMemberResponse(Member member); default List toMemberResponses(List members) { @@ -36,7 +39,8 @@ default OAuth2Info convertOauth(OAuthRequest request) { @IterableMapping(elementTargetType = MemberResponse.class) List toMemberResponses(Set planMembers); - @Mapping(target = "id", source = "planMember.member.id") + @Mapping(target = "memberId", source = "planMember.member.id") @Mapping(target = "nickname", source = "planMember.member.nickname") + @Mapping(target = "profileImage", source = "planMember.member.profileImage") MemberResponse toMemberResponse(PlanMember planMember); } diff --git a/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java index d2091039..f5e9b469 100644 --- a/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java @@ -1,25 +1,11 @@ package com.twtw.backend.domain.friend.controller; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import com.twtw.backend.domain.friend.dto.request.FriendRequest; import com.twtw.backend.domain.friend.dto.request.FriendUpdateRequest; import com.twtw.backend.domain.friend.dto.response.FriendResponse; import com.twtw.backend.domain.friend.entity.FriendStatus; import com.twtw.backend.domain.friend.service.FriendService; import com.twtw.backend.support.docs.RestDocsTest; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -30,6 +16,18 @@ import java.util.List; import java.util.UUID; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @DisplayName("FriendController의") @WebMvcTest(FriendController.class) class FriendControllerTest extends RestDocsTest { @@ -41,8 +39,8 @@ void getFriends() throws Exception { // given final List expected = List.of( - new FriendResponse(UUID.randomUUID(), "정해진"), - new FriendResponse(UUID.randomUUID(), "주어진")); + new FriendResponse(UUID.randomUUID(), "정해진", "http://hojiniSelfie"), + new FriendResponse(UUID.randomUUID(), "주어진", "http://hojiniSelfCamera")); given(friendService.getFriends()).willReturn(expected); // when @@ -68,8 +66,8 @@ void getFriendsByStatus() throws Exception { // given final List expected = List.of( - new FriendResponse(UUID.randomUUID(), "호전"), - new FriendResponse(UUID.randomUUID(), "후진")); + new FriendResponse(UUID.randomUUID(), "호전", "http://HJ39Selfie"), + new FriendResponse(UUID.randomUUID(), "후진", "http://HJ39SelfCamera")); given(friendService.getFriendsByStatus(any())).willReturn(expected); // when @@ -158,8 +156,8 @@ void getFriendByName() throws Exception { // given final List expected = List.of( - new FriendResponse(UUID.randomUUID(), "호진정"), - new FriendResponse(UUID.randomUUID(), "진정해")); + new FriendResponse(UUID.randomUUID(), "호진정", "http://hojiniSelfie"), + new FriendResponse(UUID.randomUUID(), "진정해", "http://hojiniSelfCamera")); given(friendService.getFriendByNickname(any())).willReturn(expected); // when diff --git a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java index b54f0da0..f79da15f 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java @@ -1,17 +1,5 @@ package com.twtw.backend.domain.group.controller; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import com.twtw.backend.domain.group.dto.request.*; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; import com.twtw.backend.domain.group.dto.response.ShareInfoResponse; @@ -19,7 +7,6 @@ import com.twtw.backend.domain.group.service.GroupService; import com.twtw.backend.domain.member.dto.response.MemberResponse; import com.twtw.backend.support.docs.RestDocsTest; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -31,6 +18,17 @@ import java.util.List; import java.util.UUID; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @DisplayName("GroupController의") @WebMvcTest(GroupController.class) class GroupControllerTest extends RestDocsTest { @@ -47,8 +45,8 @@ void getGroupById() throws Exception { "HDJ", "GROUP-IMAGE", List.of( - new MemberResponse(UUID.randomUUID(), "DEAN"), - new MemberResponse(UUID.randomUUID(), "ZION-T"))); + new MemberResponse(UUID.randomUUID(), "DEAN", "http://hojiniSelfie"), + new MemberResponse(UUID.randomUUID(), "ZION-T", "http://hojiniSelfie"))); given(groupService.getGroupById(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"))) .willReturn(expected); @@ -76,8 +74,8 @@ void makeGroup() throws Exception { "HDJ", "GROUP-IMAGE", List.of( - new MemberResponse(UUID.randomUUID(), "DEAN"), - new MemberResponse(UUID.randomUUID(), "ZION-T"))); + new MemberResponse(UUID.randomUUID(), "DEAN", "http://hojiniSelfie"), + new MemberResponse(UUID.randomUUID(), "ZION-T", "http://hojiniSelfie"))); given(groupService.makeGroup(any())).willReturn(expected); final ResultActions perform = @@ -135,8 +133,8 @@ void inviteGroup() throws Exception { "홍담진", "http://someUrlToS3", List.of( - new MemberResponse(UUID.randomUUID(), "DEAN"), - new MemberResponse(UUID.randomUUID(), "ZION-T"))); + new MemberResponse(UUID.randomUUID(), "DEAN", "http://hojiniSelfie"), + new MemberResponse(UUID.randomUUID(), "ZION-T", "http://hojiniSelfie"))); given(groupService.inviteGroup(any())).willReturn(expected); // when @@ -296,8 +294,8 @@ void getMyGroups() throws Exception { "BLACK_PINK", "I_LOVE_YOU_LOSE", List.of( - new MemberResponse(UUID.randomUUID(), "LISA"), - new MemberResponse(UUID.randomUUID(), "제니"))); + new MemberResponse(UUID.randomUUID(), "LISA", "http://hojiniSelfieWow"), + new MemberResponse(UUID.randomUUID(), "제니", "http://hojiniSelfieAwesome"))); GroupInfoResponse response2 = new GroupInfoResponse( UUID.randomUUID(), @@ -305,8 +303,8 @@ void getMyGroups() throws Exception { "LE_SSERAFIM", "I_LOVE_YOU_채원", List.of( - new MemberResponse(UUID.randomUUID(), "카즈하"), - new MemberResponse(UUID.randomUUID(), "사쿠라"))); + new MemberResponse(UUID.randomUUID(), "카즈하", "http://hojiniSelfieGreat"), + new MemberResponse(UUID.randomUUID(), "사쿠라", "http://hojiniSelfieGoat"))); responseList.add(response1); responseList.add(response2); diff --git a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java index 11a84786..9c8f1ef6 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java @@ -1,22 +1,10 @@ package com.twtw.backend.domain.member.controller; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import com.twtw.backend.domain.member.dto.response.DuplicateNicknameResponse; import com.twtw.backend.domain.member.dto.response.MemberResponse; import com.twtw.backend.domain.member.dto.response.SearchMemberResponse; import com.twtw.backend.domain.member.service.MemberService; import com.twtw.backend.support.docs.RestDocsTest; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -26,6 +14,16 @@ import java.util.UUID; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @DisplayName("MemberController의") @WebMvcTest(MemberController.class) public class MemberControllerTest extends RestDocsTest { @@ -61,7 +59,7 @@ void searchMemberByNickname() throws Exception { String expectedNickname = "JIN_JOO_ONE"; final MemberResponse memberResponse = - new MemberResponse(UUID.randomUUID(), expectedNickname); + new MemberResponse(UUID.randomUUID(), expectedNickname, "http://HJ39"); final SearchMemberResponse response = new SearchMemberResponse(true, memberResponse); given(memberService.getMemberByNickname(expectedNickname)).willReturn(response); diff --git a/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java index f1396fc5..8a01bfaf 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java @@ -54,7 +54,7 @@ void getResponseByMember() { MemberResponse memberResponse = memberService.getResponseByMember(member); // then - assertThat(memberResponse.getId()).isEqualTo(member.getId()); + assertThat(memberResponse.getMemberId()).isEqualTo(member.getId()); } @Test @@ -68,6 +68,6 @@ void searchMemberByNickname() { memberService.getMemberByNickname(member.getNickname()); // then - assertThat(response.getMemberResponse().getId()).isEqualTo(member.getId()); + assertThat(response.getMemberResponse().getMemberId()).isEqualTo(member.getId()); } } diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java index 1dc30d1a..979fa80a 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java @@ -1,17 +1,5 @@ package com.twtw.backend.domain.plan.controller; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; -import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; import com.twtw.backend.domain.member.dto.response.MemberResponse; import com.twtw.backend.domain.place.entity.CategoryGroupCode; @@ -25,7 +13,6 @@ import com.twtw.backend.domain.plan.dto.response.PlanResponse; import com.twtw.backend.domain.plan.service.PlanService; import com.twtw.backend.support.docs.RestDocsTest; - import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; @@ -38,6 +25,17 @@ import java.util.List; import java.util.UUID; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest; +import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willDoNothing; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @DisplayName("PlanController의") @WebMvcTest(PlanController.class) class PlanControllerTest extends RestDocsTest { @@ -156,10 +154,10 @@ void getPlanById() throws Exception { "홍담진", "http://someUrlToS3", List.of( - new MemberResponse(UUID.randomUUID(), "카즈하"), - new MemberResponse(UUID.randomUUID(), "사쿠라"))), - List.of(new MemberResponse(UUID.randomUUID(), "진호정")), - List.of(new MemberResponse(UUID.randomUUID(), "진정Ho"))); + new MemberResponse(UUID.randomUUID(), "카즈하", "http://HJ39FaceCamera"), + new MemberResponse(UUID.randomUUID(), "사쿠라", "http://HJ39FaceCam"))), + List.of(new MemberResponse(UUID.randomUUID(), "진호정", "http://HJ39Face")), + List.of(new MemberResponse(UUID.randomUUID(), "진정Ho", "http://HJ39Camera"))); given(planService.getPlanById(any())).willReturn(expected); // when @@ -322,10 +320,10 @@ void getPlans() throws Exception { "http://someUrlToS3", List.of( new MemberResponse( - UUID.randomUUID(), "카즈하"), + UUID.randomUUID(), "카즈하", "http://HJ39GOAT"), new MemberResponse( - UUID.randomUUID(), "사쿠라")))) - .members(List.of(new MemberResponse(UUID.randomUUID(), "진호정"))) + UUID.randomUUID(), "사쿠라", "http://HJ39")))) + .members(List.of(new MemberResponse(UUID.randomUUID(), "진호정", "http://HoJin39"))) .build(), PlanInfoResponse.builder() .planId(UUID.randomUUID()) @@ -348,13 +346,13 @@ void getPlans() throws Exception { "http://someUrlToS3", List.of( new MemberResponse( - UUID.randomUUID(), "카즈하"), + UUID.randomUUID(), "카즈하", "http://HJ39"), new MemberResponse( - UUID.randomUUID(), "사쿠라")))) + UUID.randomUUID(), "사쿠라", "http://HJ39")))) .members( List.of( new MemberResponse( - UUID.randomUUID(), "JinHoJeong"))) + UUID.randomUUID(), "JinHoJeong", "http://HJ39"))) .build()); given(planService.getPlans()).willReturn(expected);