use of org.mapstruct.ap.test.nestedsourceproperties.source.Artist in project mapstruct by mapstruct.
the class NestedSourcePropertiesTest method shouldGenerateImplementationForPropertyNamesOnly.
@ProcessorTest
@WithClasses({ ArtistToChartEntry.class })
public void shouldGenerateImplementationForPropertyNamesOnly() {
generatedSource.addComparisonToFixtureFor(ArtistToChartEntry.class);
Studio studio = new Studio();
studio.setName("Abbey Road");
studio.setCity("London");
Label label = new Label();
label.setStudio(studio);
label.setName("EMY");
Artist artist = new Artist();
artist.setName("The Beatles");
artist.setLabel(label);
Song song = new Song();
song.setArtist(artist);
song.setTitle("A Hard Day's Night");
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.test.nestedsourceproperties.source.Artist in project mapstruct by mapstruct.
the class ArtistToChartEntryImpl method songArtistLabelStudioName.
private String songArtistLabelStudioName(Song song) {
if (song == null) {
return null;
}
Artist artist = song.getArtist();
if (artist == null) {
return null;
}
Label label = artist.getLabel();
if (label == null) {
return null;
}
Studio studio = label.getStudio();
if (studio == null) {
return null;
}
String name = studio.getName();
if (name == null) {
return null;
}
return name;
}
use of org.mapstruct.ap.test.nestedsourceproperties.source.Artist in project mapstruct by mapstruct.
the class ArtistToChartEntryImpl method songArtistName.
private String songArtistName(Song song) {
if (song == null) {
return null;
}
Artist artist = song.getArtist();
if (artist == null) {
return null;
}
String name = artist.getName();
if (name == null) {
return null;
}
return name;
}
use of org.mapstruct.ap.test.nestedsourceproperties.source.Artist in project mapstruct by mapstruct.
the class ArtistToChartEntryImpl method songArtistLabelStudioCity.
private String songArtistLabelStudioCity(Song song) {
if (song == null) {
return null;
}
Artist artist = song.getArtist();
if (artist == null) {
return null;
}
Label label = artist.getLabel();
if (label == null) {
return null;
}
Studio studio = label.getStudio();
if (studio == null) {
return null;
}
String city = studio.getCity();
if (city == null) {
return null;
}
return city;
}
use of org.mapstruct.ap.test.nestedsourceproperties.source.Artist in project mapstruct by mapstruct.
the class ChartEntryToArtistUpdateImpl method chartEntryToSong.
protected void chartEntryToSong(ChartEntry chartEntry, Song mappingTarget) {
if (chartEntry == null) {
return;
}
if (mappingTarget.getArtist() == null) {
mappingTarget.setArtist(new Artist());
}
chartEntryToArtist(chartEntry, mappingTarget.getArtist());
if (chartEntry.getSongTitle() != null) {
mappingTarget.setTitle(chartEntry.getSongTitle());
}
if (mappingTarget.getPositions() != null) {
List<Integer> list = mapPosition(chartEntry.getPosition());
if (list != null) {
mappingTarget.getPositions().clear();
mappingTarget.getPositions().addAll(list);
}
} else {
List<Integer> list = mapPosition(chartEntry.getPosition());
if (list != null) {
mappingTarget.setPositions(list);
}
}
}
Aggregations