use of org.springframework.data.mapping.context.SamplePersistentProperty in project spring-data-commons by spring-projects.
the class ConvertingPropertyAccessorUnitTests method getIdProperty.
private static SamplePersistentProperty getIdProperty() {
SampleMappingContext mappingContext = new SampleMappingContext();
BasicPersistentEntity<Object, SamplePersistentProperty> entity = mappingContext.getRequiredPersistentEntity(Entity.class);
return entity.getPersistentProperty("id");
}
use of org.springframework.data.mapping.context.SamplePersistentProperty in project spring-data-commons by spring-projects.
the class BasicPersistentEntityUnitTests method detectsPropertyWithAnnotation.
// DATACMNS-365
@Test
public void detectsPropertyWithAnnotation() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
SamplePersistentProperty property = entity.getPersistentProperty(LastModifiedBy.class);
assertThat(property.getName()).isEqualTo("field");
property = entity.getPersistentProperty(CreatedBy.class);
assertThat(property.getName()).isEqualTo("property");
assertThat(entity.getPersistentProperty(CreatedDate.class)).isNull();
}
use of org.springframework.data.mapping.context.SamplePersistentProperty in project spring-data-commons by spring-projects.
the class BasicPersistentEntityUnitTests method supportsSubtypeInstancesOnPropertyAccessorLookup.
// DATACMNS-597
@Test
public void supportsSubtypeInstancesOnPropertyAccessorLookup() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
assertThat(entity.getPropertyAccessor(new Subtype())).isNotNull();
}
use of org.springframework.data.mapping.context.SamplePersistentProperty in project spring-data-commons by spring-projects.
the class BasicPersistentEntityUnitTests method returnsBeanWrapperForPropertyAccessor.
// DATACMNS-596
@Test
public void returnsBeanWrapperForPropertyAccessor() {
assumeThat(System.getProperty("java.version"), CoreMatchers.startsWith("1.6"));
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
Entity value = new Entity();
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(value);
assertThat(accessor).isInstanceOf(BeanWrapper.class);
assertThat(accessor.getBean()).isEqualTo(value);
}
use of org.springframework.data.mapping.context.SamplePersistentProperty in project spring-data-commons by spring-projects.
the class AnnotationBasedPersistentPropertyUnitTests method cachesNonPresenceOfAnnotationOnField.
// DATACMNS-677
@Test
@SuppressWarnings("unchecked")
public void cachesNonPresenceOfAnnotationOnField() {
SamplePersistentProperty property = getProperty(Sample.class, "getterWithoutField");
assertThat(property).satisfies(it -> {
assertThat(it.findAnnotation(MyAnnotation.class)).isNull();
Map<Class<?>, ?> field = (Map<Class<?>, ?>) ReflectionTestUtils.getField(it, "annotationCache");
assertThat(field.containsKey(MyAnnotation.class)).isTrue();
assertThat(field.get(MyAnnotation.class)).isEqualTo(Optional.empty());
});
}
Aggregations