-
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
[DEV-299] GetMemberPurchases EP 마이그레이션 #113
Conversation
dla0510
commented
Jun 7, 2024
•
edited
Loading
edited
- 작업 내용
- GetMemberPurchases EP -> GetMemberAllPurchases, GetMemberPurchase EP로 분리
- 각 EP별 CommandDto, ResultDto, ResponseDto 작성
- PurchaseRepository 수정
- findWithTicketingByMember() 함수 수정
- interface nested projection 구현
- ResultListTransformer를 이용한 class nested projection 방법도 구현했다가 제거... (유지보수 측면에서 불리)
- findWithTicketingByMember() 함수 수정
- 기타 버그 수정
- migration.sql 버그 수정
- Ticket 생성자 버그 수정
- purchase, purchaseItem entity 수정
src/main/java/com/tiketeer/Tiketeer/domain/purchase/PurchaseItem.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
} | ||
|
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.
private <T, R> void checkProperty(T object, Function<T, R> propertyGetter, R expectedValue) {
assertThat(propertyGetter.apply(object)).isEqualTo(expectedValue);
}
checkProperty(results.get(0), Purchase::getTicketingId, ticketing1.getId());
checkProperty(results.get(1), Purchase::getTicketingId, ticketing2.getId());
이건 어떨까요
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.
이 부분을 말씀하신 방법으로 풀어서 작성하면 아래처럼 됩니다.
for (int i = 0; i < 2; i++) {
var purchase = results.get(i);
var ticket = i == 0 ? ticket1 : ticket2;
checkProperty(purchase.getPurchaseItems().getFirst(),
GetMemberPurchase.GetMemberPurchaseItems::getTicketId, ticket.getId());
checkProperty(purchase.getPurchaseItems().getFirst(),
GetMemberPurchase.GetMemberPurchaseItems::getTitle, ticket.getTitle());
checkProperty(purchase.getPurchaseItems().getFirst(),
GetMemberPurchase.GetMemberPurchaseItems::getDescription, ticket.getDescription());
checkProperty(purchase.getPurchaseItems().getFirst(),
GetMemberPurchase.GetMemberPurchaseItems::getPrice, ticket.getPrice());
if (i == 0) {
checkProperty(purchase.getPurchaseItems().get(1),
GetMemberPurchase.GetMemberPurchaseItems::getTicketId, ticket.getId());
checkProperty(purchase.getPurchaseItems().get(1),
GetMemberPurchase.GetMemberPurchaseItems::getTitle, ticket.getTitle());
checkProperty(purchase.getPurchaseItems().get(1),
GetMemberPurchase.GetMemberPurchaseItems::getDescription, ticket.getDescription());
checkProperty(purchase.getPurchaseItems().get(1),
GetMemberPurchase.GetMemberPurchaseItems::getPrice, ticket.getPrice());
}
}
좀 긴가 싶었는데 가독성은 요게 나은 거 같기도 하네요
checkObjectProperty
함수를 워낙 복잡하게 작성해놔서리..
어떻게 생각하시나요?
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.
전 이게 조금 더 보기 좋다고 생각합니다
그리고 원소가 두개인데 for 반복문을 사용할 필요가 있나? 라는 생각도 조금 들구요
따로따로 확인하는건 어떠실지
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.
흠 그럼 테스트 코드가 너무 길어서 되려 가독성이 떨어질 것 같습니다
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.
이것만 있는게 아니고 위에
var purchasePropertyNames = Arrays.asList("ticketingId", "title", "location", "eventTime", "createdAt", "category", "runningMinutes");
for (int i = 0; i < 2; i++) {
var purchase = results.get(i);
var ticketing = i == 0 ? ticketing1 : ticketing2;
for (var p : purchasePropertyNames) {
var comparablePropertyName = p.equals("ticketingId") ? "id" : p;
checkObjectProperty(purchase, p, ticketing, comparablePropertyName);
}
}
이 부분도 있어서요
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.
일단 checkProperty 반영함 확인 ㄱㄱ