use of com.canoo.dp.impl.remoting.converters.CalendarConverterFactory in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testConversionCurrentDate.
@Test
public void testConversionCurrentDate() throws ValueConverterException {
CalendarConverterFactory factory = new CalendarConverterFactory();
Converter converter = factory.getConverterForType(Calendar.class);
Calendar calendar = GregorianCalendar.getInstance();
Object converted = converter.convertToDolphin(calendar);
Assert.assertNotNull(converted);
Assert.assertEquals(((Calendar) converter.convertFromDolphin(converted)).getTime(), calendar.getTime());
}
use of com.canoo.dp.impl.remoting.converters.CalendarConverterFactory in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testFromDolphinConversionFixDate.
@Test
public void testFromDolphinConversionFixDate() 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;
Assert.assertEquals(calendar.getTimeZone(), TimeZone.getTimeZone("UTC"));
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), 3);
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 testToDolphinConversionFixDate.
@Test
public void testToDolphinConversionFixDate() 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);
calendar.set(Calendar.MILLISECOND, 0);
Object converted = converter.convertToDolphin(calendar);
Assert.assertNotNull(converted);
Assert.assertTrue(converted instanceof String);
Assert.assertEquals(converted, "2017-03-03T04:05:06.000Z");
}
use of com.canoo.dp.impl.remoting.converters.CalendarConverterFactory in project dolphin-platform by canoo.
the class CalenderConverterFactoryTest method testToDolphinConversionFixDateInGmt.
@Test
public void testToDolphinConversionFixDateInGmt() throws ValueConverterException {
CalendarConverterFactory factory = new CalendarConverterFactory();
Converter converter = factory.getConverterForType(Calendar.class);
Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"));
calendar.set(2017, 2, 3, 4, 5, 6);
calendar.set(Calendar.MILLISECOND, 0);
Object converted = converter.convertToDolphin(calendar);
Assert.assertNotNull(converted);
Assert.assertTrue(converted instanceof String);
Assert.assertEquals(converted, "2017-03-03T03:05:06.000Z");
}
Aggregations