-
Notifications
You must be signed in to change notification settings - Fork 0
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
GETP-301 feat: 피플 목록 조회 모자이크 기능 추가 #174
Conversation
모자이크를 수행하는 객체마다 assertSoftly를 수행하는 메소드를 만들고, 이를 테스트 메소드에서 조립하는 방식으로 하면 가독성이 좋을 것 같아요! |
if (member.isPeople()) { | ||
return null; | ||
} | ||
return repository.existsByMemberIdAndPeopleId( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
member가 null이 아니면 existsBy(memberId, ...)를 호출하는건 어떨까요?
final Education education = mosaicEducation(mosaicResponse.getEducation()); | ||
final List<String> techStacks = mosaicMessage(mosaicResponse.getHashtags()); | ||
final List<PortfolioResponse> portfolios = mosaicPortfolioResponse(mosaicResponse.getPortfolios()); | ||
mosaicResponse.mosaic(introduction, activityArea, education, techStacks, portfolios); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PeopleProfileDetailResponse의 mosaic()도 this를 반환하도록 통일하는건 어떨까요?
assertSoftly(peopleProfile -> { | ||
peopleProfile.assertThat(mosaicResponse.getProfile().getIntroduction()).hasSameSizeAs(response.getProfile().getIntroduction()); | ||
peopleProfile.assertThat(mosaicResponse.getProfile().getActivityArea()).hasSameSizeAs(response.getProfile().getActivityArea()); | ||
peopleProfile.assertThat(mosaicResponse.getProfile().getTechStacks()) | ||
.extracting(String::length) | ||
.containsExactlyElementsOf(response.getProfile().getTechStacks() | ||
.stream() | ||
.map(String::length) | ||
.toList()); | ||
assertSoftly(education -> { | ||
education.assertThat(mosaicResponse.getProfile().getEducation().getMajor()).hasSameSizeAs(response.getProfile().getEducation().getMajor()); | ||
education.assertThat(mosaicResponse.getProfile().getEducation().getSchool()).hasSameSizeAs(response.getProfile().getEducation().getSchool()); | ||
}); | ||
assertSoftly(portfolios -> { | ||
portfolios.assertThat(mosaicResponse.getProfile().getPortfolios()) | ||
.extracting(portfolio -> portfolio.description().length()) | ||
.containsExactlyElementsOf(response.getProfile().getPortfolios() | ||
.stream() | ||
.map(portfolio -> portfolio.description().length()) | ||
.toList()); | ||
portfolios.assertThat(mosaicResponse.getProfile().getPortfolios()) | ||
.extracting(portfolio -> portfolio.url().length()) | ||
.containsExactlyElementsOf(response.getProfile().getPortfolios() | ||
.stream() | ||
.map(portfolio -> portfolio.url().length()) | ||
.toList()); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
내부에 중첩된 assertSoftly는 메소드로 추출해서 가독성을 살리면 좋을 것 같아요.
assertSoftly(projectDetailResponse -> { | ||
projectDetailResponse.assertThat(mosaicResponse.getDescription()).hasSameSizeAs(response.getDescription()); | ||
projectDetailResponse.assertThat(mosaicResponse.getAttachmentFiles()) | ||
.extracting(String::length) | ||
.containsExactlyElementsOf(response.getAttachmentFiles() | ||
.stream() | ||
.map(String::length) | ||
.toList()); | ||
assertSoftly(client -> { | ||
client.assertThat(mosaicResponse.getClient().clientId()).isEqualTo(null); | ||
client.assertThat(mosaicResponse.getClient().nickname()).hasSameSizeAs(response.getClient().nickname()); | ||
assertSoftly(address -> { | ||
address.assertThat(mosaicResponse.getClient().address().zipcode()).hasSameSizeAs(response.getClient().address().zipcode()); | ||
address.assertThat(mosaicResponse.getClient().address().detail()).hasSameSizeAs(response.getClient().address().detail()); | ||
address.assertThat(mosaicResponse.getClient().address().street()).hasSameSizeAs(response.getClient().address().street()); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마찬가지로 중첩된 assertSoftly는 메소드로 추출하면 좋을 것 같아요!
반영 완료했습니다! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳!
✨ 구현한 기능
📢 논의하고 싶은 내용
test
코드에서 모자이크 전후의 값의 길이를 비교합니다. 이때DTO
에 사용자 정의 타입을 사용하고 있기 때문에,assertSoftly
로 묶어두었습니다. 매개 변수명을 타입에 맞게 작성하여 가독성을 높이는 방법으로 작성하는 게 어떨까요?assertSoftly
로 합치는 과정에서 중복되는DTO
타입이 발생한다면,Util
클래스로 묶는 작업도 해보는 게 어떨까요?🎸 기타
List<String> mosaicMessage
오버 로딩 메서드를MosaicResolverSupport
에 추가하였습니다.