use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class DateConverterFactoryTest method testConvertion.
@Test
public void testConvertion() throws ValueConverterException {
DateConverterFactory factory = new DateConverterFactory();
Converter converter = factory.getConverterForType(Date.class);
Date date = new Date();
Object converted = converter.convertToDolphin(date);
Assert.assertNotNull(converted);
Assert.assertEquals(converter.convertFromDolphin(converted), date);
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class DurationConverterFactoryTest method testBasicConversions.
@Test
public void testBasicConversions(@Mocked BeanRepository beanRepository) {
// Given
Converters converters = new Converters(beanRepository);
// When
Converter converter = converters.getConverter(Duration.class);
// Then
testReconversion(converter, Duration.ZERO);
testReconversion(converter, Duration.ofDays(7));
testReconversion(converter, Duration.ofMillis(10));
testReconversion(converter, Duration.ofDays(10_000_000));
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class DurationConverterFactoryTest method testConverterCreation.
@Test
public void testConverterCreation(@Mocked BeanRepository beanRepository) {
// Given
Converters converters = new Converters(beanRepository);
// When
Converter converter = converters.getConverter(Duration.class);
// Then
assertNotNull(converter);
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class LocalDateConverterFactoryTest 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(LocalDate.class);
// Then
converter.convertToDolphin(7);
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class LocalDateTimeConverterFactoryTest method testNullValues.
@Test
public void testNullValues(@Mocked BeanRepository beanRepository) {
// Given
Converters converters = new Converters(beanRepository);
// When
Converter converter = converters.getConverter(LocalDateTime.class);
// Then
try {
assertEquals(converter.convertFromDolphin(null), null);
assertEquals(converter.convertToDolphin(null), null);
} catch (ValueConverterException e) {
fail("Error in conversion", e);
}
}
Aggregations