Skip to content

Commit

Permalink
[FEAT] dto 프로필 이미지 url 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Dec 26, 2023
1 parent b92ce8e commit 86e5717
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
public class FriendResponse {
private UUID memberId;
private String nickname;
private String profileImage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@Builder
@AllArgsConstructor
public class MemberResponse {
private UUID id;
private UUID memberId;
private String nickname;
private String profileImage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<MemberResponse> toMemberResponses(List<Member> members) {
Expand All @@ -36,7 +39,8 @@ default OAuth2Info convertOauth(OAuthRequest request) {
@IterableMapping(elementTargetType = MemberResponse.class)
List<MemberResponse> toMemberResponses(Set<PlanMember> 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);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand All @@ -41,8 +39,8 @@ void getFriends() throws Exception {
// given
final List<FriendResponse> 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
Expand All @@ -68,8 +66,8 @@ void getFriendsByStatus() throws Exception {
// given
final List<FriendResponse> 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
Expand Down Expand Up @@ -158,8 +156,8 @@ void getFriendByName() throws Exception {
// given
final List<FriendResponse> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
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;
import com.twtw.backend.domain.group.dto.response.SimpleGroupInfoResponse;
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;
Expand All @@ -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 {
Expand All @@ -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);

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -296,17 +294,17 @@ 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(),
leaderId,
"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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
}
}
Loading

0 comments on commit 86e5717

Please sign in to comment.