use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testFromDolphinConversionFixDateWithTimeZoneConversion.
@Test
public void testFromDolphinConversionFixDateWithTimeZoneConversion() throws ValueConverterException {
CalendarConverterFactory factory = new CalendarConverterFactory();
Converter converter = factory.getConverterForType(Calendar.class);
String input = "2017-03-03T03:05:06.000Z";
Object converted = converter.convertFromDolphin(input);
Assert.assertNotNull(converted);
Assert.assertTrue(converted instanceof Calendar);
Calendar calendar = (Calendar) converted;
calendar.setTimeZone(TimeZone.getTimeZone("GMT+1"));
Assert.assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("GMT+1"));
Assert.assertEquals(calendar.get(Calendar.YEAR), 2017);
Assert.assertEquals(calendar.get(Calendar.MONTH), 2);
Assert.assertEquals(calendar.get(Calendar.DAY_OF_MONTH), 3);
Assert.assertEquals(calendar.get(Calendar.HOUR), 4);
Assert.assertEquals(calendar.get(Calendar.MINUTE), 5);
Assert.assertEquals(calendar.get(Calendar.SECOND), 6);
Assert.assertEquals(calendar.get(Calendar.MILLISECOND), 0);
}
use of com.canoo.platform.remoting.spi.converter.Converter in project dolphin-platform by canoo.
the class DateConverterFactoryTest method testConverterCreation.
@Test
public void testConverterCreation() {
DateConverterFactory factory = new DateConverterFactory();
Converter converter = factory.getConverterForType(Date.class);
Assert.assertNotNull(converter);
}
use of com.canoo.platform.remoting.spi.converter.Converter 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);
}
use of com.canoo.platform.remoting.spi.converter.Converter 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);
}
use of com.canoo.platform.remoting.spi.converter.Converter 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");
}
}
Aggregations