Search in sources :

Example 1 with StringProperty

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

the class BuiltInTest method shouldApplyBuiltInStringToXmlGregCal.

@ProcessorTest
@WithClasses(StringToXmlGregCalMapper.class)
public void shouldApplyBuiltInStringToXmlGregCal() {
    StringProperty source = new StringProperty();
    source.setProp("05.07.1999");
    source.publicProp = "05.07.2016";
    XmlGregorianCalendarProperty target = StringToXmlGregCalMapper.INSTANCE.mapAndFormat(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().toString()).isEqualTo("1999-07-05T00:00:00.000+02:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.toString()).isEqualTo("2016-07-05T00:00:00.000+02:00");
    // direct,via lexical representation
    source.setProp("2000-03-04T23:00:00+03:00");
    source.publicProp = "2016-03-04T23:00:00+03:00";
    target = StringToXmlGregCalMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().toString()).isEqualTo("2000-03-04T23:00:00+03:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.toString()).isEqualTo("2016-03-04T23:00:00+03:00");
    // null string
    source.setProp(null);
    source.publicProp = null;
    target = StringToXmlGregCalMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNull();
    assertThat(target.publicProp).isNull();
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) StringProperty(org.mapstruct.ap.test.builtin.bean.StringProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with StringProperty

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

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

the class BuiltInTest method shouldApplyBuiltInOnCalendarToString.

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

Example 4 with StringProperty

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

the class BuiltInTest method shouldApplyBuiltInXmlGregCalToString.

@ProcessorTest
@WithClasses(XmlGregCalToStringMapper.class)
public void shouldApplyBuiltInXmlGregCalToString() throws DatatypeConfigurationException {
    XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
    source.setProp(createXmlCal(1999, 3, 2, 60));
    source.publicProp = createXmlCal(2016, 3, 2, 60);
    StringProperty target = XmlGregCalToStringMapper.INSTANCE.mapAndFormat(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo("02.03.1999");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo("02.03.2016");
    source.setProp(createXmlCal(1999, 3, 2, 60));
    source.publicProp = createXmlCal(2016, 3, 2, 60);
    target = XmlGregCalToStringMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo("1999-03-02+01:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo("2016-03-02+01:00");
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) StringProperty(org.mapstruct.ap.test.builtin.bean.StringProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 5 with StringProperty

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

the class BuiltInTest method shouldApplyBuiltInOnStringToCalendar.

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

Aggregations

StringProperty (org.mapstruct.ap.test.builtin.bean.StringProperty)5 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)5 WithClasses (org.mapstruct.ap.testutil.WithClasses)5 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)4 CalendarProperty (org.mapstruct.ap.test.builtin.bean.CalendarProperty)2 JaxbElementProperty (org.mapstruct.ap.test.builtin.bean.JaxbElementProperty)1 WithJavaxJaxb (org.mapstruct.ap.testutil.WithJavaxJaxb)1