Search in sources :

Example 46 with ProcessorTest

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

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

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

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

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

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)314 WithClasses (org.mapstruct.ap.testutil.WithClasses)118 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)51 IssueKey (org.mapstruct.ap.testutil.IssueKey)39 XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)24 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)22 Date (java.util.Date)16 LocalDateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean)16 Calendar (java.util.Calendar)13 LocalDateTime (org.joda.time.LocalDateTime)13 CarDto (org.mapstruct.ap.test.complex._target.CarDto)13 Car (org.mapstruct.ap.test.complex.source.Car)13 PersonDto (org.mapstruct.ap.test.constructor.PersonDto)13 GregorianCalendar (java.util.GregorianCalendar)12 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)12 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)12 BigDecimal (java.math.BigDecimal)11 ChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry)11 DriverAndCarDto (org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto)11 DateTime (org.joda.time.DateTime)10