The EqualsBuilder.reflectionEquals
method isn't able to apply the same test of equality via reflection to the SecondLevel class field. You will need to override equals
(and therefore hashCode
) in the SecondLevel class for this to pass.
If you can't override equals, and you are happy to add another dependency to your project then you could also look at the ReflectionAssert.assertReflectionEquals
method in the Unitils library:
http://www.unitils.org/apidocs/org/unitils/reflectionassert/ReflectionAssert.html