Search in sources :

Example 1 with LocalDateTimeBean

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

the class JodaTimeTest method shouldMapXmlGregorianCalendarToLocalDateTime.

@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDateTime.class)
public void shouldMapXmlGregorianCalendarToLocalDateTime() throws Exception {
    XmlGregorianCalendarBean in = new XmlGregorianCalendarBean();
    XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(2010, 1, 15, 1, 1, 1, 100, 60);
    in.setxMLGregorianCalendar(xcal);
    LocalDateTimeBean res = XmlGregorianCalendarToLocalDateTime.INSTANCE.toDateTimeBean(in);
    assertThat(res.getLocalDateTime().getYear()).isEqualTo(2010);
    assertThat(res.getLocalDateTime().getMonthOfYear()).isEqualTo(1);
    assertThat(res.getLocalDateTime().getDayOfMonth()).isEqualTo(15);
    assertThat(res.getLocalDateTime().getHourOfDay()).isEqualTo(1);
    assertThat(res.getLocalDateTime().getMinuteOfHour()).isEqualTo(1);
    assertThat(res.getLocalDateTime().getSecondOfMinute()).isEqualTo(1);
    assertThat(res.getLocalDateTime().getMillisOfSecond()).isEqualTo(100);
}
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)

Example 2 with LocalDateTimeBean

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

the class JodaTimeTest method shouldMapXmlGregorianCalendarWithoutMillisToLocalDateTime.

@ProcessorTest
@WithClasses(XmlGregorianCalendarToLocalDateTime.class)
public void shouldMapXmlGregorianCalendarWithoutMillisToLocalDateTime() 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.setSecond(45);
    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(45);
    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)

Example 3 with LocalDateTimeBean

use of org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean 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();
}
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)

Example 4 with LocalDateTimeBean

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

the class JodaTimeTest method shouldMapIncompleteLocalDateTimeToXmlGregorianCalendar.

@ProcessorTest
@WithClasses(LocalDateTimeToXmlGregorianCalendar.class)
public void shouldMapIncompleteLocalDateTimeToXmlGregorianCalendar() {
    LocalDateTimeBean in = new LocalDateTimeBean();
    LocalDateTime dt = new LocalDateTime(2010, 1, 15, 1, 1);
    in.setLocalDateTime(dt);
    XmlGregorianCalendarBean res = LocalDateTimeToXmlGregorianCalendar.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(0);
    assertThat(res.getxMLGregorianCalendar().getMillisecond()).isEqualTo(0);
    assertThat(res.getxMLGregorianCalendar().getTimezone()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
}
Also used : LocalDateTimeBean(org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean) XmlGregorianCalendarToLocalDateTime(org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDateTime) LocalDateTime(org.joda.time.LocalDateTime) XmlGregorianCalendarBean(org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 5 with LocalDateTimeBean

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

the class JodaTimeTest method shouldMapLocalDateTimeToXmlGregorianCalendar.

@ProcessorTest
@WithClasses(LocalDateTimeToXmlGregorianCalendar.class)
public void shouldMapLocalDateTimeToXmlGregorianCalendar() {
    LocalDateTimeBean in = new LocalDateTimeBean();
    LocalDateTime dt = new LocalDateTime(2010, 1, 15, 1, 1, 1, 100);
    in.setLocalDateTime(dt);
    XmlGregorianCalendarBean res = LocalDateTimeToXmlGregorianCalendar.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(DatatypeConstants.FIELD_UNDEFINED);
}
Also used : LocalDateTimeBean(org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean) XmlGregorianCalendarToLocalDateTime(org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDateTime) LocalDateTime(org.joda.time.LocalDateTime) 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