Search in sources :

Example 6 with ValueConverterException

use of com.canoo.platform.remoting.spi.converter.ValueConverterException in project dolphin-platform by canoo.

the class LocalDateTimeConverterFactoryTest method testReconversion.

private void testReconversion(Converter converter, LocalDateTime time) {
    try {
        Object dolphinObject = converter.convertToDolphin(time);
        assertNotNull(dolphinObject);
        TimeZone.setDefault(TimeZone.getTimeZone(ZoneId.of("UTC-3")));
        Object reconvertedObject = converter.convertFromDolphin(dolphinObject);
        assertNotNull(reconvertedObject);
        assertEquals(reconvertedObject.getClass(), LocalDateTime.class);
        LocalDateTime reverted = (LocalDateTime) reconvertedObject;
        assertEquals(reverted, time);
    } catch (ValueConverterException e) {
        fail("Error in conversion");
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) ValueConverterException(com.canoo.platform.remoting.spi.converter.ValueConverterException)

Example 7 with ValueConverterException

use of com.canoo.platform.remoting.spi.converter.ValueConverterException in project dolphin-platform by canoo.

the class PeriodeConverterFactoryTest method testNullValues.

@Test
public void testNullValues(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(Period.class);
    // Then
    try {
        assertEquals(converter.convertFromDolphin(null), null);
        assertEquals(converter.convertToDolphin(null), null);
    } catch (ValueConverterException e) {
        fail("Error in conversion", e);
    }
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) ValueConverterException(com.canoo.platform.remoting.spi.converter.ValueConverterException) Test(org.testng.annotations.Test)

Example 8 with ValueConverterException

use of com.canoo.platform.remoting.spi.converter.ValueConverterException in project dolphin-platform by canoo.

the class ZonedDateTimeConverterFactoryTest method testReconversion.

private void testReconversion(Converter converter, ZonedDateTime time) {
    try {
        Object dolphinObject = converter.convertToDolphin(time);
        assertNotNull(dolphinObject);
        TimeZone.setDefault(TimeZone.getTimeZone(ZoneId.of("UTC-3")));
        Object reconvertedObject = converter.convertFromDolphin(dolphinObject);
        assertNotNull(reconvertedObject);
        assertEquals(reconvertedObject.getClass(), ZonedDateTime.class);
        ZonedDateTime reverted = (ZonedDateTime) reconvertedObject;
        assertEquals(reverted.withZoneSameInstant(ZoneId.of("UTC")), time.withZoneSameInstant(ZoneId.of("UTC")));
    } catch (ValueConverterException e) {
        fail("Error in converter", e);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ValueConverterException(com.canoo.platform.remoting.spi.converter.ValueConverterException)

Example 9 with ValueConverterException

use of com.canoo.platform.remoting.spi.converter.ValueConverterException in project dolphin-platform by canoo.

the class ZonedDateTimeConverterFactoryTest method testNullValues.

@Test
public void testNullValues(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(ZonedDateTime.class);
    // Then
    try {
        assertEquals(converter.convertFromDolphin(null), null);
        assertEquals(converter.convertToDolphin(null), null);
    } catch (ValueConverterException e) {
        fail("Error in conversion", e);
    }
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) ValueConverterException(com.canoo.platform.remoting.spi.converter.ValueConverterException) Test(org.testng.annotations.Test)

Example 10 with ValueConverterException

use of com.canoo.platform.remoting.spi.converter.ValueConverterException 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);
    }
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) ValueConverterException(com.canoo.platform.remoting.spi.converter.ValueConverterException) Test(org.testng.annotations.Test)

Aggregations

ValueConverterException (com.canoo.platform.remoting.spi.converter.ValueConverterException)12 Converters (com.canoo.dp.impl.remoting.Converters)5 Converter (com.canoo.platform.remoting.spi.converter.Converter)5 Test (org.testng.annotations.Test)5 MappingException (com.canoo.dp.impl.remoting.MappingException)2 CallActionCommand (com.canoo.dp.impl.remoting.commands.CallActionCommand)1 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)1 ControllerActionException (com.canoo.platform.remoting.client.ControllerActionException)1 Param (com.canoo.platform.remoting.client.Param)1 Duration (java.time.Duration)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Period (java.time.Period)1 ZonedDateTime (java.time.ZonedDateTime)1 CompletableFuture (java.util.concurrent.CompletableFuture)1