Search in sources :

Example 6 with Studio

use of org.mapstruct.ap.test.nestedsourceproperties.source.Studio 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;
}
Also used : Artist(org.mapstruct.ap.test.nestedsourceproperties.source.Artist) Label(org.mapstruct.ap.test.nestedsourceproperties.source.Label) Studio(org.mapstruct.ap.test.nestedsourceproperties.source.Studio)

Example 7 with Studio

use of org.mapstruct.ap.test.nestedsourceproperties.source.Studio 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;
}
Also used : Artist(org.mapstruct.ap.test.nestedsourceproperties.source.Artist) Label(org.mapstruct.ap.test.nestedsourceproperties.source.Label) Studio(org.mapstruct.ap.test.nestedsourceproperties.source.Studio)

Example 8 with Studio

use of org.mapstruct.ap.test.nestedsourceproperties.source.Studio in project mapstruct by mapstruct.

the class NestedSourcePropertiesTest method shouldGenerateImplementationForMultipleParam.

@ProcessorTest
@WithClasses({ ArtistToChartEntry.class })
public void shouldGenerateImplementationForMultipleParam() {
    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");
    Chart chart = new Chart();
    chart.setName("Billboard");
    chart.setType("record-sales");
    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");
}
Also used : Artist(org.mapstruct.ap.test.nestedsourceproperties.source.Artist) Song(org.mapstruct.ap.test.nestedsourceproperties.source.Song) ChartEntry(org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry) Label(org.mapstruct.ap.test.nestedsourceproperties.source.Label) Studio(org.mapstruct.ap.test.nestedsourceproperties.source.Studio) Chart(org.mapstruct.ap.test.nestedsourceproperties.source.Chart) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

Studio (org.mapstruct.ap.test.nestedsourceproperties.source.Studio)8 Artist (org.mapstruct.ap.test.nestedsourceproperties.source.Artist)7 Label (org.mapstruct.ap.test.nestedsourceproperties.source.Label)7 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)5 ChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry)2 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)2 WithClasses (org.mapstruct.ap.testutil.WithClasses)2 ChartEntryLabel (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntryLabel)1 Chart (org.mapstruct.ap.test.nestedsourceproperties.source.Chart)1