Search in sources :

Example 11 with WithClasses

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

the class BuiltInTest method shouldApplyBuiltInOnJAXBElementList.

@ProcessorTest
@WithClasses({ JaxbListMapper.class, JaxbElementListProperty.class })
@WithJavaxJaxb
@IssueKey("141")
public void shouldApplyBuiltInOnJAXBElementList() {
    JaxbElementListProperty source = new JaxbElementListProperty();
    source.setProp(createJaxbList("TEST2"));
    source.publicProp = createJaxbList("PUBLIC TEST2");
    StringListProperty target = JaxbListMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp().get(0)).isEqualTo("TEST2");
    assertThat(target.publicProp.get(0)).isEqualTo("PUBLIC TEST2");
}
Also used : StringListProperty(org.mapstruct.ap.test.builtin.bean.StringListProperty) JaxbElementListProperty(org.mapstruct.ap.test.builtin.bean.JaxbElementListProperty) WithJavaxJaxb(org.mapstruct.ap.testutil.WithJavaxJaxb) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 12 with WithClasses

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

the class BuiltInTest method shouldApplyBuiltInOnJAXBElementExtra.

@ProcessorTest
@WithClasses({ JaxbMapper.class, JaxbElementProperty.class })
@WithJavaxJaxb
@IssueKey("1698")
public void shouldApplyBuiltInOnJAXBElementExtra() {
    JaxbElementProperty source = new JaxbElementProperty();
    source.setProp(createJaxb("5"));
    source.publicProp = createJaxb("5");
    BigDecimalProperty target = JaxbMapper.INSTANCE.mapBD(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isEqualTo(new BigDecimal("5"));
    assertThat(target.publicProp).isEqualTo(new BigDecimal("5"));
    JaxbElementProperty source2 = new JaxbElementProperty();
    source2.setProp(createJaxb("5"));
    source2.publicProp = createJaxb("5");
    SomeTypeProperty target2 = JaxbMapper.INSTANCE.mapSomeType(source2);
    assertThat(target2).isNotNull();
    assertThat(target2.publicProp).isNotNull();
    assertThat(target2.getProp()).isNotNull();
}
Also used : BigDecimalProperty(org.mapstruct.ap.test.builtin.bean.BigDecimalProperty) SomeTypeProperty(org.mapstruct.ap.test.builtin.bean.SomeTypeProperty) JaxbElementProperty(org.mapstruct.ap.test.builtin.bean.JaxbElementProperty) BigDecimal(java.math.BigDecimal) WithJavaxJaxb(org.mapstruct.ap.testutil.WithJavaxJaxb) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 13 with WithClasses

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

the class BuiltInTest method shouldApplyBuiltInOnCalendarToDate.

@ProcessorTest
@WithClasses(CalendarToDateMapper.class)
public void shouldApplyBuiltInOnCalendarToDate() throws ParseException {
    CalendarProperty source = new CalendarProperty();
    source.setProp(createCalendar("02.03.1999"));
    source.publicProp = createCalendar("02.03.2016");
    DateProperty target = CalendarToDateMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo(createCalendar("02.03.1999").getTime());
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo(createCalendar("02.03.2016").getTime());
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) CalendarProperty(org.mapstruct.ap.test.builtin.bean.CalendarProperty) DateProperty(org.mapstruct.ap.test.builtin.bean.DateProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 14 with WithClasses

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

the class BuiltInTest method shouldApplyBuiltInOnJAXBElement.

@ProcessorTest
@WithClasses({ JaxbMapper.class, JaxbElementProperty.class })
@WithJavaxJaxb
public void shouldApplyBuiltInOnJAXBElement() {
    JaxbElementProperty source = new JaxbElementProperty();
    source.setProp(createJaxb("TEST"));
    source.publicProp = createJaxb("PUBLIC TEST");
    StringProperty target = JaxbMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isEqualTo("TEST");
    assertThat(target.publicProp).isEqualTo("PUBLIC TEST");
}
Also used : StringProperty(org.mapstruct.ap.test.builtin.bean.StringProperty) JaxbElementProperty(org.mapstruct.ap.test.builtin.bean.JaxbElementProperty) WithJavaxJaxb(org.mapstruct.ap.testutil.WithJavaxJaxb) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 15 with WithClasses

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

the class BuiltInTest method shouldApplyBuiltInOnCalendarToZonedDateTime.

@ProcessorTest
@WithClasses(CalendarToZonedDateTimeMapper.class)
public void shouldApplyBuiltInOnCalendarToZonedDateTime() throws ParseException {
    assertThat(CalendarToZonedDateTimeMapper.INSTANCE.map(null)).isNull();
    CalendarProperty source = new CalendarProperty();
    source.setProp(createCalendar("02.03.1999"));
    source.publicProp = createCalendar("02.03.2016");
    ZonedDateTimeProperty target = CalendarToZonedDateTimeMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo(ZonedDateTime.of(1999, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo(ZonedDateTime.of(2016, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) CalendarProperty(org.mapstruct.ap.test.builtin.bean.CalendarProperty) ZonedDateTimeProperty(org.mapstruct.ap.test.builtin.java8time.bean.ZonedDateTimeProperty) 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