[
https://issues.apache.org/jira/browse/FINERACT-2576?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tofunmi Oguntibeju updated FINERACT-2576:
-----------------------------------------
Description:
This PR adds a comprehensive {{MoneyTest}} suite covering all major operations
on the {{Money}} class, including parameterized edge cases for floating-point
precision, boundary values, and identity/immutability behaviour.
*Test coverage added:*
* {{plus(double)}} — parameterized cases including negative values and
floating-point precision edge cases
* {{total(Money...)}} varargs — aggregation of multiple {{Money}} instances,
and exception thrown on empty input
* {{total(Iterable<Money>)}} — iterable aggregation including single-element
and empty-list exception cases
* {{roundToMultiplesOf(double, int)}} — parameterized cases plus NaN return
for negative values
* {{roundToMultiplesOf(BigDecimal, Integer)}} — parameterized cases including
zero and negative multiples
* {{roundToMultiplesOf(Money, int)}} — with and without {{{}MathContext{}}},
including zero-multiple passthrough
* {{ceiling(double, double)}} — NaN cases and valid cases covering zero, exact
multiples, and rounding up
* {{floor(double, double)}} — NaN cases and valid cases covering negative step
sizes and floating-point steps
* {{getAmountDefaultedToNullIfZero()}} — null for zero, non-null with correct
value for non-zero
* {{dividedBy(BigDecimal/double/long)}} — identity optimisation (returns same
instance when dividing by 1), correct results for division by 2
* {{multipliedBy(BigDecimal/double/long)}} — with and without
{{{}MathContext{}}}, identity optimisation for multiplier of 1
* {{multiplyRetainScale(BigDecimal/double)}} — scale preservation at currency
decimal places
* {{percentageOf(BigDecimal)}} — 50%, 100%, and 0% cases
* {{negated()}} — positive, negative, and zero (returns same instance for zero)
* {{abs()}} — positive, negative, zero, and with {{MathContext}}
* {{zero()}} — instance method with and without {{MathContext}}
* {{getMc()}} — non-null {{MathContext}} assertion
* {{copy()}} — value equality, same currency, different instance; copy with
{{BigDecimal}} and {{double}} overrides
Effectively increasing test coverage to 81%
was:
MoneyTest has very low test coverage. This PR adds units tests for testing
Plus, Total, Rounding, Ceiling, Floor, DividedBy, MultipliedBy, Abs, Copy and
edge cases.
Effectively increasing test coverage to 81%
> Add unit tests for MoneyTest in fineract-core
> ---------------------------------------------
>
> Key: FINERACT-2576
> URL: https://issues.apache.org/jira/browse/FINERACT-2576
> Project: Apache Fineract
> Issue Type: Test
> Components: Test
> Reporter: Tofunmi Oguntibeju
> Priority: Minor
>
> This PR adds a comprehensive {{MoneyTest}} suite covering all major
> operations on the {{Money}} class, including parameterized edge cases for
> floating-point precision, boundary values, and identity/immutability
> behaviour.
> *Test coverage added:*
> * {{plus(double)}} — parameterized cases including negative values and
> floating-point precision edge cases
> * {{total(Money...)}} varargs — aggregation of multiple {{Money}} instances,
> and exception thrown on empty input
> * {{total(Iterable<Money>)}} — iterable aggregation including single-element
> and empty-list exception cases
> * {{roundToMultiplesOf(double, int)}} — parameterized cases plus NaN return
> for negative values
> * {{roundToMultiplesOf(BigDecimal, Integer)}} — parameterized cases
> including zero and negative multiples
> * {{roundToMultiplesOf(Money, int)}} — with and without {{{}MathContext{}}},
> including zero-multiple passthrough
> * {{ceiling(double, double)}} — NaN cases and valid cases covering zero,
> exact multiples, and rounding up
> * {{floor(double, double)}} — NaN cases and valid cases covering negative
> step sizes and floating-point steps
> * {{getAmountDefaultedToNullIfZero()}} — null for zero, non-null with
> correct value for non-zero
> * {{dividedBy(BigDecimal/double/long)}} — identity optimisation (returns
> same instance when dividing by 1), correct results for division by 2
> * {{multipliedBy(BigDecimal/double/long)}} — with and without
> {{{}MathContext{}}}, identity optimisation for multiplier of 1
> * {{multiplyRetainScale(BigDecimal/double)}} — scale preservation at
> currency decimal places
> * {{percentageOf(BigDecimal)}} — 50%, 100%, and 0% cases
> * {{negated()}} — positive, negative, and zero (returns same instance for
> zero)
> * {{abs()}} — positive, negative, zero, and with {{MathContext}}
> * {{zero()}} — instance method with and without {{MathContext}}
> * {{getMc()}} — non-null {{MathContext}} assertion
> * {{copy()}} — value equality, same currency, different instance; copy with
> {{BigDecimal}} and {{double}} overrides
> Effectively increasing test coverage to 81%
--
This message was sent by Atlassian Jira
(v8.20.10#820010)