use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class MappingAuditableBeanWrapperFactoryUnitTests method setUp.
@Before
public void setUp() {
SampleMappingContext context = new SampleMappingContext();
context.getPersistentEntity(Sample.class);
context.getPersistentEntity(SampleWithInstant.class);
PersistentEntities entities = new PersistentEntities(Collections.singleton(context));
factory = new MappingAuditableBeanWrapperFactory(entities);
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class MappingContextTypeInformationMapperUnitTests method doesNotReturnTypeAliasForSimpleType.
@Test
public void doesNotReturnTypeAliasForSimpleType() {
SampleMappingContext mappingContext = new SampleMappingContext();
mappingContext.initialize();
mapper = new MappingContextTypeInformationMapper(mappingContext);
assertThat(mapper.createAliasFor(from(String.class)).isPresent()).isFalse();
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class MappingContextTypeInformationMapperUnitTests method extractsAliasForUnknownType.
@Test
public void extractsAliasForUnknownType() {
SampleMappingContext mappingContext = new SampleMappingContext();
mappingContext.initialize();
mapper = new MappingContextTypeInformationMapper(mappingContext);
assertThat(mapper.createAliasFor(from(Entity.class)).hasValue("foo")).isTrue();
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class BasicPersistentEntityUnitTests method rejectsNullBeanForPropertyAccessor.
// DATACMNS-596
@Test(expected = IllegalArgumentException.class)
public void rejectsNullBeanForPropertyAccessor() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
entity.getPropertyAccessor(null);
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class BasicPersistentEntityUnitTests method returnsGeneratedPropertyAccessorForPropertyAccessor.
// DATACMNS-809
@Test
public void returnsGeneratedPropertyAccessorForPropertyAccessor() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
Entity value = new Entity();
PersistentPropertyAccessor accessor = entity.getPropertyAccessor(value);
assertThat(accessor).isNotInstanceOf(BeanWrapper.class);
assertThat(accessor.getClass().getName()).contains("_Accessor_");
assertThat(accessor.getBean()).isEqualTo(value);
}
Aggregations