Search in sources :

Example 16 with SampleMappingContext

use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.

the class MappingContextTypeInformationMapperUnitTests method detectsTypeForUnknownEntity.

@Test
public void detectsTypeForUnknownEntity() {
    SampleMappingContext mappingContext = new SampleMappingContext();
    mappingContext.initialize();
    mapper = new MappingContextTypeInformationMapper(mappingContext);
    assertThat(mapper.resolveTypeFrom(Alias.of("foo"))).isNull();
    PersistentEntity<?, SamplePersistentProperty> entity = mappingContext.getRequiredPersistentEntity(Entity.class);
    assertThat(entity).isNotNull();
    assertThat(mapper.resolveTypeFrom(Alias.of("foo"))).isEqualTo(from(Entity.class));
}
Also used : PersistentEntity(org.springframework.data.mapping.PersistentEntity) 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