use of cn.taketoday.format.support.ApplicationConversionService in project today-framework by TAKETODAY.
the class BeanFactoryTests method beforeEach.
@BeforeEach
public void beforeEach() throws IOException {
context = new StandardApplicationContext();
ApplicationPropertySourcesProcessor processor = new ApplicationPropertySourcesProcessor(context);
processor.setPropertiesLocation("info.properties");
processor.postProcessEnvironment();
context.scan("cn.taketoday.beans.factory", "test.demo.config");
context.refresh();
beanFactory = context.getBeanFactory();
beanFactory.setConversionService(new ApplicationConversionService());
}
use of cn.taketoday.format.support.ApplicationConversionService in project today-framework by TAKETODAY.
the class ConversionServiceDeducerTests method getConversionServiceWhenHasNoConversionServiceBeanAndNoQualifiedBeansAndBeanFactoryConversionServiceContainsOnlyBeanFactoryInstance.
@Test
void getConversionServiceWhenHasNoConversionServiceBeanAndNoQualifiedBeansAndBeanFactoryConversionServiceContainsOnlyBeanFactoryInstance() {
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(EmptyConfiguration.class);
ConversionService conversionService = new ApplicationConversionService();
applicationContext.getBeanFactory().setConversionService(conversionService);
ConversionServiceDeducer deducer = new ConversionServiceDeducer(applicationContext);
List<ConversionService> conversionServices = deducer.getConversionServices();
assertThat(conversionServices).containsOnly(conversionService);
assertThat(conversionServices.get(0)).isSameAs(conversionService);
}
use of cn.taketoday.format.support.ApplicationConversionService in project today-framework by TAKETODAY.
the class ConversionServiceDeducer method getConversionServices.
private List<ConversionService> getConversionServices(ConfigurableApplicationContext applicationContext) {
List<ConversionService> conversionServices = new ArrayList<>();
if (applicationContext.getBeanFactory().getConversionService() != null) {
conversionServices.add(applicationContext.getBeanFactory().getConversionService());
}
ConverterBeans converterBeans = new ConverterBeans(applicationContext);
if (!converterBeans.isEmpty()) {
ApplicationConversionService beansConverterService = new ApplicationConversionService();
converterBeans.addTo(beansConverterService);
conversionServices.add(beansConverterService);
}
return conversionServices;
}
use of cn.taketoday.format.support.ApplicationConversionService in project today-infrastructure by TAKETODAY.
the class ConversionServiceDeducer method getConversionServices.
private List<ConversionService> getConversionServices(ConfigurableApplicationContext applicationContext) {
List<ConversionService> conversionServices = new ArrayList<>();
if (applicationContext.getBeanFactory().getConversionService() != null) {
conversionServices.add(applicationContext.getBeanFactory().getConversionService());
}
ConverterBeans converterBeans = new ConverterBeans(applicationContext);
if (!converterBeans.isEmpty()) {
ApplicationConversionService beansConverterService = new ApplicationConversionService();
converterBeans.addTo(beansConverterService);
conversionServices.add(beansConverterService);
}
return conversionServices;
}
use of cn.taketoday.format.support.ApplicationConversionService in project today-infrastructure by TAKETODAY.
the class ConversionServiceDeducerTests method getConversionServiceWhenHasNoConversionServiceBeanAndNoQualifiedBeansAndBeanFactoryConversionServiceContainsOnlyBeanFactoryInstance.
@Test
void getConversionServiceWhenHasNoConversionServiceBeanAndNoQualifiedBeansAndBeanFactoryConversionServiceContainsOnlyBeanFactoryInstance() {
ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext(EmptyConfiguration.class);
ConversionService conversionService = new ApplicationConversionService();
applicationContext.getBeanFactory().setConversionService(conversionService);
ConversionServiceDeducer deducer = new ConversionServiceDeducer(applicationContext);
List<ConversionService> conversionServices = deducer.getConversionServices();
assertThat(conversionServices).containsOnly(conversionService);
assertThat(conversionServices.get(0)).isSameAs(conversionService);
}
Aggregations