Search in sources :

Example 6 with LocalDateTimeBean

use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean in project mapstruct by mapstruct.

the class JodaTimeTest method shouldMapXmlGregorianCalendarWithoutSecondsToLocalDateTime.

@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDateTime.class)
public void shouldMapXmlGregorianCalendarWithoutSecondsToLocalDateTime() 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.setTimezone(60);
    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(0);
    assertThat(res.getLocalDateTime().getMillisOfSecond()).isEqualTo(0);
}
Also used : LocalDateTimeBean(org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) XmlGregorianCalendarBean(org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

LocalDateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean)6 XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)6 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)6 WithClasses (org.mapstruct.ap.testutil.WithClasses)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4 LocalDateTime (org.joda.time.LocalDateTime)2 XmlGregorianCalendarToLocalDateTime (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDateTime)2