DATACMNS-1122 - Improve message for absent required property in PersistentEntity.getRequiredPersistentProperty(…).
Exception message now contains the property name.
This commit is contained in:
@@ -151,7 +151,7 @@ public interface PersistentEntity<T, P extends PersistentProperty<P>> extends It
|
||||
return property;
|
||||
}
|
||||
|
||||
throw new IllegalStateException(String.format("Required identifier property not found for %s!", getType()));
|
||||
throw new IllegalStateException(String.format("Required property %s not found for %s!", name, getType()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -165,6 +165,16 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
|
||||
assertThat(entity.getPersistentProperty(CreatedDate.class)).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1122
|
||||
public void reportsRequiredPropertyName() {
|
||||
|
||||
SampleMappingContext context = new SampleMappingContext();
|
||||
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
|
||||
|
||||
assertThatThrownBy(() -> entity.getRequiredPersistentProperty("foo"))
|
||||
.hasMessageContaining("Required property foo not found");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-596
|
||||
public void returnsBeanWrapperForPropertyAccessor() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user