use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class BasicPersistentEntityUnitTests method rejectsNonMatchingBeanForPropertyAccessor.
// DATACMNS-596
@Test(expected = IllegalArgumentException.class)
public void rejectsNonMatchingBeanForPropertyAccessor() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
entity.getPropertyAccessor("foo");
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class BasicPersistentEntityUnitTests method reportsRequiredPropertyName.
// DATACMNS-1122
@Test
public void reportsRequiredPropertyName() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
assertThatThrownBy(() -> entity.getRequiredPersistentProperty("foo")).hasMessageContaining("Required property foo not found");
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class PersistentEntityInformationUnitTests method obtainsIdAndIdTypeInformationFromPersistentEntity.
// DATACMNS-480
@Test
public void obtainsIdAndIdTypeInformationFromPersistentEntity() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Sample.class);
EntityInformation<Object, Long> information = new PersistentEntityInformation<>(entity);
assertThat(information.getIdType()).isEqualTo(Long.class);
Sample sample = new Sample();
sample.id = 5L;
assertThat(information.getId(sample)).isEqualTo(5L);
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class PersistentEntityInformationUnitTests method returnsNullIfNoIdPropertyPresent.
// DATACMNS-596
@Test
public void returnsNullIfNoIdPropertyPresent() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(EntityWithoutId.class);
PersistentEntityInformation<Object, Serializable> information = new PersistentEntityInformation<>(entity);
assertThat(information.getId(new EntityWithoutId())).isNull();
}
use of org.springframework.data.mapping.context.SampleMappingContext in project spring-data-commons by spring-projects.
the class MappingContextTypeInformationMapperUnitTests method createsTypeMapperForGenericTypesWithDifferentBindings.
// DATACMNS-485
@Test
@SuppressWarnings("unchecked")
public void createsTypeMapperForGenericTypesWithDifferentBindings() {
AnnotatedTypeScanner scanner = new AnnotatedTypeScanner(TypeAlias.class);
SampleMappingContext context = new SampleMappingContext();
context.setInitialEntitySet(scanner.findTypes(getClass().getPackage().getName()));
context.initialize();
new MappingContextTypeInformationMapper(context);
}
Aggregations