Search in sources :

Example 21 with Converters

use of com.canoo.dp.impl.remoting.Converters in project dolphin-platform by canoo.

the class ZonedDateTimeConverterFactoryTest method testWrongBeanValues.

@Test(expectedExceptions = ClassCastException.class)
public void testWrongBeanValues(@Mocked BeanRepository beanRepository) throws ValueConverterException {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(ZonedDateTime.class);
    // Then
    converter.convertToDolphin(7);
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) Test(org.testng.annotations.Test)

Example 22 with Converters

use of com.canoo.dp.impl.remoting.Converters in project dolphin-platform by canoo.

the class ZonedDateTimeConverterFactoryTest method testBasicConversions.

@Test
public void testBasicConversions(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(ZonedDateTime.class);
    // Then
    testReconversion(converter, ZonedDateTime.now());
    testReconversion(converter, ZonedDateTime.now(ZoneId.of(ZoneId.getAvailableZoneIds().iterator().next())));
    testReconversion(converter, ZonedDateTime.now(ZoneId.of("GMT")));
    testReconversion(converter, ZonedDateTime.now(ZoneId.of("Z")));
    testReconversion(converter, ZonedDateTime.now(ZoneId.of("UTC+6")));
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) Test(org.testng.annotations.Test)

Example 23 with Converters

use of com.canoo.dp.impl.remoting.Converters in project dolphin-platform by canoo.

the class ConverterTest method testDateConversions.

@Test
public void testDateConversions() {
    Converters converters = new Converters(null);
    Converter converter = converters.getConverter(Date.class);
    Date testDate1 = new Date();
    checkConversion(converter, testDate1);
    Date testDate2 = new Date(0);
    checkConversion(converter, testDate2);
    Date testDate3 = new Date(Long.MAX_VALUE);
    checkConversion(converter, testDate3);
    Date testDate4 = null;
    checkConversion(converter, testDate4);
// TODO: Not working based on date formate (yyyy), max year is 9999
// Date testDate5 = new Date(Long.MIN_VALUE);
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 24 with Converters

use of com.canoo.dp.impl.remoting.Converters in project dolphin-platform by canoo.

the class AbstractDolphinBasedTest method createBeanManager.

protected BeanManager createBeanManager(final ClientModelStore clientModelStore, final BeanRepository beanRepository, final EventDispatcher dispatcher) {
    final Converters converters = new Converters(beanRepository);
    final PresentationModelBuilderFactory builderFactory = new ClientPresentationModelBuilderFactory(clientModelStore);
    final ClassRepository classRepository = new ClassRepositoryImpl(clientModelStore, converters, builderFactory);
    final ListMapper listMapper = new ListMapperImpl(clientModelStore, classRepository, beanRepository, builderFactory, dispatcher);
    final BeanBuilder beanBuilder = new ClientBeanBuilderImpl(classRepository, beanRepository, listMapper, builderFactory, dispatcher);
    return new BeanManagerImpl(beanRepository, beanBuilder);
}
Also used : BeanBuilder(com.canoo.dp.impl.remoting.BeanBuilder) ClientPresentationModelBuilderFactory(com.canoo.dp.impl.client.ClientPresentationModelBuilderFactory) PresentationModelBuilderFactory(com.canoo.dp.impl.remoting.PresentationModelBuilderFactory) ClientPresentationModelBuilderFactory(com.canoo.dp.impl.client.ClientPresentationModelBuilderFactory) BeanManagerImpl(com.canoo.dp.impl.remoting.BeanManagerImpl) ListMapper(com.canoo.dp.impl.remoting.ListMapper) ListMapperImpl(com.canoo.dp.impl.remoting.collections.ListMapperImpl) ClassRepository(com.canoo.dp.impl.remoting.ClassRepository) ClassRepositoryImpl(com.canoo.dp.impl.remoting.ClassRepositoryImpl) Converters(com.canoo.dp.impl.remoting.Converters) ClientBeanBuilderImpl(com.canoo.dp.impl.client.ClientBeanBuilderImpl)

Example 25 with Converters

use of com.canoo.dp.impl.remoting.Converters in project dolphin-platform by canoo.

the class ConverterTest method testDoubleConversions.

@Test
public void testDoubleConversions() {
    Converters converters = new Converters(null);
    Converter converter = converters.getConverter(Double.class);
    checkConversion(converter, 2.9d);
    checkConversion(converter, null);
    checkConversion(converter, 0.0);
    checkConversion(converter, Double.MAX_VALUE);
    checkConversion(converter, Double.MIN_VALUE);
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) Test(org.testng.annotations.Test)

Aggregations

Converters (com.canoo.dp.impl.remoting.Converters)36 Test (org.testng.annotations.Test)33 Converter (com.canoo.platform.remoting.spi.converter.Converter)28 ValueConverterException (com.canoo.platform.remoting.spi.converter.ValueConverterException)5 BeanBuilder (com.canoo.dp.impl.remoting.BeanBuilder)3 BeanManagerImpl (com.canoo.dp.impl.remoting.BeanManagerImpl)3 ClassRepository (com.canoo.dp.impl.remoting.ClassRepository)3 ClassRepositoryImpl (com.canoo.dp.impl.remoting.ClassRepositoryImpl)3 ListMapper (com.canoo.dp.impl.remoting.ListMapper)3 PresentationModelBuilderFactory (com.canoo.dp.impl.remoting.PresentationModelBuilderFactory)3 ListMapperImpl (com.canoo.dp.impl.remoting.collections.ListMapperImpl)3 RemotingConfiguration (com.canoo.dp.impl.server.config.RemotingConfiguration)2 GarbageCollectionCallback (com.canoo.dp.impl.server.gc.GarbageCollectionCallback)2 GarbageCollector (com.canoo.dp.impl.server.gc.GarbageCollector)2 Instance (com.canoo.dp.impl.server.gc.Instance)2 ServerBeanBuilderImpl (com.canoo.dp.impl.server.model.ServerBeanBuilderImpl)2 ServerPresentationModelBuilderFactory (com.canoo.dp.impl.server.model.ServerPresentationModelBuilderFactory)2 ClientBeanBuilderImpl (com.canoo.dp.impl.client.ClientBeanBuilderImpl)1 ClientPresentationModelBuilderFactory (com.canoo.dp.impl.client.ClientPresentationModelBuilderFactory)1 BeanRepositoryImpl (com.canoo.dp.impl.remoting.BeanRepositoryImpl)1