Skip to content

Conversation

@bongj9
Copy link
Contributor

@bongj9 bongj9 commented Jun 1, 2025

✨ 작업내용

  • 서비스 로직 단위테스트 작성
  • 발견한 예외들을 확인하고 리펙토링 완성
  • 리플렉션을 삭제하고 기본 생성자로 테스트코드에 필요한 필드 생성
  • 테스트에서 발견한 에러 로직 수정

🐞 이슈사항

이슈 번호 제목 상태
#113 결합도가 너무 타이트해서 테스트시 불편함을 겪음 ✅ 해결
#115 리플렉션방식 변경 ✅ 해결

⚠️ 특별사항

  • 단위테스트가 엄청 많았습니다.
  • 제가 놓친 부분이 있으면 코멘트 부탁드립니다. 사람과 ai가 검토를 많이 했습니다 ㅋㅋㅋㅋㅋ

Copy link
Contributor

@caniro caniro left a 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);
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 리플렉션 쓰신 이유가 있으신가요??
이렇게 필드를 설정하면 나중에 필드명 변경하거나 했을 때, 미리 찾을 수 없을 것 같아서요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private 필드로 생성을 해서 테스트에서 접근할려면 리플렉션으로 접근하는게 좋을 것 같아서 구현했는데
찾아보니 안티패턴이 될 수도 있기때문에 지양한다고 하네요ㅠㅠ
다시 수정하고 올리겠습니다!
리뷰 감사합니다

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리플렉션 코드 삭제하고 기본 생성자를 통해 생성했습니다

Copy link
Contributor

@Junh-b Junh-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전반적으로 validation logic이 꼼꼼하게 추가되었네요.
많은 양의 테스트 작성하신 것도 잘 보았습니다.

@109an94
Copy link
Contributor

109an94 commented Jun 2, 2025

아까 남길려고 했는데 저도 리플렉션 썻는데 코멘트 보고 후다닥 바꿨습니다.
코드량 보니깐 엄청 많던데 고생 많으셨습니다 ㄷㄷ

@investfuture-sonarqube1
Copy link

Failed Quality Gate failed

  • 17 New Issues (is greater than 0)

Project ID: CleanEngine_cleanengine-be_2b6f2f63-fa39-426c-b9c7-8aa127fd14d8

View in SonarQube

@Junh-b Junh-b merged commit fcbb726 into dev Jun 4, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants