DATAJPA-716 - Strengthened tests for updatability detection in JpaPersistentProperty.

Added negative check, too, and tweaked implementation to actually correctly detect the updatability.
This commit is contained in:
Oliver Gierke
2015-05-19 13:47:17 +02:00
parent 5caab71b97
commit 92d8baac15
2 changed files with 5 additions and 3 deletions

View File

@@ -292,11 +292,11 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty<JpaPer
Annotation annotation = findAnnotation(annotationType);
if (annotation != null && AnnotationUtils.getValue(annotation, "updateable") == Boolean.TRUE) {
return true;
if (annotation != null && AnnotationUtils.getValue(annotation, "updatable").equals(Boolean.FALSE)) {
return false;
}
}
return false;
return true;
}
}

View File

@@ -188,6 +188,7 @@ public class JpaPersistentPropertyImplUnitTests {
@Test
public void considersNonUpdateablePropertyNotWriteable() {
assertThat(getProperty(WithReadOnly.class, "name").isWritable(), is(false));
assertThat(getProperty(WithReadOnly.class, "updatable").isWritable(), is(true));
}
private JpaPersistentProperty getProperty(Class<?> ownerType, String propertyName) {
@@ -311,5 +312,6 @@ public class JpaPersistentPropertyImplUnitTests {
static class WithReadOnly {
@Column(updatable = false) String name;
String updatable;
}
}