use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry 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");
}
use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class NestedSourcePropertiesTest method shouldPickPropertyNameOverParameterName.
@ProcessorTest
@WithClasses({ ArtistToChartEntry.class })
public void shouldPickPropertyNameOverParameterName() {
Chart chart = new Chart();
chart.setName("Billboard");
chart.setType("record-sales");
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();
}
use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class NestedProductPropertiesTest method shouldMapNestedComposedTarget.
@ProcessorTest
public void shouldMapNestedComposedTarget() {
ChartEntry chartEntry1 = new ChartEntry();
chartEntry1.setArtistName("Prince");
chartEntry1.setCity("Minneapolis");
chartEntry1.setRecordedAt("Live, First Avenue, Minneapolis");
chartEntry1.setSongTitle("Purple Rain");
ChartEntry chartEntry2 = new ChartEntry();
chartEntry2.setChartName("Italian Singles Chart");
chartEntry2.setPosition(32);
Chart result = ChartEntryToArtist.MAPPER.map(chartEntry1, chartEntry2);
assertThat(result.getName()).isEqualTo("Italian Singles Chart");
assertThat(result.getSong()).isNotNull();
assertThat(result.getSong().getArtist()).isNotNull();
assertThat(result.getSong().getTitle()).isEqualTo("Purple Rain");
assertThat(result.getSong().getArtist().getName()).isEqualTo("Prince");
assertThat(result.getSong().getArtist().getLabel()).isNotNull();
assertThat(result.getSong().getArtist().getLabel().getStudio()).isNotNull();
assertThat(result.getSong().getArtist().getLabel().getStudio().getName()).isEqualTo("Live, First Avenue, Minneapolis");
assertThat(result.getSong().getArtist().getLabel().getStudio().getCity()).isEqualTo("Minneapolis");
assertThat(result.getSong().getPositions()).hasSize(1);
assertThat(result.getSong().getPositions().get(0)).isEqualTo(32);
}
use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class NestedProductPropertiesTest method shouldReverseNestedTarget.
@ProcessorTest
public void shouldReverseNestedTarget() {
ChartEntry chartEntry = new ChartEntry();
chartEntry.setArtistName("Prince");
chartEntry.setChartName("US Billboard Hot Rock Songs");
chartEntry.setCity("Minneapolis");
chartEntry.setPosition(1);
chartEntry.setRecordedAt("Live, First Avenue, Minneapolis");
chartEntry.setSongTitle("Purple Rain");
Chart chart = ChartEntryToArtist.MAPPER.map(chartEntry);
ChartEntry result = ChartEntryToArtist.MAPPER.map(chart);
assertThat(result).isNotNull();
assertThat(result.getArtistName()).isEqualTo("Prince");
assertThat(result.getChartName()).isEqualTo("US Billboard Hot Rock Songs");
assertThat(result.getCity()).isEqualTo("Minneapolis");
assertThat(result.getPosition()).isEqualTo(1);
assertThat(result.getRecordedAt()).isEqualTo("Live, First Avenue, Minneapolis");
assertThat(result.getSongTitle()).isEqualTo("Purple Rain");
}
Aggregations