use of org.springframework.core.convert.support.DefaultConversionService in project spring-data-commons by spring-projects.
the class DomainClassConverterIntegrationTests method findsRepositoryFactories.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void findsRepositoryFactories() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory() {
@Override
protected BeanWrapper instantiateBean(String beanName, RootBeanDefinition mbd) {
return beanName.equals("repoFactory") ? new BeanWrapperImpl(factory) : super.instantiateBean(beanName, mbd);
}
};
beanFactory.registerBeanDefinition("postProcessor", new RootBeanDefinition(PredictingProcessor.class));
beanFactory.registerBeanDefinition("repoFactory", new RootBeanDefinition(RepositoryFactoryBeanSupport.class));
doReturn(Person.class).when(information).getDomainType();
doReturn(Serializable.class).when(information).getIdType();
doReturn(PersonRepository.class).when(factory).getObjectType();
doReturn(information).when(factory).getRepositoryInformation();
GenericApplicationContext context = new GenericApplicationContext(beanFactory);
context.refresh();
assertThat(context.getBeansOfType(RepositoryFactoryInformation.class).values()).hasSize(1);
DomainClassConverter converter = new DomainClassConverter(new DefaultConversionService());
converter.setApplicationContext(context);
assertThat(converter.matches(TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Person.class))).isTrue();
}
use of org.springframework.core.convert.support.DefaultConversionService in project spring-data-commons by spring-projects.
the class CustomConversionsUnitTests method populatesConversionServiceCorrectly.
// DATACMNS-1035
@Test
public void populatesConversionServiceCorrectly() {
GenericConversionService conversionService = new DefaultConversionService();
CustomConversions conversions = new CustomConversions(StoreConversions.NONE, Arrays.asList(StringToFormatConverter.INSTANCE));
conversions.registerConvertersIn(conversionService);
assertThat(conversionService.canConvert(String.class, Format.class), is(true));
}
use of org.springframework.core.convert.support.DefaultConversionService in project spring-data-commons by spring-projects.
the class CustomConversionsUnitTests method customConverterOverridesDefault.
// DATAMONGO-881, DATACMNS-1035
@Test
public void customConverterOverridesDefault() {
CustomConversions conversions = new CustomConversions(StoreConversions.NONE, Arrays.asList(CustomDateTimeConverter.INSTANCE));
GenericConversionService conversionService = new DefaultConversionService();
conversions.registerConvertersIn(conversionService);
assertThat(conversionService.convert(new DateTime(), Date.class)).isEqualTo(new Date(0));
}
use of org.springframework.core.convert.support.DefaultConversionService in project molgenis by molgenis.
the class PlatformITConfig method conversionService.
@Bean
public ConversionService conversionService() {
DefaultConversionService defaultConversionService = new DefaultConversionService();
defaultConversionService.addConverter(new StringToDateConverter());
defaultConversionService.addConverter(new StringToDateTimeConverter());
return defaultConversionService;
}
use of org.springframework.core.convert.support.DefaultConversionService in project molgenis by molgenis.
the class AclConfig method aclClassIdUtils.
@Bean
public AclClassIdUtils aclClassIdUtils() {
AclClassIdUtils aclClassIdUtils = new AclClassIdUtils();
aclClassIdUtils.setConversionService(new DefaultConversionService());
return aclClassIdUtils;
}
Aggregations