Fix: Change Balance fields from Double to BigDecimal#35
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Balance resource to represent monetary amounts using BigDecimal instead of Double, and adjusts the corresponding test assertions to compare BigDecimal values correctly.
Changes:
- Changed
totalBalance,balance, andcreditinBalancefromDoubletoBigDecimal - Updated
BalanceTestassertions to useisEqualByComparingTowithBigDecimalexpectations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/main/java/com/didww/sdk/resource/Balance.java |
Switches balance-related monetary fields and getters from Double to BigDecimal. |
src/test/java/com/didww/sdk/resource/BalanceTest.java |
Updates assertions to compare BigDecimal values rather than floating-point values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static com.github.tomakehurst.wiremock.client.WireMock.*; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
There was a problem hiding this comment.
Import ordering is inconsistent with the rest of the test suite (e.g., AddressTest groups non-static imports first, then static imports). java.math.BigDecimal should be placed with the other non-static imports above the static imports to match the project’s import style / avoid checkstyle failures.
| import static org.assertj.core.api.Assertions.assertThat; | |
| import static com.github.tomakehurst.wiremock.client.WireMock.*; | |
| import java.math.BigDecimal; | |
| import java.math.BigDecimal; | |
| import static org.assertj.core.api.Assertions.assertThat; | |
| import static com.github.tomakehurst.wiremock.client.WireMock.*; |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @JsonProperty("total_balance") | ||
| private Double totalBalance; | ||
| private BigDecimal totalBalance; |
There was a problem hiding this comment.
Changing totalBalance/balance/credit from Double to BigDecimal (and the corresponding getter return types) is a breaking public API change for SDK consumers. Please ensure any in-repo callers (e.g., examples/README snippets) are updated accordingly, and consider providing a backwards-compatible path (e.g., deprecated Double-returning accessors or a documented major version bump/release note) so downstream users aren’t surprised by compilation failures.
| import com.didww.sdk.repository.ApiResponse; | ||
| import org.junit.jupiter.api.Test; | ||
| import java.math.BigDecimal; | ||
|
|
There was a problem hiding this comment.
Import grouping is inconsistent with other tests in this package (they don’t separate regular imports from static imports with an extra blank line). Consider removing the blank line after import java.math.BigDecimal; to keep import formatting consistent.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public Double getCredit() { | ||
| public BigDecimal getCredit() { | ||
| return credit; | ||
| } |
There was a problem hiding this comment.
Changing the public getter return types from Double to BigDecimal is a breaking API change for SDK consumers (compile-time). If backwards compatibility is required, consider keeping the Double getters (deprecated) or adding alternate getters (e.g., getTotalBalanceAsDouble()) and documenting the migration/release versioning accordingly.
| } | |
| } | |
| @Deprecated | |
| public Double getTotalBalanceAsDouble() { | |
| return totalBalance != null ? totalBalance.doubleValue() : null; | |
| } | |
| @Deprecated | |
| public Double getBalanceAsDouble() { | |
| return balance != null ? balance.doubleValue() : null; | |
| } | |
| @Deprecated | |
| public Double getCreditAsDouble() { | |
| return credit != null ? credit.doubleValue() : null; | |
| } |
Move java.math.BigDecimal above static imports to match project conventions.
4504fc9 to
b5637f3
Compare
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public BigDecimal getTotalBalance() { | ||
| return totalBalance; | ||
| } | ||
|
|
||
| public Double getBalance() { | ||
| public BigDecimal getBalance() { |
There was a problem hiding this comment.
Changing these getters from Double to BigDecimal is a source/binary breaking change for SDK consumers (method signature change). If the library intends to remain backward compatible, consider keeping the Double getters (deprecated) and adding new BigDecimal-named accessors, or ensure the release/versioning/docs explicitly treat this as a breaking change.



Summary
totalBalance,balance, andcreditfields fromDoubletoBigDecimalisEqualByComparingTofor BigDecimal comparisonTest plan