use of org.mapstruct.ap.test.builtin.bean.CalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnXmlGregCalToCalendar.
@ProcessorTest
@WithClasses(XmlGregCalToCalendarMapper.class)
public void shouldApplyBuiltInOnXmlGregCalToCalendar() throws DatatypeConfigurationException {
XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
source.setProp(createXmlCal(1999, 3, 2, 60));
source.publicProp = createXmlCal(2016, 3, 2, 60);
CalendarProperty target = XmlGregCalToCalendarMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().getTimeInMillis()).isEqualTo(920329200000L);
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.getTimeInMillis()).isEqualTo(1456873200000L);
assertThat(target.publicProp.getTimeInMillis()).isEqualTo(1456873200000L);
}
use of org.mapstruct.ap.test.builtin.bean.CalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnZonedDateTimeToCalendar.
@ProcessorTest
@WithClasses(ZonedDateTimeToCalendarMapper.class)
public void shouldApplyBuiltInOnZonedDateTimeToCalendar() throws ParseException {
assertThat(ZonedDateTimeToCalendarMapper.INSTANCE.map(null)).isNull();
ZonedDateTimeProperty source = new ZonedDateTimeProperty();
source.setProp(ZonedDateTime.of(1999, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
source.publicProp = ZonedDateTime.of(2016, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault());
CalendarProperty target = ZonedDateTimeToCalendarMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp()).isEqualTo(createCalendar("02.03.1999"));
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp).isEqualTo(createCalendar("02.03.2016"));
}
use of org.mapstruct.ap.test.builtin.bean.CalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnCalendarToDate.
@ProcessorTest
@WithClasses(CalendarToDateMapper.class)
public void shouldApplyBuiltInOnCalendarToDate() throws ParseException {
CalendarProperty source = new CalendarProperty();
source.setProp(createCalendar("02.03.1999"));
source.publicProp = createCalendar("02.03.2016");
DateProperty target = CalendarToDateMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp()).isEqualTo(createCalendar("02.03.1999").getTime());
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp).isEqualTo(createCalendar("02.03.2016").getTime());
}
use of org.mapstruct.ap.test.builtin.bean.CalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnCalendarToZonedDateTime.
@ProcessorTest
@WithClasses(CalendarToZonedDateTimeMapper.class)
public void shouldApplyBuiltInOnCalendarToZonedDateTime() throws ParseException {
assertThat(CalendarToZonedDateTimeMapper.INSTANCE.map(null)).isNull();
CalendarProperty source = new CalendarProperty();
source.setProp(createCalendar("02.03.1999"));
source.publicProp = createCalendar("02.03.2016");
ZonedDateTimeProperty target = CalendarToZonedDateTimeMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp()).isEqualTo(ZonedDateTime.of(1999, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp).isEqualTo(ZonedDateTime.of(2016, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
}
use of org.mapstruct.ap.test.builtin.bean.CalendarProperty in project mapstruct by mapstruct.
the class DatatypeFactoryTest method testNoConflictsWithOwnDatatypeFactory.
@ProcessorTest
public void testNoConflictsWithOwnDatatypeFactory() throws ParseException {
DateProperty source1 = new DateProperty();
source1.setProp(createDate("31-08-1982 10:20:56"));
CalendarProperty source2 = new CalendarProperty();
source2.setProp(createCalendar("02.03.1999"));
XmlGregorianCalendarFactorizedProperty target1 = ToXmlGregCalMapper.INSTANCE.map(source1);
assertThat(target1).isNotNull();
assertThat(target1.getProp()).isNotNull();
assertThat(target1.getProp().toString()).isEqualTo("1982-08-31T10:20:56.000+02:00");
XmlGregorianCalendarFactorizedProperty target2 = ToXmlGregCalMapper.INSTANCE.map(source2);
assertThat(target2).isNotNull();
assertThat(target2.getProp()).isNotNull();
assertThat(target2.getProp().toString()).isEqualTo("1999-03-02T00:00:00.000+01:00");
}
Aggregations