Search in sources :

Example 91 with WithClasses

use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.

the class JodaTimeTest method shouldMapIncompleteLocalTimeToXmlGregorianCalendar.

@ProcessorTest
@WithClasses(LocalTimeToXmlGregorianCalendar.class)
public void shouldMapIncompleteLocalTimeToXmlGregorianCalendar() {
    LocalTimeBean in = new LocalTimeBean();
    LocalTime dt = new LocalTime(1, 1, 0, 100);
    in.setLocalTime(dt);
    XmlGregorianCalendarBean res = LocalTimeToXmlGregorianCalendar.INSTANCE.toXmlGregorianCalendarBean(in);
    assertThat(res.getxMLGregorianCalendar().getYear()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
    assertThat(res.getxMLGregorianCalendar().getMonth()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
    assertThat(res.getxMLGregorianCalendar().getDay()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
    assertThat(res.getxMLGregorianCalendar().getHour()).isEqualTo(1);
    assertThat(res.getxMLGregorianCalendar().getMinute()).isEqualTo(1);
    assertThat(res.getxMLGregorianCalendar().getSecond()).isEqualTo(0);
    assertThat(res.getxMLGregorianCalendar().getMillisecond()).isEqualTo(100);
    assertThat(res.getxMLGregorianCalendar().getTimezone()).isEqualTo(DatatypeConstants.FIELD_UNDEFINED);
}
Also used : LocalTime(org.joda.time.LocalTime) XmlGregorianCalendarToLocalTime(org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalTime) 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 92 with WithClasses

use of org.mapstruct.ap.testutil.WithClasses 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 93 with WithClasses

use of org.mapstruct.ap.testutil.WithClasses 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)

Example 94 with WithClasses

use of org.mapstruct.ap.testutil.WithClasses 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)

Example 95 with WithClasses

use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.

the class JodaTimeTest method shouldMapXmlGregorianCalendarWithoutMillisAndTimeZoneToDateTimeWithDefaultTimeZone.

@ProcessorTest
@WithClasses(XmlGregorianCalendarToDateTime.class)
public void shouldMapXmlGregorianCalendarWithoutMillisAndTimeZoneToDateTimeWithDefaultTimeZone() 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);
    DateTimeBean res = XmlGregorianCalendarToDateTime.INSTANCE.toDateTimeBean(in);
    assertThat(res.getDateTime().getYear()).isEqualTo(1999);
    assertThat(res.getDateTime().getMonthOfYear()).isEqualTo(5);
    assertThat(res.getDateTime().getDayOfMonth()).isEqualTo(25);
    assertThat(res.getDateTime().getHourOfDay()).isEqualTo(23);
    assertThat(res.getDateTime().getMinuteOfHour()).isEqualTo(34);
    assertThat(res.getDateTime().getSecondOfMinute()).isEqualTo(45);
    assertThat(res.getDateTime().getMillisOfSecond()).isEqualTo(0);
    assertThat(res.getDateTime().getZone().getOffset(0)).isEqualTo(DateTimeZone.getDefault().getOffset(0));
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) 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) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

WithClasses (org.mapstruct.ap.testutil.WithClasses)119 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)118 XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)24 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)17 IssueKey (org.mapstruct.ap.testutil.IssueKey)17 LocalDateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean)16 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)12 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)11 DateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.DateTimeBean)10 CalendarProperty (org.mapstruct.ap.test.builtin.bean.CalendarProperty)8 Song (org.mapstruct.ap.test.constructor.nestedsource.source.Song)8 ChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry)7 BigDecimal (java.math.BigDecimal)6 BigInteger (java.math.BigInteger)6 ChartEntry (org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry)6 Date (java.util.Date)5 LocalDateTime (org.joda.time.LocalDateTime)5 StringProperty (org.mapstruct.ap.test.builtin.bean.StringProperty)5 XmlGregorianCalendarToLocalDateTime (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDateTime)5 VehicleCollection (org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollection)5