From 0a2af7c36e8d707718b1814d89f4f0a836d0cc76 Mon Sep 17 00:00:00 2001 From: devholic22 Date: Tue, 13 Aug 2024 09:59:32 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=86=8C=EC=9A=B8=EB=A9=94?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EA=B2=B0=EA=B3=BC=20fixture=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 회원을 기반으로 소울메이트 결과를 추출한 fixture 등록 --- .../fixture/SurveySoulmateResponseFixture.java | 11 +++++++++++ .../membersurvey/MemberSurveysFakeRepository.java | 14 +++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/atwoz/survey/fixture/SurveySoulmateResponseFixture.java b/src/test/java/com/atwoz/survey/fixture/SurveySoulmateResponseFixture.java index 7126bfdf..5521fc8c 100644 --- a/src/test/java/com/atwoz/survey/fixture/SurveySoulmateResponseFixture.java +++ b/src/test/java/com/atwoz/survey/fixture/SurveySoulmateResponseFixture.java @@ -1,5 +1,6 @@ package com.atwoz.survey.fixture; +import com.atwoz.member.domain.member.Member; import com.atwoz.survey.infrastructure.membersurvey.dto.SurveySoulmateResponse; public class SurveySoulmateResponseFixture { @@ -7,4 +8,14 @@ public class SurveySoulmateResponseFixture { public static SurveySoulmateResponse 소울메이트_응답() { return new SurveySoulmateResponse(1L, "nickname", "서울시", "강남구", 25); } + + public static SurveySoulmateResponse 소울메이트_응답_회원(final Member member) { + return new SurveySoulmateResponse( + member.getId(), + member.getNickname(), + member.getMemberProfile().getProfile().getLocation().getCity(), + member.getMemberProfile().getProfile().getLocation().getSector(), + member.getMemberProfile().getProfile().getPhysicalProfile().getAge() + ); + } } diff --git a/src/test/java/com/atwoz/survey/infrastructure/membersurvey/MemberSurveysFakeRepository.java b/src/test/java/com/atwoz/survey/infrastructure/membersurvey/MemberSurveysFakeRepository.java index 14d2bd2f..32ee109d 100644 --- a/src/test/java/com/atwoz/survey/infrastructure/membersurvey/MemberSurveysFakeRepository.java +++ b/src/test/java/com/atwoz/survey/infrastructure/membersurvey/MemberSurveysFakeRepository.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import static com.atwoz.survey.fixture.SurveySoulmateResponseFixture.소울메이트_응답_회원; public class MemberSurveysFakeRepository implements MemberSurveysRepository { @@ -79,7 +80,8 @@ public List findSoulmates(final Long memberId) { for (MemberSurveys otherMemberSurveys : otherMembers) { if (isSameAnswer(memberSurveys, otherMemberSurveys)) { Member otherMember = findMemberById(otherMemberSurveys.getMemberId()); - result.add(convertSurveySoulmateResponse(otherMember)); + SurveySoulmateResponse response = 소울메이트_응답_회원(otherMember); + result.add(response); } } @@ -100,16 +102,6 @@ private boolean isSameAnswer(final MemberSurveys memberSurveys, final MemberSurv return same >= MINIMUM_MATCH_SIZE; } - private SurveySoulmateResponse convertSurveySoulmateResponse(final Member member) { - return new SurveySoulmateResponse( - member.getId(), - member.getNickname(), - member.getMemberProfile().getProfile().getLocation().getCity(), - member.getMemberProfile().getProfile().getLocation().getSector(), - member.getMemberProfile().getProfile().getPhysicalProfile().getAge() - ); - } - private Member findMemberById(final Long memberId) { return memberRepository.findById(memberId) .orElseThrow(MemberNotFoundException::new);