DATACMNS-121 - Implement equals(…) and hashCode() of AbstractPersistentProperty.
Implemented equals(…) and hashCode() methods based on the field backing the property.
This commit is contained in:
@@ -78,6 +78,34 @@ public class AbstractPersistentPropertyUnitTests {
|
||||
assertThat(property.isEntity(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-121
|
||||
*/
|
||||
@Test
|
||||
public void considersPropertiesEqualIfFieldEquals() {
|
||||
|
||||
Field first = ReflectionUtils.findField(FirstConcrete.class, "genericField");
|
||||
Field second = ReflectionUtils.findField(SecondConcrete.class, "genericField");
|
||||
|
||||
SamplePersistentProperty firstProperty = new SamplePersistentProperty(first, null, entity, typeHolder);
|
||||
SamplePersistentProperty secondProperty = new SamplePersistentProperty(second, null, entity, typeHolder);
|
||||
|
||||
assertThat(firstProperty, is(secondProperty));
|
||||
assertThat(firstProperty.hashCode(), is(secondProperty.hashCode()));
|
||||
}
|
||||
|
||||
class Generic<T> {
|
||||
T genericField;
|
||||
}
|
||||
|
||||
class FirstConcrete extends Generic<String> {
|
||||
|
||||
}
|
||||
|
||||
class SecondConcrete extends Generic<Integer> {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class TestClassSet extends TreeSet<Object> {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user