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