use of org.mapstruct.ap.test.constructor.nestedsource.source.Label 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.constructor.nestedsource.source.Label 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.constructor.nestedsource.source.Label in project mapstruct by mapstruct.
the class NestedSourcePropertiesConstructorTest method shouldGenerateImplementationForMultipleParam.
@ProcessorTest
@WithClasses({ ArtistToChartEntry.class })
public void shouldGenerateImplementationForMultipleParam() {
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());
Chart chart = new Chart("record-sales", "Billboard", null);
ChartEntry chartEntry = ArtistToChartEntry.MAPPER.map(chart, song, 1);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistName()).isEqualTo("The Beatles");
assertThat(chartEntry.getChartName()).isEqualTo("Billboard");
assertThat(chartEntry.getCity()).isEqualTo("London");
assertThat(chartEntry.getPosition()).isEqualTo(1);
assertThat(chartEntry.getRecordedAt()).isEqualTo("Abbey Road");
assertThat(chartEntry.getSongTitle()).isEqualTo("A Hard Day's Night");
chartEntry = ArtistToChartEntry.MAPPER.map(null, song, 10);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistName()).isEqualTo("The Beatles");
assertThat(chartEntry.getChartName()).isNull();
assertThat(chartEntry.getCity()).isEqualTo("London");
assertThat(chartEntry.getPosition()).isEqualTo(10);
assertThat(chartEntry.getRecordedAt()).isEqualTo("Abbey Road");
assertThat(chartEntry.getSongTitle()).isEqualTo("A Hard Day's Night");
chartEntry = ArtistToChartEntry.MAPPER.map(chart, null, 5);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistName()).isNull();
assertThat(chartEntry.getChartName()).isEqualTo("Billboard");
assertThat(chartEntry.getCity()).isNull();
assertThat(chartEntry.getPosition()).isEqualTo(5);
assertThat(chartEntry.getRecordedAt()).isNull();
assertThat(chartEntry.getSongTitle()).isNull();
chartEntry = ArtistToChartEntry.MAPPER.map(chart, song, null);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistName()).isEqualTo("The Beatles");
assertThat(chartEntry.getChartName()).isEqualTo("Billboard");
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.constructor.nestedsource.source.Label in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesConstructorTest method prepareSong.
private Song prepareSong() {
Studio studio = new Studio("Abbey Road", "London");
Label label = new Label("EMY", studio);
Artist artist = new Artist("The Beatles", label);
return new Song(artist, "A Hard Day's Night", Collections.emptyList());
}
use of org.mapstruct.ap.test.constructor.nestedsource.source.Label in project mapstruct by mapstruct.
the class ChartEntryToArtistImpl method chartEntryToLabel.
protected Label chartEntryToLabel(ChartEntry chartEntry) {
if (chartEntry == null) {
return null;
}
Studio studio = null;
studio = chartEntryToStudio(chartEntry);
String name = null;
Label label = new Label(name, studio);
return label;
}
Aggregations