20260125 #196 백테스팅 dto 예외처리 테스트 리팩토링#197
Conversation
…simpleCondition), 필수 값 누락 예외 처리 (validateOperand_exception), 지원하지 않는 지표 예외 처리 (createIndicator_unknownCode) 에 대한 테스트 코드 작성
Walkthrough여러 백테스트 DTO를 클래스에서 Java 레코드로 전환하고, TradeType enum을 도입했으며, Ta4jHelperService 및 BacktestingEngine에서 레코드 접근자와 CustomException 기반 예외 처리를 적용하고 관련 테스트를 추가/수정했습니다. Changes
Sequence Diagram(s)(생성 조건 미충족 — 생략) Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/src/main/java/org/sejongisc/backend/backtest/service/Ta4jHelperService.java (1)
207-212: MACD 지표의 output이 null일 때 NullPointerException 발생 위험StrategyOperand의 output 필드는 선택사항이며 null 값이 가능합니다. 현재 코드는 207-212줄의 switch 문에서 직접
operand.output()을 사용하여 null일 경우 NPE가 발생합니다. 같은 파일의 BB 지표(227줄)처럼 null을 처리하여 기본값을 제공해야 합니다.🛠️ 수정 제안
- return switch (operand.output()) { + String output = operand.output(); + return switch (output == null ? "macd" : output) { case "macd" -> macd; case "signal" -> signalLine; case "hist" -> new ManualMACDHistogramIndicator(macd, signalLine); default -> macd; };
🤖 Fix all issues with AI agents
In
`@backend/src/test/java/org/sejongisc/backend/backtest/service/Ta4jHelperServiceTest.java`:
- Around line 71-73: The right StrategyOperand is being constructed with null
for its params but the StrategyOperand.params field is `@NotNull` and should
receive an empty map when there are no params; update the right StrategyOperand
construction to pass Map.of() instead of null (mirroring how the left operand is
created) so the params constraint and the comment "비어있더라도 {} 전달" are satisfied.
backend/src/test/java/org/sejongisc/backend/backtest/service/Ta4jHelperServiceTest.java
Show resolved
Hide resolved
|
고생하셨습니다 ! 토끼 리뷰만 반영하면 될 것 같아용 ~~ |
Yooonjeong
left a comment
There was a problem hiding this comment.
record로 변경하니 깔끔하고 좋네여 고생하셨습니당~
efbfa0a
Refactor
DTO 구조 개선 (Java Record 도입): StrategyCondition, StrategyOperand, TradeLog, BacktestRunMetricsResponse 등을 record로 변환하여 코드를 간소화했습니다.
Enum 분리: TradeLog 내부에 있던 거래 유형을 TradeType Enum으로 분리하여 가독성과 재사용성을 높였습니다.
서비스 로직 동기화: Record 변환에 맞춰 Ta4jHelperService와 BacktestingEngine의 데이터 접근 방식(Getter)을 수정했습니다 (getXXX() → XXX()).
예외 처리 표준화: Ta4jHelperService에서 발생하던 IllegalArgumentException을 CustomException(ErrorCode)으로 교체하여 에러 응답을 통일했습니다.(500->400)
Test
Summary by CodeRabbit
Bug Fixes / Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.