use of org.springframework.data.mapping.model.EntityInstantiators in project spring-data-ldap by spring-projects.
the class PartTreeLdapRepositoryQueryTests method assertFilterAndBaseForMethod.
private void assertFilterAndBaseForMethod(Method targetMethod, String expectedFilter, String expectedBase, Object... expectedParams) {
LdapQueryMethod queryMethod = new LdapQueryMethod(targetMethod, repositoryMetadata, factory);
PartTreeLdapRepositoryQuery tested = new PartTreeLdapRepositoryQuery(queryMethod, entityClass, ldapTemplate, new LdapMappingContext(), new EntityInstantiators());
LdapQuery query = tested.createQuery(new LdapParametersParameterAccessor(queryMethod, expectedParams));
String base = query.base().toString();
assertThat(base).isEqualTo(expectedBase);
assertThat(query.filter().encode()).isEqualTo(expectedFilter);
}
use of org.springframework.data.mapping.model.EntityInstantiators in project spring-data-geode by spring-projects.
the class MappingPdxSerializerUnitTests method setEntityInstantiatorsWithNonNullEntityInstantiators.
@Test
public void setEntityInstantiatorsWithNonNullEntityInstantiators() {
EntityInstantiators mockEntityInstantiators = mock(EntityInstantiators.class);
this.pdxSerializer.setEntityInstantiators(mockEntityInstantiators);
assertThat(this.pdxSerializer.getEntityInstantiators()).isSameAs(mockEntityInstantiators);
}
use of org.springframework.data.mapping.model.EntityInstantiators in project spring-data-geode by spring-projects.
the class MappingPdxSerializerUnitTests method resolveEntityInstantiatorForNonManagedPersistentEntityWithNoEntityInstantiator.
@Test
@SuppressWarnings("rawtypes")
public void resolveEntityInstantiatorForNonManagedPersistentEntityWithNoEntityInstantiator() {
EntityInstantiator mockEntityInstantiator = mock(EntityInstantiator.class);
EntityInstantiators mockEntityInstantiators = mock(EntityInstantiators.class);
PersistentEntity mockEntity = mock(PersistentEntity.class);
doReturn(mockEntityInstantiators).when(this.pdxSerializer).getEntityInstantiators();
assertThat(this.pdxSerializer.resolveEntityInstantiator(mockEntity)).isNotEqualTo(mockEntityInstantiator);
verify(this.pdxSerializer, times(1)).getEntityInstantiators();
verify(mockEntityInstantiators, times(1)).getInstantiatorFor(eq(mockEntity));
verifyNoInteractions(mockEntityInstantiator);
verifyNoInteractions(mockEntity);
}
use of org.springframework.data.mapping.model.EntityInstantiators in project spring-data-geode by spring-projects.
the class MappingPdxSerializerUnitTests method resolveEntityInstantiatorForManagedPersistentEntityWithEntityInstantiator.
@Test
@SuppressWarnings("rawtypes")
public void resolveEntityInstantiatorForManagedPersistentEntityWithEntityInstantiator() {
EntityInstantiator mockEntityInstantiator = mock(EntityInstantiator.class);
EntityInstantiators mockEntityInstantiators = mock(EntityInstantiators.class);
PersistentEntity mockEntity = mock(PersistentEntity.class);
doReturn(mockEntityInstantiators).when(this.pdxSerializer).getEntityInstantiators();
doReturn(mockEntityInstantiator).when(mockEntityInstantiators).getInstantiatorFor(eq(mockEntity));
assertThat(this.pdxSerializer.resolveEntityInstantiator(mockEntity)).isEqualTo(mockEntityInstantiator);
verify(this.pdxSerializer, times(1)).getEntityInstantiators();
verify(mockEntityInstantiators, times(1)).getInstantiatorFor(eq(mockEntity));
verifyNoInteractions(mockEntityInstantiator);
verifyNoInteractions(mockEntity);
}
use of org.springframework.data.mapping.model.EntityInstantiators in project spring-data-commons by spring-projects.
the class InstantiationAwarePersistentPropertyAccessorUnitTests method shouldSetMultipleProperties.
// DATACMNS-1768
@Test
void shouldSetMultipleProperties() {
EntityInstantiators instantiators = new EntityInstantiators();
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Sample.class);
Sample bean = new Sample("Dave", "Matthews", 42);
PersistentPropertyAccessor<Sample> wrapper = new InstantiationAwarePropertyAccessor<>(bean, entity::getPropertyAccessor, instantiators);
wrapper.setProperty(entity.getRequiredPersistentProperty("firstname"), "Oliver August");
wrapper.setProperty(entity.getRequiredPersistentProperty("lastname"), "Heisenberg");
assertThat(wrapper.getBean()).isEqualTo(new Sample("Oliver August", "Heisenberg", 42));
}
Aggregations