use of org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInStringToXmlGregCal.
@ProcessorTest
@WithClasses(StringToXmlGregCalMapper.class)
public void shouldApplyBuiltInStringToXmlGregCal() {
StringProperty source = new StringProperty();
source.setProp("05.07.1999");
source.publicProp = "05.07.2016";
XmlGregorianCalendarProperty target = StringToXmlGregCalMapper.INSTANCE.mapAndFormat(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("1999-07-05T00:00:00.000+02:00");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("2016-07-05T00:00:00.000+02:00");
// direct,via lexical representation
source.setProp("2000-03-04T23:00:00+03:00");
source.publicProp = "2016-03-04T23:00:00+03:00";
target = StringToXmlGregCalMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("2000-03-04T23:00:00+03:00");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("2016-03-04T23:00:00+03:00");
// null string
source.setProp(null);
source.publicProp = null;
target = StringToXmlGregCalMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNull();
assertThat(target.publicProp).isNull();
}
use of org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty 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.XmlGregorianCalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnDateToXmlGregCal.
@ProcessorTest
@WithClasses(DateToXmlGregCalMapper.class)
public void shouldApplyBuiltInOnDateToXmlGregCal() throws ParseException {
DateProperty source = new DateProperty();
source.setProp(createDate("31-08-1982 10:20:56"));
source.publicProp = createDate("31-08-2016 10:20:56");
XmlGregorianCalendarProperty target = DateToXmlGregCalMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("1982-08-31T10:20:56.000+02:00");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("2016-08-31T10:20:56.000+02:00");
}
use of org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnCalendarToXmlGregCal.
@ProcessorTest
@WithClasses(CalendarToXmlGregCalMapper.class)
public void shouldApplyBuiltInOnCalendarToXmlGregCal() throws ParseException {
CalendarProperty source = new CalendarProperty();
source.setProp(createCalendar("02.03.1999"));
source.publicProp = createCalendar("02.03.2016");
XmlGregorianCalendarProperty target = CalendarToXmlGregCalMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("1999-03-02T00:00:00.000+01:00");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("2016-03-02T00:00:00.000+01:00");
}
use of org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnXmlGregCalToDate.
@ProcessorTest
@WithClasses(XmlGregCalToDateMapper.class)
public void shouldApplyBuiltInOnXmlGregCalToDate() throws DatatypeConfigurationException {
XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
source.setProp(createXmlCal(1999, 3, 2, 60));
source.publicProp = createXmlCal(2016, 3, 2, 60);
DateProperty target = XmlGregCalToDateMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("Tue Mar 02 00:00:00 CET 1999");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("Wed Mar 02 00:00:00 CET 2016");
}
Aggregations