Skip to content

Conversation

@pleasebelieveme
Copy link
Owner

@pleasebelieveme pleasebelieveme commented Nov 3, 2025

  • 문자열을 정수로 변환
  • 입력 null, 빈 문자열, 숫자가 아닌 문자가 포함된 경우 예외 처리

Summary by CodeRabbit

개선 사항

  • 기능 개선

    • 구입 금액 입력 처리 개선: 널 값, 공백, 비숫자 입력 등 다양한 유효하지 않은 입력에 대해 명확한 오류 메시지 제공
  • 테스트

    • 정상 입력과 비정상 입력 시나리오에 대한 테스트 케이스 추가로 안정성 향상

@pleasebelieveme pleasebelieveme merged commit bad53ba into main Nov 3, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 3, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

구입 금액 입력을 파싱하고 검증하는 새로운 유틸리티 클래스 PurchaseAmountParser를 도입합니다. null/빈 값 검증 후 정수 변환을 수행하며, 각 단계의 실패 시 한글 에러 메시지를 포함한 예외를 발생시킵니다.

Changes

Cohort / File(s) Summary
파서 유틸리티 클래스
src/main/java/lotto/parser/PurchaseAmountParser.java
구입 금액 문자열 파싱 및 검증 로직 추가. parse(String) 메서드에서 null/공백 입력 검증 후 parseToInteger(String)으로 위임. 유효하지 않은 입력 시 IllegalArgumentException 또는 NumberFormatException 발생
파서 테스트 클래스
src/test/java/lotto/parser/PurchaseAmountParserTest.java
JUnit 5 및 AssertJ를 사용한 테스트 스위트. 유효한 입력 파싱, null 입력, 공백 입력, 비숫자 입력에 대한 예외 검증 포함

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PurchaseAmountParser
    participant Integer Parser

    Client->>PurchaseAmountParser: parse(input)
    
    rect rgb(200, 220, 255)
    Note over PurchaseAmountParser: Validation Phase
    alt input is null or empty
        PurchaseAmountParser-->>Client: IllegalArgumentException<br/>[ERROR] 구입 금액을 입력해주세요.
    else input is valid (non-empty)
        PurchaseAmountParser->>PurchaseAmountParser: parseToInteger(input)
    end
    end
    
    rect rgb(200, 255, 220)
    Note over PurchaseAmountParser: Parsing Phase
    alt input is numeric
        PurchaseAmountParser->>Integer Parser: Integer.parseInt(input)
        Integer Parser-->>PurchaseAmountParser: int value
        PurchaseAmountParser-->>Client: return int
    else input is non-numeric
        PurchaseAmountParser-->>Client: NumberFormatException<br/>[ERROR] 구입 금액은 숫자여야 합니다.
    end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • 단순한 문자열 검증 및 변환 로직으로 구성
  • 테스트 케이스가 충분하고 예상 동작이 명확함
  • 기존 코드베이스와의 상호작용이 최소화되어 있음

Poem

🐰 구입 금액을 슉- 파싱하고,
숫자 아닌 건 쏙- 걸러내고,
오류 메시지 한글로 예쁘게,
테스트도 촘촘히 갖춰있네,
이제 안심하고 당첨 꿈꿀 수 있지! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pleasebelieveme

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d8cbbf and e655f23.

📒 Files selected for processing (2)
  • src/main/java/lotto/parser/PurchaseAmountParser.java (1 hunks)
  • src/test/java/lotto/parser/PurchaseAmountParserTest.java (1 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants