Search in sources :

Example 1 with SampleMappingContext

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

the class AnnotationBasedPersistentPropertyUnitTests method setUp.

@Before
public void setUp() {
    context = new SampleMappingContext();
    entity = context.getRequiredPersistentEntity(Sample.class);
}
Also used : SampleMappingContext(org.springframework.data.mapping.context.SampleMappingContext) Before(org.junit.Before)

Example 2 with SampleMappingContext

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

Example 3 with SampleMappingContext

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

Example 4 with SampleMappingContext

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

Example 5 with SampleMappingContext

use of org.springframework.data.mapping.context.SampleMappingContext 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);
}
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