Skip to content

Commit

Permalink
test: 부정확했던 테스트 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
eom-tae-in committed Aug 13, 2024
1 parent 8740582 commit 4a66ac6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
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

0 comments on commit 4a66ac6

Please sign in to comment.