use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class MultipleBuilderMapperTest method builderMappingMapperConfigDefined.
@WithClasses({ BuilderMapperConfig.class, BuilderConfigDefinedMapper.class })
@ProcessorTest
public void builderMappingMapperConfigDefined() {
Process map = BuilderConfigDefinedMapper.INSTANCE.map(new Source("map"));
Process wrongMap = BuilderConfigDefinedMapper.INSTANCE.wrongMap(new Source("wrongMap"));
assertThat(map.getBuildMethod()).isEqualTo("create");
assertThat(wrongMap.getBuildMethod()).isEqualTo("wrongCreate");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class Issue2318Test method shouldMap.
@ProcessorTest
@WithClasses(Issue2318Mapper.class)
public void shouldMap() {
SourceChild source = new SourceChild();
source.setValue("From child");
source.setHolder(new Issue2318Mapper.SourceParent.Holder());
source.getHolder().setParentValue1("From parent");
source.getHolder().setParentValue2(12);
TargetChild target = Issue2318Mapper.INSTANCE.mapChild(source);
assertThat(target.getParentValue1()).isEqualTo("From parent");
assertThat(target.getParentValue2()).isEqualTo(12);
assertThat(target.getChildValue()).isEqualTo("From child");
}
use of org.mapstruct.ap.testutil.WithClasses 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"));
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class NestedSourcePropertiesConstructorTest method shouldGenerateImplementationForPropertyNamesOnly.
@ProcessorTest
@WithClasses({ ArtistToChartEntry.class })
public void shouldGenerateImplementationForPropertyNamesOnly() {
generatedSource.addComparisonToFixtureFor(ArtistToChartEntry.class);
Studio studio = new Studio("Abbey Road", "London");
Label label = new Label("EMY", studio);
Artist artist = new Artist("The Beatles", label);
Song song = new Song(artist, "A Hard Day's Night", Collections.emptyList());
ChartEntry chartEntry = ArtistToChartEntry.MAPPER.map(song);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistName()).isEqualTo("The Beatles");
assertThat(chartEntry.getChartName()).isNull();
assertThat(chartEntry.getCity()).isEqualTo("London");
assertThat(chartEntry.getPosition()).isEqualTo(0);
assertThat(chartEntry.getRecordedAt()).isEqualTo("Abbey Road");
assertThat(chartEntry.getSongTitle()).isEqualTo("A Hard Day's Night");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class NestedSourcePropertiesConstructorTest method shouldPickPropertyNameOverParameterName.
@ProcessorTest
@WithClasses({ ArtistToChartEntry.class })
public void shouldPickPropertyNameOverParameterName() {
Chart chart = new Chart("record-sales", "Billboard", null);
ChartEntry chartEntry = ArtistToChartEntry.MAPPER.map(chart);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistName()).isNull();
assertThat(chartEntry.getChartName()).isEqualTo("Billboard");
assertThat(chartEntry.getCity()).isNull();
assertThat(chartEntry.getPosition()).isEqualTo(0);
assertThat(chartEntry.getRecordedAt()).isNull();
assertThat(chartEntry.getSongTitle()).isNull();
}
Aggregations