Skip to content
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

Closed

Conversation

36893488147419103231
Copy link
Contributor

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.

Your Name added 4 commits August 26, 2017 21:37
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.
Copy link
Owner

@sta-szek sta-szek left a 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 {
Copy link
Owner

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);
Copy link
Owner

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);
Copy link
Owner

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) {
Copy link
Owner

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 {}

@sta-szek
Copy link
Owner

I think that the second approach is better.

@sta-szek sta-szek closed this Nov 4, 2017
@ghost ghost removed the in progress label Nov 4, 2017
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.

None yet

2 participants