Search in sources :

Example 6 with Converter

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

the class LocalDateConverterFactoryTest method testBasicConversions.

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

Example 7 with Converter

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

the class LocalDateConverterFactoryTest method testConverterCreation.

@Test
public void testConverterCreation(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(LocalDate.class);
    // Then
    assertNotNull(converter);
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Converter(com.canoo.platform.remoting.spi.converter.Converter) Test(org.testng.annotations.Test)

Example 8 with Converter

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

the class LocalDateConverterFactoryTest method testNullValues.

@Test
public void testNullValues(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(LocalDate.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 9 with Converter

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

the class LocalDateConverterFactoryTest method testWrongDolphinValues.

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

Example 10 with Converter

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

the class LocalDateTimeConverterFactoryTest method testBasicConversions.

@Test
public void testBasicConversions(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(LocalDateTime.class);
    // Then
    testReconversion(converter, LocalDateTime.now());
    testReconversion(converter, LocalDateTime.now(ZoneId.of(ZoneId.getAvailableZoneIds().iterator().next())));
    testReconversion(converter, LocalDateTime.now(ZoneId.of("GMT")));
    testReconversion(converter, LocalDateTime.now(ZoneId.of("Z")));
    testReconversion(converter, LocalDateTime.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)

Aggregations

Converter (com.canoo.platform.remoting.spi.converter.Converter)38 Test (org.testng.annotations.Test)37 Converters (com.canoo.dp.impl.remoting.Converters)28 CalendarConverterFactory (com.canoo.dp.impl.remoting.converters.CalendarConverterFactory)7 GregorianCalendar (java.util.GregorianCalendar)7 Calendar (java.util.Calendar)6 ValueConverterException (com.canoo.platform.remoting.spi.converter.ValueConverterException)5 DateConverterFactory (com.canoo.dp.impl.remoting.converters.DateConverterFactory)2 Date (java.util.Date)2 ClassInfo (com.canoo.dp.impl.remoting.info.ClassInfo)1 PropertyInfo (com.canoo.dp.impl.remoting.info.PropertyInfo)1 ObservableList (com.canoo.platform.remoting.ObservableList)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1