use of org.mapstruct.ap.testutil.ProcessorTest 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.testutil.ProcessorTest 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.testutil.ProcessorTest 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.testutil.ProcessorTest 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.testutil.ProcessorTest 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);
}
Aggregations