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();
}
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");
}
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");
}
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");
}
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"));
}
Aggregations