Search in sources :

Example 1 with Converters

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

the class DurationConverterFactoryTest method testFactoryFieldType.

@Test
public void testFactoryFieldType(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    int type = converters.getFieldType(Duration.class);
    // Then
    assertEquals(type, ValueFieldTypes.DURATION_FIELD_TYPE);
}
Also used : Converters(com.canoo.dp.impl.remoting.Converters) Test(org.testng.annotations.Test)

Example 2 with Converters

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

the class DurationConverterFactoryTest 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(Duration.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 3 with Converters

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

the class DurationConverterFactoryTest 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(Duration.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 4 with Converters

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

the class DurationConverterFactoryTest method testNullValues.

@Test
public void testNullValues(@Mocked BeanRepository beanRepository) {
    // Given
    Converters converters = new Converters(beanRepository);
    // When
    Converter converter = converters.getConverter(Duration.class);
    // Then
    try {
        assertEquals(converter.convertFromDolphin(null), null);
        assertEquals(converter.convertToDolphin(null), null);
    } catch (ValueConverterException e) {
        fail("Error in conversion");
    }
}
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 5 with Converters

use of com.canoo.dp.impl.remoting.Converters 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)

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