use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldNotMapXmlGregorianCalendarWithoutDaysToLocalDate.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDate.class)
public void shouldNotMapXmlGregorianCalendarWithoutDaysToLocalDate() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(1999, 5, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED);
in.setxMLGregorianCalendar(xcal);
LocalDateBean res = XmlGregorianCalendarToLocalDate.INSTANCE.toLocalDateBean(in);
assertThat(res.getLocalDate()).isNull();
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapLocalDateToXmlGregorianCalendar.
@ProcessorTest
@WithClasses(LocalDateToXmlGregorianCalendar.class)
public void shouldMapLocalDateToXmlGregorianCalendar() {
LocalDateBean in = new LocalDateBean();
LocalDate dt = new LocalDate(2010, 1, 15);
in.setLocalDate(dt);
XmlGregorianCalendarBean res = LocalDateToXmlGregorianCalendar.INSTANCE.toXmlGregorianCalendarBean(in);
assertThat(res.getxMLGregorianCalendar().getYear()).isEqualTo(2010);
assertThat(res.getxMLGregorianCalendar().getMonth()).isEqualTo(1);
assertThat(res.getxMLGregorianCalendar().getDay()).isEqualTo(15);
assertThat(res.getxMLGregorianCalendar().getHour()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
assertThat(res.getxMLGregorianCalendar().getMinute()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
assertThat(res.getxMLGregorianCalendar().getSecond()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
assertThat(res.getxMLGregorianCalendar().getMillisecond()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
assertThat(res.getxMLGregorianCalendar().getTimezone()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapXmlGregorianCalendarToLocalDate.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDate.class)
public void shouldMapXmlGregorianCalendarToLocalDate() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(1999, 5, 25, DatatypeConstants.FIELD_UNDEFINED);
in.setxMLGregorianCalendar(xcal);
LocalDateBean res = XmlGregorianCalendarToLocalDate.INSTANCE.toLocalDateBean(in);
assertThat(res.getLocalDate().getYear()).isEqualTo(1999);
assertThat(res.getLocalDate().getMonthOfYear()).isEqualTo(5);
assertThat(res.getLocalDate().getDayOfMonth()).isEqualTo(25);
}
Aggregations