use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapXmlGregorianCalendarToLocalDateTime.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDateTime.class)
public void shouldMapXmlGregorianCalendarToLocalDateTime() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(2010, 1, 15, 1, 1, 1, 100, 60);
in.setxMLGregorianCalendar(xcal);
LocalDateTimeBean res = XmlGregorianCalendarToLocalDateTime.INSTANCE.toDateTimeBean(in);
assertThat(res.getLocalDateTime().getYear()).isEqualTo(2010);
assertThat(res.getLocalDateTime().getMonthOfYear()).isEqualTo(1);
assertThat(res.getLocalDateTime().getDayOfMonth()).isEqualTo(15);
assertThat(res.getLocalDateTime().getHourOfDay()).isEqualTo(1);
assertThat(res.getLocalDateTime().getMinuteOfHour()).isEqualTo(1);
assertThat(res.getLocalDateTime().getSecondOfMinute()).isEqualTo(1);
assertThat(res.getLocalDateTime().getMillisOfSecond()).isEqualTo(100);
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapXmlGregorianCalendarWithoutSecondsAndTimeZoneToDateTimeWithDefaultTimeZone.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToDateTime.class)
public void shouldMapXmlGregorianCalendarWithoutSecondsAndTimeZoneToDateTimeWithDefaultTimeZone() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar();
xcal.setYear(1999);
xcal.setMonth(5);
xcal.setDay(25);
xcal.setHour(23);
xcal.setMinute(34);
in.setxMLGregorianCalendar(xcal);
DateTimeBean res = XmlGregorianCalendarToDateTime.INSTANCE.toDateTimeBean(in);
assertThat(res.getDateTime().getYear()).isEqualTo(1999);
assertThat(res.getDateTime().getMonthOfYear()).isEqualTo(5);
assertThat(res.getDateTime().getDayOfMonth()).isEqualTo(25);
assertThat(res.getDateTime().getHourOfDay()).isEqualTo(23);
assertThat(res.getDateTime().getMinuteOfHour()).isEqualTo(34);
assertThat(res.getDateTime().getSecondOfMinute()).isEqualTo(0);
assertThat(res.getDateTime().getMillisOfSecond()).isEqualTo(0);
assertThat(res.getDateTime().getZone().getOffset(0)).isEqualTo(DateTimeZone.getDefault().getOffset(0));
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapIncompleteDateTimeToXmlGregorianCalendar.
@ProcessorTest
@WithClasses(DateTimeToXmlGregorianCalendar.class)
public void shouldMapIncompleteDateTimeToXmlGregorianCalendar() {
DateTimeBean in = new DateTimeBean();
DateTime dt = new DateTime(2010, 1, 15, 1, 1);
in.setDateTime(dt);
XmlGregorianCalendarBean res = DateTimeToXmlGregorianCalendar.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(1);
assertThat(res.getxMLGregorianCalendar().getMinute()).isEqualTo(1);
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapXmlGregorianCalendarWithoutMillisToLocalDateTime.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDateTime.class)
public void shouldMapXmlGregorianCalendarWithoutMillisToLocalDateTime() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar();
xcal.setYear(1999);
xcal.setMonth(5);
xcal.setDay(25);
xcal.setHour(23);
xcal.setMinute(34);
xcal.setSecond(45);
in.setxMLGregorianCalendar(xcal);
LocalDateTimeBean res = XmlGregorianCalendarToLocalDateTime.INSTANCE.toDateTimeBean(in);
assertThat(res.getLocalDateTime().getYear()).isEqualTo(1999);
assertThat(res.getLocalDateTime().getMonthOfYear()).isEqualTo(5);
assertThat(res.getLocalDateTime().getDayOfMonth()).isEqualTo(25);
assertThat(res.getLocalDateTime().getHourOfDay()).isEqualTo(23);
assertThat(res.getLocalDateTime().getMinuteOfHour()).isEqualTo(34);
assertThat(res.getLocalDateTime().getSecondOfMinute()).isEqualTo(45);
assertThat(res.getLocalDateTime().getMillisOfSecond()).isEqualTo(0);
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean 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();
}
Aggregations