Implement createUniqueInstance method and improve tests#10
Merged
Conversation
Added a method to create unique instances of a given class to avoid conflicts in POJO tests.
Add test for incorrect getter returning wrong field type.
Removed unnecessary blank line at the beginning of the file.
kapilasrikanth
approved these changes
Jun 30, 2026
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.
Creates an instance for clazz and applies increaseValue up to uniquenessIndex times, producing a value that is distinct from instances created with a lower index. Guards against null and ClassCastException returns from changers (stopping the loop early when the changer chain can't produce further distinct values).
GetterTester.java — set a unique value per field before asserting the getter
Replaced the simple forEach with an IntStream.range so each field gets a positional index. Before invoking the getter, FieldUtils.setValue writes a unique value (createUniqueInstance(field.getType(), fieldIndex)) into the field on the shared instance. This ensures:
A copy-paste getter returning the wrong field will now produce a mismatch → test fails as expected.
Was package-private (class), changed to public class so the regression test can reference it.
Added Should_Fail_When_Getter_Returns_Wrong_Field_Of_Same_Type, which tests a POJO where getFieldB() erroneously returns fieldA, and asserts that the tester now throws GetterAssertionError.