use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnXmlGregCalToDate.
@ProcessorTest
@WithClasses(XmlGregCalToDateMapper.class)
public void shouldApplyBuiltInOnXmlGregCalToDate() throws DatatypeConfigurationException {
XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
source.setProp(createXmlCal(1999, 3, 2, 60));
source.publicProp = createXmlCal(2016, 3, 2, 60);
DateProperty target = XmlGregCalToDateMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("Tue Mar 02 00:00:00 CET 1999");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("Wed Mar 02 00:00:00 CET 2016");
}
use of org.mapstruct.ap.testutil.WithClasses 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.testutil.WithClasses 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.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnMap.
@ProcessorTest
@WithClasses({ MapSourceTargetMapper.class, MapSource.class })
@WithJavaxJaxb
public void shouldApplyBuiltInOnMap() throws DatatypeConfigurationException {
MapSource source = new MapSource();
source.setExample(new HashMap<>());
source.getExample().put(createJaxb("TEST"), createXmlCal(1999, 3, 2, 60));
source.publicExample = new HashMap<>();
source.publicExample.put(createJaxb("TEST"), createXmlCal(2016, 3, 2, 60));
MapTarget target = MapSourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getExample().get("TEST")).isEqualTo("1999-03-02+01:00");
assertThat(target.publicExample.get("TEST")).isEqualTo("2016-03-02+01:00");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnDateToCalendar.
@ProcessorTest
@WithClasses(DateToCalendarMapper.class)
public void shouldApplyBuiltInOnDateToCalendar() throws ParseException {
DateProperty source = new DateProperty();
source.setProp(new SimpleDateFormat("dd.MM.yyyy").parse("02.03.1999"));
source.publicProp = new SimpleDateFormat("dd.MM.yyyy").parse("02.03.2016");
CalendarProperty target = DateToCalendarMapper.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