use of com.canoo.dp.impl.remoting.converters.CalendarConverterFactory 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.dp.impl.remoting.converters.CalendarConverterFactory in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testTypeIdentifier.
@Test
public void testTypeIdentifier() {
CalendarConverterFactory factory = new CalendarConverterFactory();
Assert.assertEquals(factory.getTypeIdentifier(), CalendarConverterFactory.FIELD_TYPE_CALENDAR);
}
use of com.canoo.dp.impl.remoting.converters.CalendarConverterFactory in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testTypeSupport.
@Test
public void testTypeSupport() {
CalendarConverterFactory factory = new CalendarConverterFactory();
Assert.assertTrue(factory.supportsType(Calendar.class));
Assert.assertTrue(factory.supportsType(GregorianCalendar.class));
}
use of com.canoo.dp.impl.remoting.converters.CalendarConverterFactory in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testConverterCreation.
@Test
public void testConverterCreation() {
CalendarConverterFactory factory = new CalendarConverterFactory();
Converter converter = factory.getConverterForType(Calendar.class);
Assert.assertNotNull(converter);
converter = factory.getConverterForType(GregorianCalendar.class);
Assert.assertNotNull(converter);
}
use of com.canoo.dp.impl.remoting.converters.CalendarConverterFactory in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testConversionFixDate.
@Test
public void testConversionFixDate() throws ValueConverterException {
CalendarConverterFactory factory = new CalendarConverterFactory();
Converter converter = factory.getConverterForType(Calendar.class);
Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
calendar.set(2017, 2, 3, 4, 5, 6);
Object converted = converter.convertToDolphin(calendar);
Assert.assertNotNull(converted);
Assert.assertEquals(((Calendar) converter.convertFromDolphin(converted)).getTime(), calendar.getTime());
}
Aggregations