-
Notifications
You must be signed in to change notification settings - Fork 2
[BE] 차트데이터의 서비스 로직의 모든 단위테스트 및 리펙토링 추가 #114
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
Conversation
검증을 추가해서 NUll로 들어온다면 NPE를 발생시키게 수정했습니다.
caniro
left a comment
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.
와 리팩토링이랑 테스트 많이 하셨네요 ㅋㅋ 고생하셨습니다 ㅠㅠ
| if (yesterdayLastTrade == null) { | ||
| log.debug("전일 거래 데이터가 없습니다: {}", ticker); | ||
| return new PrevRateDto(ticker, 0.0, currentTrade.getPrice(), 0.0, LocalDateTime.now()); | ||
| return new PrevRateDto(ticker, 0.0, currentTrade.getPrice(), 0.0, currentTime); |
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 void setField(Object target, String fieldName, Object value) throws Exception { | ||
| java.lang.reflect.Field field = Trade.class.getDeclaredField(fieldName); | ||
| field.setAccessible(true); | ||
| field.set(target, value); |
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.
private 필드로 생성을 해서 테스트에서 접근할려면 리플렉션으로 접근하는게 좋을 것 같아서 구현했는데
찾아보니 안티패턴이 될 수도 있기때문에 지양한다고 하네요ㅠㅠ
다시 수정하고 올리겠습니다!
리뷰 감사합니다
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.
리플렉션 코드 삭제하고 기본 생성자를 통해 생성했습니다
Junh-b
left a comment
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.
전반적으로 validation logic이 꼼꼼하게 추가되었네요.
많은 양의 테스트 작성하신 것도 잘 보았습니다.
|
아까 남길려고 했는데 저도 리플렉션 썻는데 코멘트 보고 후다닥 바꿨습니다. |

✨ 작업내용
🐞 이슈사항