-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#203 added EQUALS_FAST and HASH_CODE_FAST #205
Conversation
Now it is possible to test equals() and hashCode() in quadratic rather than exponential time (and 20^2 is much better than 2^20 for a POJO with 20 fields corresponding to 20 columns in a DB table). The old thorough testers are preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've provided code formatter rules, so please reformat your code.
} | ||
|
||
// @TestFactory | ||
// public Stream<DynamicTest> Should_Generate_Different_Objects_Recursively() throws IllegalAccessException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove those tests or make them pass
@Test | ||
public void Should_Generate_Different_Objects_For_Class_Containing_Boolean_Type() { | ||
// given | ||
final ObjectGenerator objectGenerator = new ObjectGenerator(abstractFieldValueChanger, constructorParameters); | ||
final ObjectGenerator objectGenerator = makeObjectGenerator(abstractFieldValueChanger, constructorParameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove parameters abstractFieldValueChanger
and constructorParameters
as they are always the same.
|
||
public HashCodeFastTester() { | ||
super(); | ||
setThoroughTesting(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://stackoverflow.com/a/3404369
You can create protected constructor in HashCodeTester
with boolean parameter and then call super(true)
Same in EqualsFastTester
|
||
public ObjectGenerator(final AbstractFieldValueChanger abstractFieldValueChanger, | ||
final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters) { | ||
final MultiValuedMap<Class<?>, ConstructorParameters> constructorParameters, | ||
final boolean thorough) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to pass some kind of policy, that would generate fields / list of fields e.g.
interface Permutator { public List<List<T>> permutate(final List<T> listToPermutate);}
class ThoroughFieldPermutator implements Permutator {}
class SublistFieldPermutator implements Permutator {}
I think that the second approach is better. |
Now it is possible to test equals() and hashCode() in quadratic rather
than exponential time (and 20^2 is much better than 2^20 for a POJO
with 20 fields corresponding to 20 columns in a DB table).
The old thorough testers are preserved.