Skip to content

Conversation

@RVRhub
Copy link
Contributor

@RVRhub RVRhub commented May 20, 2024

PR Modify the enrichment provider classes map in BaseFaker to store a complete list of generated FakerContext.
: #1190

This allows you to store multiple locals for one class in the net.datafaker.providers.base.BaseFaker#CLASSES map.
Before this, every call to the net.datafaker.providers.base.BaseFaker#getProvider(java.lang.Class, java.util.function.Function<PR,AP>, PR) method would overwrite the map for one class name, making the cache ineffective.

@what-the-diff
Copy link

what-the-diff bot commented May 20, 2024

PR Summary

  • Enhanced reliability in 'BaseFaker' class
    In the BaseFaker.java file, the class BaseFaker has been updated to improve its stability and reliability. Previously, this class directly modified the CLASSES map using the put method. This has been replaced with putIfAbsent method, which adds a new item into the map only if that key does not already exist. This change prevents unnecessary overwriting and ensures that the uniqueness of the map keys is maintained.

  • Added new test for verifying multiple context handling
    A new test method testMultipleFakerContextsPerOneClassName has been added in CustomFakerTest.java file to check the correct handling of multiple contexts within a single class name. This test essentially generates two different instances of the BaseFaker class, each with distinct locales, and checks whether a service provider associated with the 'Insect' class can be acquired successfully in both instances. This test will enhance the robustness of our platform by ensuring that the service doesn't fail when handling multiple contexts for a single class name.

@codecov-commenter
Copy link

codecov-commenter commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.22%. Comparing base (b37c566) to head (3dadede).
Report is 100 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1198      +/-   ##
============================================
- Coverage     92.35%   92.22%   -0.13%     
- Complexity     2821     2905      +84     
============================================
  Files           292      301       +9     
  Lines          5609     5750     +141     
  Branches        599      620      +21     
============================================
+ Hits           5180     5303     +123     
- Misses          275      290      +15     
- Partials        154      157       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@snuyanzin snuyanzin left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @RVRhub

I've run about 25 times (each run contains 9 jobs) the ci and all the runs are passed
https://github.com/datafaker-net/datafaker/actions/runs/9165081403
So it looks pretty stable

@snuyanzin snuyanzin merged commit 05b7efb into datafaker-net:main May 20, 2024
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.

3 participants