use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalTimeBean 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.LocalTimeBean 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.LocalTimeBean 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.LocalTimeBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldNotMapXmlGregorianCalendarWithoutMinutesToLocalTime.
@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalTime.class)
public void shouldNotMapXmlGregorianCalendarWithoutMinutesToLocalTime() 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);
LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean(in);
assertThat(res.getLocalTime()).isNull();
}
use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalTimeBean in project mapstruct by mapstruct.
the class JodaTimeTest method shouldMapIncompleteLocalTimeToXmlGregorianCalendar.
@ProcessorTest
@WithClasses(LocalTimeToXmlGregorianCalendar.class)
public void shouldMapIncompleteLocalTimeToXmlGregorianCalendar() {
LocalTimeBean in = new LocalTimeBean();
LocalTime dt = new LocalTime(1, 1, 0, 100);
in.setLocalTime(dt);
XmlGregorianCalendarBean res = LocalTimeToXmlGregorianCalendar.INSTANCE.toXmlGregorianCalendarBean(in);
assertThat(res.getxMLGregorianCalendar().getYear()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
assertThat(res.getxMLGregorianCalendar().getMonth()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
assertThat(res.getxMLGregorianCalendar().getDay()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
assertThat(res.getxMLGregorianCalendar().getHour()).isEqualTo(1);
assertThat(res.getxMLGregorianCalendar().getMinute()).isEqualTo(1);
assertThat(res.getxMLGregorianCalendar().getSecond()).isEqualTo(0);
assertThat(res.getxMLGregorianCalendar().getMillisecond()).isEqualTo(100);
assertThat(res.getxMLGregorianCalendar().getTimezone()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
}
Aggregations