Search in sources :

Example 1 with LocalDateBean

use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean 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();
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) XmlGregorianCalendarBean(org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean) LocalDateBean(org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with LocalDateBean

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

the class JodaTimeTest method shouldMapLocalDateToXmlGregorianCalendar.

@ProcessorTest
@WithClasses(LocalDateToXmlGregorianCalendar.class)
public void shouldMapLocalDateToXmlGregorianCalendar() {
    LocalDateBean in = new LocalDateBean();
    LocalDate dt = new LocalDate(2010, 1, 15);
    in.setLocalDate(dt);
    XmlGregorianCalendarBean res = LocalDateToXmlGregorianCalendar.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(DatatypeConstants.FIELD_UNDEFINED);
    assertThat(res.getxMLGregorianCalendar().getMinute()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
    assertThat(res.getxMLGregorianCalendar().getSecond()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
    assertThat(res.getxMLGregorianCalendar().getMillisecond()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
    assertThat(res.getxMLGregorianCalendar().getTimezone()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
}
Also used : LocalDateBean(org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean) XmlGregorianCalendarBean(org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean) LocalDate(org.joda.time.LocalDate) XmlGregorianCalendarToLocalDate(org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDate) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 3 with LocalDateBean

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

the class JodaTimeTest method shouldMapXmlGregorianCalendarToLocalDate.

@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDate.class)
public void shouldMapXmlGregorianCalendarToLocalDate() throws Exception {
    XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
    XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(1999, 5, 25, DatatypeConstants.FIELD_UNDEFINED);
    in.setxMLGregorianCalendar(xcal);
    LocalDateBean res = XmlGregorianCalendarToLocalDate.INSTANCE.toLocalDateBean(in);
    assertThat(res.getLocalDate().getYear()).isEqualTo(1999);
    assertThat(res.getLocalDate().getMonthOfYear()).isEqualTo(5);
    assertThat(res.getLocalDate().getDayOfMonth()).isEqualTo(25);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) XmlGregorianCalendarBean(org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean) LocalDateBean(org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

LocalDateBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean)3 XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)3 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)3 WithClasses (org.mapstruct.ap.testutil.WithClasses)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 LocalDate (org.joda.time.LocalDate)1 XmlGregorianCalendarToLocalDate (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDate)1