use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldNotMapXmlGregorianCalendarWithoutMinutesToLocalDateTime.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDateTime.class)
public void shouldNotMapXmlGregorianCalendarWithoutMinutesToLocalDateTime() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar();
xcal.setYear(1999);
xcal.setMonth(5);
xcal.setDay(25);
xcal.setHour(23);
in.setxMLGregorianCalendar(xcal);
LocalDateTimeBean res = XmlGregorianCalendarToLocalDateTime.INSTANCE.toDateTimeBean(in);
assertThat(res.getLocalDateTime()).isNull();
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapXmlGregorianCalendarToLocalTime.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalTime.class)
public void shouldMapXmlGregorianCalendarToLocalTime() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendarTime(1, 1, 1, 100, 60);
in.setxMLGregorianCalendar(xcal);
LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean(in);
assertThat(res.getLocalTime().getHourOfDay()).isEqualTo(1);
assertThat(res.getLocalTime().getMinuteOfHour()).isEqualTo(1);
assertThat(res.getLocalTime().getSecondOfMinute()).isEqualTo(1);
assertThat(res.getLocalTime().getMillisOfSecond()).isEqualTo(100);
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapXmlGregorianCalendarWithoutMillisToLocalTime.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalTime.class)
public void shouldMapXmlGregorianCalendarWithoutMillisToLocalTime() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar();
xcal.setHour(23);
xcal.setMinute(34);
xcal.setSecond(45);
in.setxMLGregorianCalendar(xcal);
LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean(in);
assertThat(res.getLocalTime().getHourOfDay()).isEqualTo(23);
assertThat(res.getLocalTime().getMinuteOfHour()).isEqualTo(34);
assertThat(res.getLocalTime().getSecondOfMinute()).isEqualTo(45);
assertThat(res.getLocalTime().getMillisOfSecond()).isEqualTo(0);
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapXmlGregorianCalendarWithoutSecondsToLocalTime.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalTime.class)
public void shouldMapXmlGregorianCalendarWithoutSecondsToLocalTime() throws Exception {
XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar();
xcal.setHour(23);
xcal.setMinute(34);
xcal.setTimezone(60);
in.setxMLGregorianCalendar(xcal);
LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean(in);
assertThat(res.getLocalTime().getHourOfDay()).isEqualTo(23);
assertThat(res.getLocalTime().getMinuteOfHour()).isEqualTo(34);
assertThat(res.getLocalTime().getSecondOfMinute()).isEqualTo(0);
assertThat(res.getLocalTime().getMillisOfSecond()).isEqualTo(0);
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapDateTimeToXmlGregorianCalendar.
@ProcessorTest
@WithClasses(DateTimeToXmlGregorianCalendar.class)
public void shouldMapDateTimeToXmlGregorianCalendar() {
DateTimeBean in = new DateTimeBean();
DateTime dt = new DateTime(2010, 1, 15, 1, 1, 1, 100, DateTimeZone.forOffsetHours(-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);
assertThat(res.getxMLGregorianCalendar().getSecond()).isEqualTo(1);
assertThat(res.getxMLGregorianCalendar().getMillisecond()).isEqualTo(100);
assertThat(res.getxMLGregorianCalendar().getTimezone()).isEqualTo(-60);
}
Aggregations