Search in sources :

Example 6 with SampleMappingContext

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);
}
Also used : PersistentEntities(org.springframework.data.mapping.context.PersistentEntities) SampleMappingContext(org.springframework.data.mapping.context.SampleMappingContext) Before(org.junit.Before)

Example 7 with SampleMappingContext

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();
}
Also used : SampleMappingContext(org.springframework.data.mapping.context.SampleMappingContext) Test(org.junit.Test)

Example 8 with SampleMappingContext

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();
}
Also used : SampleMappingContext(org.springframework.data.mapping.context.SampleMappingContext) Test(org.junit.Test)

Example 9 with SampleMappingContext

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);
}
Also used : SamplePersistentProperty(org.springframework.data.mapping.context.SamplePersistentProperty) SampleMappingContext(org.springframework.data.mapping.context.SampleMappingContext) Test(org.junit.Test)

Example 10 with SampleMappingContext

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);
}
Also used : PersistentEntity(org.springframework.data.mapping.PersistentEntity) PersistentPropertyAccessor(org.springframework.data.mapping.PersistentPropertyAccessor) SamplePersistentProperty(org.springframework.data.mapping.context.SamplePersistentProperty) SampleMappingContext(org.springframework.data.mapping.context.SampleMappingContext) Test(org.junit.Test)

Aggregations

SampleMappingContext (org.springframework.data.mapping.context.SampleMappingContext)16 Test (org.junit.Test)13 SamplePersistentProperty (org.springframework.data.mapping.context.SamplePersistentProperty)11 PersistentEntity (org.springframework.data.mapping.PersistentEntity)3 Before (org.junit.Before)2 PersistentPropertyAccessor (org.springframework.data.mapping.PersistentPropertyAccessor)2 Serializable (java.io.Serializable)1 CreatedBy (org.springframework.data.annotation.CreatedBy)1 PersistentEntities (org.springframework.data.mapping.context.PersistentEntities)1 AnnotatedTypeScanner (org.springframework.data.util.AnnotatedTypeScanner)1