Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 부정확했던 테스트 방식 변경 #52

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class MemberQueryServiceTest {
@BeforeEach
void setup() {
HobbyRepository hobbyRepository = new HobbyFakeRepository();
memberRepository = new MemberFakeRepository();
memberQueryService = new MemberQueryService(memberRepository, hobbyRepository);
memberLikeRepository = new MemberLikeFakeRepository();
memberRepository = new MemberFakeRepository(memberLikeRepository);
memberQueryService = new MemberQueryService(memberRepository, hobbyRepository);
member = memberRepository.save(회원_생성());
uniqueMemberFieldsGenerator = new UniqueMemberFieldsGenerator();
취미_목록_생성(hobbyRepository);
Expand Down Expand Up @@ -152,7 +152,7 @@ class 닉네임_중복_확인 {
ProfileFilterRequest profileFilterRequest = 프로필_필터_요청서_생성();
Long memberId = member.getId();
Member newMember = memberRepository.save(새로운_이성_회원_생성());
memberLikeRepository.save(호감_생성_id_주입(newMember.getId(), memberId));
memberLikeRepository.save(호감_생성_id_주입(memberId, newMember.getId()));

// when
ProfileResponse profileResponse = memberQueryService.findProfileByPopularity(profileFilterRequest, memberId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.atwoz.member.infrastructure.member.dto.InternalProfileFilterRequest;
import com.atwoz.member.infrastructure.member.dto.MemberResponse;
import com.atwoz.member.infrastructure.member.dto.ProfileResponse;
import com.atwoz.memberlike.domain.MemberLikeRepository;
import com.atwoz.memberlike.infrastructure.MemberLikeFakeRepository;
import java.time.LocalDate;
import java.util.ArrayList;
Expand All @@ -32,7 +33,15 @@ public class MemberFakeRepository implements MemberRepository {

private final Map<Long, Member> map = new HashMap<>();
private Long id = 1L;
private final MemberLikeFakeRepository memberLikeFakeRepository = new MemberLikeFakeRepository();
private final MemberLikeRepository memberLikeFakeRepository;

public MemberFakeRepository(final MemberLikeRepository memberLikeFakeRepository) {
this.memberLikeFakeRepository = memberLikeFakeRepository;
}

public MemberFakeRepository() {
this.memberLikeFakeRepository = new MemberLikeFakeRepository();
}

@Override
public Optional<Member> findById(final Long id) {
Expand Down Expand Up @@ -93,7 +102,7 @@ public ProfileResponse findProfileByPopularity(final InternalProfileFilterReques
.filter(member -> applyFilterConditions(internalProfileFilterRequest, member))
.filter(member -> isDifferentGender(member, foundMember))
.sorted(Comparator.comparing(member ->
memberLikeFakeRepository.findReceivedLikesWithPaging(memberId, pageable)
memberLikeFakeRepository.findReceivedLikesWithPaging(member.getId(), pageable)
.getTotalElements()
))
.map(ProfileResponseFixture::프로필_응답서_생성_회원)
Expand Down
Loading