Search in sources :

Example 6 with Label

use of org.mapstruct.ap.test.constructor.nestedsource.source.Label 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");
}
Also used : Artist(org.mapstruct.ap.test.constructor.nestedsource.source.Artist) Song(org.mapstruct.ap.test.constructor.nestedsource.source.Song) ChartEntry(org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry) Label(org.mapstruct.ap.test.constructor.nestedsource.source.Label) Studio(org.mapstruct.ap.test.constructor.nestedsource.source.Studio) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 7 with Label

use of org.mapstruct.ap.test.constructor.nestedsource.source.Label in project mapstruct by mapstruct.

the class ChartEntryToArtistImpl method chartEntryToArtist.

protected Artist chartEntryToArtist(ChartEntry chartEntry) {
    if (chartEntry == null) {
        return null;
    }
    Label label = null;
    String name = null;
    label = chartEntryToLabel(chartEntry);
    name = chartEntry.getArtistName();
    Artist artist = new Artist(name, label);
    return artist;
}
Also used : Artist(org.mapstruct.ap.test.constructor.nestedsource.source.Artist) Label(org.mapstruct.ap.test.constructor.nestedsource.source.Label)

Example 8 with Label

use of org.mapstruct.ap.test.constructor.nestedsource.source.Label in project mapstruct by mapstruct.

the class ChartEntryToArtistImpl method chartSongArtistLabelStudioName.

private String chartSongArtistLabelStudioName(Chart chart) {
    if (chart == null) {
        return null;
    }
    Song song = chart.getSong();
    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.constructor.nestedsource.source.Artist) Song(org.mapstruct.ap.test.constructor.nestedsource.source.Song) Label(org.mapstruct.ap.test.constructor.nestedsource.source.Label) Studio(org.mapstruct.ap.test.constructor.nestedsource.source.Studio)

Example 9 with Label

use of org.mapstruct.ap.test.constructor.nestedsource.source.Label in project mapstruct by mapstruct.

the class ChartEntryToArtistImpl method chartSongArtistLabelStudioCity.

private String chartSongArtistLabelStudioCity(Chart chart) {
    if (chart == null) {
        return null;
    }
    Song song = chart.getSong();
    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.constructor.nestedsource.source.Artist) Song(org.mapstruct.ap.test.constructor.nestedsource.source.Song) Label(org.mapstruct.ap.test.constructor.nestedsource.source.Label) Studio(org.mapstruct.ap.test.constructor.nestedsource.source.Studio)

Aggregations

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