Skip to content

Commit

Permalink
refactor: 소울메이트 결과 fixture 등록
Browse files Browse the repository at this point in the history
- 회원을 기반으로 소울메이트 결과를 추출한 fixture 등록
  • Loading branch information
devholic22 committed Aug 13, 2024
1 parent d175b63 commit 0a2af7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
package com.atwoz.survey.fixture;

import com.atwoz.member.domain.member.Member;
import com.atwoz.survey.infrastructure.membersurvey.dto.SurveySoulmateResponse;

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()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -79,7 +80,8 @@ public List<SurveySoulmateResponse> 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);
}
}

Expand All @@ -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);
Expand Down

0 comments on commit 0a2af7c

Please sign in to comment.