Skip to content

FINERACT-2534: Add unit tests for StreamUtil utility class#5624

Open
devi-pathak2263 wants to merge 1 commit intoapache:developfrom
devi-pathak2263:add-streamutil-tests
Open

FINERACT-2534: Add unit tests for StreamUtil utility class#5624
devi-pathak2263 wants to merge 1 commit intoapache:developfrom
devi-pathak2263:add-streamutil-tests

Conversation

@devi-pathak2263
Copy link

@devi-pathak2263 devi-pathak2263 commented Mar 15, 2026

Description

This PR adds unit tests for the StreamUtil utility class in fineract-core.

The following methods are covered:

  • foldLeft collector functionality
  • mergeMapsOfLists collector functionality

These tests verify that:

  • 'foldLeft' correctly reduces a stream using the provided accumulator and preserves order
  • 'mergeMapsOfLists' correctly merges maps with list values by concatenating lists for identical keys
  • merging behavior works for both duplicate and distinct keys
  • the resulting map is mutable
  • behavior is correct for empty streams

This improves test coverage and ensures the correctness of commonly used utility collectors.

JIRA: https://issues.apache.org/jira/browse/FINERACT-2534

##Testing

Executed locally:
./gradlew spotlessApply
./gradlew :fineract-core

Checklist

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

@adamsaghy
Copy link
Contributor

@devi-pathak2263 Please squash your commits.

@devi-pathak2263
Copy link
Author

@devi-pathak2263 Please squash your commits.

Thanks for the feedback. I have squashed the commits into a single commit.

@adamsaghy
Copy link
Contributor

@devi-pathak2263 Can you please:

  • Set the commit email address to match with your github account email address?
  • Set GPG signature for commit?

@devi-pathak2263 devi-pathak2263 force-pushed the add-streamutil-tests branch 2 times, most recently from 01f24d2 to 7794b2e Compare March 17, 2026 11:27
@devi-pathak2263
Copy link
Author

@devi-pathak2263 Can you please:

  • Set the commit email address to match with your github account email address?
  • Set GPG signature for commit?

I have now:

  • updated the commit author email to match my GitHub account
  • amended the commit with a GPG signature

The latest commit should now be verified. Let me know if anything else needs improvement.

Add unit tests for:
- foldLeft collector functionality (including order-sensitive behavior)
- mergeMapsOfLists collector functionality

Enhancements:
- Added test to verify foldLeft preserves order
- Added tests for merging maps with duplicate and different keys
- Added test to verify result map is mutable
- Avoided reliance on ordering guarantees from Collectors.toMap
- Ensured use of mutable lists in tests

Improves reliability and test coverage for StreamUtil.
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