Search in sources :

Example 46 with DefaultConversionService

use of org.springframework.core.convert.support.DefaultConversionService in project spring-integration by spring-projects.

the class BeanFactoryTypeConverterTests method testDelegateWithTargetUUID.

@Test
public void testDelegateWithTargetUUID() {
    DefaultConversionService conversionService = new DefaultConversionService();
    BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(conversionService);
    UUID uuid = UUID.randomUUID();
    Object converted = typeConverter.convertValue(uuid.toString(), TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(UUID.class));
    assertEquals(uuid, converted);
}
Also used : DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) UUID(java.util.UUID) Test(org.junit.Test)

Example 47 with DefaultConversionService

use of org.springframework.core.convert.support.DefaultConversionService in project spring-integration by spring-projects.

the class BeanFactoryTypeConverterTests method testEditorWithTargetFoo.

@Test
public void testEditorWithTargetFoo() {
    DefaultConversionService conversionService = new DefaultConversionService();
    final Foo foo = new Foo();
    conversionService.addConverter(new Converter<String, Foo>() {

        @Override
        public Foo convert(String source) {
            return foo;
        }
    });
    BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(conversionService);
    UUID uuid = UUID.randomUUID();
    Object convertedFoo = typeConverter.convertValue(uuid, TypeDescriptor.valueOf(UUID.class), TypeDescriptor.valueOf(Foo.class));
    assertSame(foo, convertedFoo);
}
Also used : DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) UUID(java.util.UUID) Test(org.junit.Test)

Example 48 with DefaultConversionService

use of org.springframework.core.convert.support.DefaultConversionService in project spring-integration by spring-projects.

the class BeanFactoryTypeConverterTests method testNullArg.

@Test
public void testNullArg() {
    DefaultConversionService conversionService = new DefaultConversionService();
    BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(conversionService);
    Object foo = typeConverter.convertValue(null, null, TypeDescriptor.valueOf(Bar.class));
    assertNull(foo);
}
Also used : DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) Test(org.junit.Test)

Example 49 with DefaultConversionService

use of org.springframework.core.convert.support.DefaultConversionService in project spring-integration by spring-projects.

the class BeanFactoryTypeConverterTests method testEditorWithTargetString.

@Test
public void testEditorWithTargetString() {
    DefaultConversionService conversionService = new DefaultConversionService();
    BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(conversionService);
    UUID uuid = UUID.randomUUID();
    Object foo = typeConverter.convertValue(uuid, TypeDescriptor.valueOf(UUID.class), TypeDescriptor.valueOf(String.class));
    assertEquals(uuid.toString(), foo);
}
Also used : DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) UUID(java.util.UUID) Test(org.junit.Test)

Example 50 with DefaultConversionService

use of org.springframework.core.convert.support.DefaultConversionService in project spring-integration by spring-projects.

the class DatatypeChannelTests method unsupportedTypeButConversionServiceSupports.

@Test
public void unsupportedTypeButConversionServiceSupports() {
    QueueChannel channel = createChannel(Integer.class);
    ConversionService conversionService = new DefaultConversionService();
    DefaultDatatypeChannelMessageConverter converter = new DefaultDatatypeChannelMessageConverter();
    converter.setConversionService(conversionService);
    channel.setMessageConverter(converter);
    assertTrue(channel.send(new GenericMessage<String>("123")));
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) ConversionService(org.springframework.core.convert.ConversionService) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) DefaultConversionService(org.springframework.core.convert.support.DefaultConversionService) DefaultDatatypeChannelMessageConverter(org.springframework.integration.support.converter.DefaultDatatypeChannelMessageConverter) Test(org.junit.Test)

Aggregations

DefaultConversionService (org.springframework.core.convert.support.DefaultConversionService)84 Test (org.junit.jupiter.api.Test)37 Test (org.junit.Test)29 ConversionService (org.springframework.core.convert.ConversionService)13 MethodParameter (org.springframework.core.MethodParameter)12 GenericConversionService (org.springframework.core.convert.support.GenericConversionService)12 ConfigurableWebBindingInitializer (org.springframework.web.bind.support.ConfigurableWebBindingInitializer)12 WebDataBinderFactory (org.springframework.web.bind.support.WebDataBinderFactory)12 DefaultDataBinderFactory (org.springframework.web.bind.support.DefaultDataBinderFactory)11 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)9 RequestParam (org.springframework.web.bind.annotation.RequestParam)9 Optional (java.util.Optional)8 BeforeEach (org.junit.jupiter.api.BeforeEach)6 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)6 HashMap (java.util.HashMap)5 DefaultDatatypeChannelMessageConverter (org.springframework.integration.support.converter.DefaultDatatypeChannelMessageConverter)5 GenericMessage (org.springframework.messaging.support.GenericMessage)5 Before (org.junit.Before)4 ContentConverter (com.synopsys.integration.alert.common.ContentConverter)3 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)3