use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class EnumToEnumThrowExceptionMappingTest method shouldIgnoreThrowExceptionWhenInverseValueMappings.
@IssueKey("2339")
@ProcessorTest
@WithClasses({ OrderThrowExceptionMapper.class, OrderDto.class })
public void shouldIgnoreThrowExceptionWhenInverseValueMappings() {
OrderType target = OrderThrowExceptionMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.B2B);
assertThat(target).isEqualTo(OrderType.B2B);
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class Issue1482Test method testReverse.
@ProcessorTest
@WithClasses(TargetSourceMapper.class)
public void testReverse() {
Target target = new Target();
target.setBigDecimal(new BigDecimal(5));
target.setTest("VAL1");
Source2 source2 = TargetSourceMapper.INSTANCE.map(target);
assertThat(source2).isNotNull();
assertThat(source2.getTest()).isEqualTo(SourceEnum.VAL1);
assertThat(source2.getWrapper().getValue()).isEqualTo(new BigDecimal(5));
}
use of org.mapstruct.ap.testutil.WithClasses 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.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnXmlGregCalToCalendar.
@ProcessorTest
@WithClasses(XmlGregCalToCalendarMapper.class)
public void shouldApplyBuiltInOnXmlGregCalToCalendar() throws DatatypeConfigurationException {
XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
source.setProp(createXmlCal(1999, 3, 2, 60));
source.publicProp = createXmlCal(2016, 3, 2, 60);
CalendarProperty target = XmlGregCalToCalendarMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().getTimeInMillis()).isEqualTo(920329200000L);
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.getTimeInMillis()).isEqualTo(1456873200000L);
assertThat(target.publicProp.getTimeInMillis()).isEqualTo(1456873200000L);
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnZonedDateTimeToCalendar.
@ProcessorTest
@WithClasses(ZonedDateTimeToCalendarMapper.class)
public void shouldApplyBuiltInOnZonedDateTimeToCalendar() throws ParseException {
assertThat(ZonedDateTimeToCalendarMapper.INSTANCE.map(null)).isNull();
ZonedDateTimeProperty source = new ZonedDateTimeProperty();
source.setProp(ZonedDateTime.of(1999, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
source.publicProp = ZonedDateTime.of(2016, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault());
CalendarProperty target = ZonedDateTimeToCalendarMapper.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