Search in sources :

Example 6 with XmlGregorianCalendarBean

use of org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean 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 7 with XmlGregorianCalendarBean

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

Example 8 with XmlGregorianCalendarBean

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

Example 9 with XmlGregorianCalendarBean

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

Example 10 with XmlGregorianCalendarBean

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

the class JodaTimeTest method shouldMapDateTimeToXmlGregorianCalendar.

@ProcessorTest
@WithClasses(DateTimeToXmlGregorianCalendar.class)
public void shouldMapDateTimeToXmlGregorianCalendar() {
    DateTimeBean in = new DateTimeBean();
    DateTime dt = new DateTime(2010, 1, 15, 1, 1, 1, 100, DateTimeZone.forOffsetHours(-1));
    in.setDateTime(dt);
    XmlGregorianCalendarBean res = DateTimeToXmlGregorianCalendar.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(-60);
}
Also used : XmlGregorianCalendarBean(org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean) LocalDateTimeBean(org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean) DateTimeBean(org.mapstruct.ap.test.builtin.jodatime.bean.DateTimeBean) XmlGregorianCalendarToDateTime(org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToDateTime) XmlGregorianCalendarToLocalDateTime(org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDateTime) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)24 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)24 WithClasses (org.mapstruct.ap.testutil.WithClasses)24 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)17 LocalDateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean)16 DateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.DateTimeBean)10 LocalDateTime (org.joda.time.LocalDateTime)5 LocalTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalTimeBean)5 XmlGregorianCalendarToLocalDateTime (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDateTime)5 DateTime (org.joda.time.DateTime)3 LocalDateBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateBean)3 XmlGregorianCalendarToDateTime (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToDateTime)3 LocalDate (org.joda.time.LocalDate)1 LocalTime (org.joda.time.LocalTime)1 XmlGregorianCalendarToLocalDate (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDate)1 XmlGregorianCalendarToLocalTime (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalTime)1