use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class CompilingStatement method getTestClasses.
/**
* Returns the classes to be compiled for this test.
*
* @return A set containing the classes to be compiled for this test
*/
private Set<Class<?>> getTestClasses() {
Set<Class<?>> testClasses = new HashSet<Class<?>>();
WithClasses withClasses = method.getAnnotation(WithClasses.class);
if (withClasses != null) {
testClasses.addAll(Arrays.asList(withClasses.value()));
}
withClasses = method.getMethod().getDeclaringClass().getAnnotation(WithClasses.class);
if (withClasses != null) {
testClasses.addAll(Arrays.asList(withClasses.value()));
}
if (testClasses.isEmpty()) {
throw new IllegalStateException("The classes to be compiled during the test must be specified via @WithClasses.");
}
return testClasses;
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class Issue1482Test method testForward.
@ProcessorTest
@WithClasses(SourceTargetMapper.class)
public void testForward() {
Source source = new Source();
source.setTest(SourceEnum.VAL1);
source.setWrapper(new BigDecimalWrapper(new BigDecimal(5)));
Target target = SourceTargetMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getTest()).isEqualTo("value1");
assertThat(target.getBigDecimal()).isEqualTo(new BigDecimal(5));
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnIterable.
@ProcessorTest
@WithClasses(IterableSourceTargetMapper.class)
public void shouldApplyBuiltInOnIterable() throws DatatypeConfigurationException {
IterableSource source = new IterableSource();
source.setDates(Arrays.asList(createXmlCal(1999, 3, 2, 60)));
source.publicDates = Arrays.asList(createXmlCal(2016, 3, 2, 60));
IterableTarget target = IterableSourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getDates()).containsExactly("02.03.1999");
assertThat(target.publicDates).containsExactly("02.03.2016");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnDateToXmlGregCal.
@ProcessorTest
@WithClasses(DateToXmlGregCalMapper.class)
public void shouldApplyBuiltInOnDateToXmlGregCal() throws ParseException {
DateProperty source = new DateProperty();
source.setProp(createDate("31-08-1982 10:20:56"));
source.publicProp = createDate("31-08-2016 10:20:56");
XmlGregorianCalendarProperty target = DateToXmlGregCalMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("1982-08-31T10:20:56.000+02:00");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("2016-08-31T10:20:56.000+02:00");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class BuiltInTest method shouldApplyBuiltInOnCalendarToXmlGregCal.
@ProcessorTest
@WithClasses(CalendarToXmlGregCalMapper.class)
public void shouldApplyBuiltInOnCalendarToXmlGregCal() throws ParseException {
CalendarProperty source = new CalendarProperty();
source.setProp(createCalendar("02.03.1999"));
source.publicProp = createCalendar("02.03.2016");
XmlGregorianCalendarProperty target = CalendarToXmlGregCalMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getProp()).isNotNull();
assertThat(target.getProp().toString()).isEqualTo("1999-03-02T00:00:00.000+01:00");
assertThat(target.publicProp).isNotNull();
assertThat(target.publicProp.toString()).isEqualTo("2016-03-02T00:00:00.000+01:00");
}
Aggregations