Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ private String validateText(final String value, final String fieldName) {
}

private BigDecimal validateTotalAmount(final BigDecimal value) {
if (value.compareTo(BigDecimal.ZERO) <= 0) {
throw new IllegalArgumentException("totalAmount must be greater than zero");
if (value.compareTo(BigDecimal.ZERO) < 0) {
throw new IllegalArgumentException("totalAmount must be greater than minus");
Comment on lines +131 to +132

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

예외 메시지인 "totalAmount must be greater than minus"는 영문법상 어색하며 의미가 모호합니다. 음수를 허용하지 않는다는 의도를 명확히 하기 위해 "totalAmount must be non-negative" 또는 "totalAmount must be greater than or equal to zero"로 변경하는 것이 좋습니다.

또한, 이 변경으로 인해 기존 TransferTest.javachangeTotalAmount_zeroOrNegative_throws 테스트(금액이 0일 때 예외 발생을 검증하는 테스트)가 실패하게 됩니다. 테스트 코드도 이번 변경 사항에 맞춰 함께 수정해 주세요.

Suggested change
if (value.compareTo(BigDecimal.ZERO) < 0) {
throw new IllegalArgumentException("totalAmount must be greater than minus");
if (value.compareTo(BigDecimal.ZERO) < 0) {
throw new IllegalArgumentException("totalAmount must be non-negative");
}

}
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ void changeAccountHolder_blank_throws() {
}

@Test
@DisplayName("changeTotalAmount는 0 이하 금액이면 예외를 던진다")
void changeTotalAmount_zeroOrNegative_throws() {
@DisplayName("changeTotalAmount는 0을 허용하고 음수 금액이면 예외를 던진다")
void changeTotalAmount_allowsZeroAndRejectsNegative() {
Transfer transfer = transfer();

assertThatThrownBy(() -> transfer.changeTotalAmount(BigDecimal.ZERO))
.isInstanceOf(IllegalArgumentException.class);
transfer.changeTotalAmount(BigDecimal.ZERO);

assertThat(transfer.getTotalAmount()).isEqualByComparingTo(BigDecimal.ZERO);
assertThatThrownBy(() -> transfer.changeTotalAmount(new BigDecimal("-1")))
.isInstanceOf(IllegalArgumentException.class);
}
Expand Down
Loading