Skip to content

FINERACT-2576: Add unit test for MoneyTest in fineract-core - #5730

Merged
adamsaghy merged 1 commit into
apache:developfrom
paultofunmi:FINERACT-2576/add-unit-tests-for-moneytests-fineract-core
Apr 2, 2026
Merged

FINERACT-2576: Add unit test for MoneyTest in fineract-core#5730
adamsaghy merged 1 commit into
apache:developfrom
paultofunmi:FINERACT-2576/add-unit-tests-for-moneytests-fineract-core

Conversation

@paultofunmi

@paultofunmi paultofunmi commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a comprehensive MoneyTest suite covering all major operations on the Money class, including parameterized edge cases for floating-point precision.

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

All tests are pure unit tests with no Spring context or database dependencies.

Fixes: https://issues.apache.org/jira/browse/FINERACT-2576

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

@paultofunmi
paultofunmi force-pushed the FINERACT-2576/add-unit-tests-for-moneytests-fineract-core branch from 8b56ccc to 45088f9 Compare April 2, 2026 01:23
@Aman-Mittal
Aman-Mittal requested a review from budaidev April 2, 2026 01:32

@Aman-Mittal Aman-Mittal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, only unit tests are added.

@paultofunmi
paultofunmi force-pushed the FINERACT-2576/add-unit-tests-for-moneytests-fineract-core branch from 45088f9 to 6d7743f Compare April 2, 2026 06:52
@paultofunmi
paultofunmi requested a review from budaidev April 2, 2026 07:38
FINERACT-2576: Add unit test for MoneyTest in fineract-core

Code Review Reactions

FINERACT-2576: Code Review formatting
@paultofunmi
paultofunmi force-pushed the FINERACT-2576/add-unit-tests-for-moneytests-fineract-core branch from 6d7743f to 86e9ec8 Compare April 2, 2026 09:08
@budaidev

budaidev commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

LGTM

@Aman-Mittal
Aman-Mittal requested a review from adamsaghy April 2, 2026 12:39
@Aman-Mittal

Copy link
Copy Markdown
Member

@adamsaghy can you look at this PR. Me and attilia have given our reviews.

@adamsaghy
adamsaghy merged commit 7309e46 into apache:develop Apr 2, 2026
44 checks passed
@paultofunmi
paultofunmi deleted the FINERACT-2576/add-unit-tests-for-moneytests-fineract-core branch April 2, 2026 13:03
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.

5 participants