You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Have an abstract ValueObject class that defines equals and hashCode
accordingly using EqualsBuilder and HashCodeBuilder:
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
public abstract class ValueObject {
@Override
public final boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public final int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
2. And a simple subclass:
public class A extends ValueObject {
private final int a;
private final int b;
public A(int a, int b) {
this.a = a;
this.b = b;
}
public int getA() {
return this.a;
}
public int getB() {
return this.b;
}
}
3. Being tested with EqualsVerifier like this:
public class ATest {
@Test
public void equalsContract() throws Exception {
EqualsVerifier.forClass(A.class)
.withRedefinedSuperclass()
.allFieldsShouldBeUsed()
.verify();
}
}
What is the code (equals method, hashCode method, relevant fields) that
triggers the problem?
Available in the first answer.
What error message does EqualsVerifier give?
java.lang.AssertionError: Significant fields: all fields should be used, but A
has not defined an equals method.
This exception is not thrown if I don't set allFieldsShouldBeUsed, but then the
test wouldn't guarantee that all fields are indeed being used.
What stacktrace does EqualsVerifier print, when called with the debug()
method?
java.lang.AssertionError: Significant fields: all fields should be used, but A
has not defined an equals method.
For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:378)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:361)
What did you expect?
Passing test.
What version of EqualsVerifier are you using?
1.5.1
Please provide any additional information below.
See conversation in google group:
https://groups.google.com/forum/#!topic/equalsverifier/StWs2oybPAo
Original issue reported on code.google.com by andre.sc...@gmail.com on 8 Jan 2015 at 3:31
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
andre.sc...@gmail.com
on 8 Jan 2015 at 3:31The text was updated successfully, but these errors were encountered: