Search in sources :

Example 1 with CalendarConverterFactory

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);
}
Also used : CalendarConverterFactory(com.canoo.dp.impl.remoting.converters.CalendarConverterFactory) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Converter(com.canoo.platform.remoting.spi.converter.Converter) Test(org.testng.annotations.Test)

Example 2 with CalendarConverterFactory

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);
}
Also used : CalendarConverterFactory(com.canoo.dp.impl.remoting.converters.CalendarConverterFactory) Test(org.testng.annotations.Test)

Example 3 with CalendarConverterFactory

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));
}
Also used : CalendarConverterFactory(com.canoo.dp.impl.remoting.converters.CalendarConverterFactory) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Test(org.testng.annotations.Test)

Example 4 with CalendarConverterFactory

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);
}
Also used : CalendarConverterFactory(com.canoo.dp.impl.remoting.converters.CalendarConverterFactory) GregorianCalendar(java.util.GregorianCalendar) Converter(com.canoo.platform.remoting.spi.converter.Converter) Test(org.testng.annotations.Test)

Example 5 with CalendarConverterFactory

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());
}
Also used : CalendarConverterFactory(com.canoo.dp.impl.remoting.converters.CalendarConverterFactory) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Converter(com.canoo.platform.remoting.spi.converter.Converter) Test(org.testng.annotations.Test)

Aggregations

CalendarConverterFactory (com.canoo.dp.impl.remoting.converters.CalendarConverterFactory)9 Test (org.testng.annotations.Test)9 GregorianCalendar (java.util.GregorianCalendar)8 Converter (com.canoo.platform.remoting.spi.converter.Converter)7 Calendar (java.util.Calendar)7