Open
Conversation
seongahjo
reviewed
Nov 11, 2025
...ure-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/random/DeterministicRandom.java
Outdated
Show resolved
Hide resolved
seongahjo
reviewed
Nov 11, 2025
...ure-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/random/DeterministicRandom.java
Outdated
Show resolved
Hide resolved
seongahjo
reviewed
Nov 11, 2025
| import org.apiguardian.api.API.Status; | ||
|
|
||
| @API(since = "1.1.16", status = Status.MAINTAINED) | ||
| public class DeterministicRandom extends Random { |
Contributor
There was a problem hiding this comment.
I think it would be better to create a new interface for obtaining the Random instance and the seed value.
It is to avoid using the DeterministicRandom directly.
Contributor
Author
There was a problem hiding this comment.
Thank you for your feedback! 🙂
I created a new interface named RandomSource to obtain Random instances and seed values.
I also implemented DeterministicRandomSource that encapsulates the caching logic,
so the internal implementation is no longer exposed.
7077b4a to
237fa16
Compare
38a7176 to
84e0308
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement DeterministicRandom class with seed-based Random instance caching for deterministic test reproducibility.
Description
DeterministicRandomclass that extendsRandomnextLong()generated values as keysgetRandomInstance(long seed)to retrieve cached Random instances by seedgetCurrentSeedRandom()to get the Random instance for the current seedHow Has This Been Tested?
./gradlew :fixture-monkey-api:testpasses successfullynextLong(), instance retrieval, cache size limit (≤32), deterministic behavior, and seed independenceIs the Document updated?
Not yet.