use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class ArtistToChartEntryImpl method map.
@Override
public ChartEntry map(Chart name) {
if (name == null) {
return null;
}
String chartName = null;
chartName = name.getName();
String songTitle = null;
String artistName = null;
String recordedAt = null;
String city = null;
int position = 0;
ChartEntry chartEntry = new ChartEntry(chartName, songTitle, artistName, recordedAt, city, position);
return chartEntry;
}
use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class ArtistToChartEntryImpl method map.
@Override
public ChartEntry map(Song song) {
if (song == null) {
return null;
}
String songTitle = null;
String artistName = null;
String recordedAt = null;
String city = null;
songTitle = song.getTitle();
artistName = songArtistName(song);
recordedAt = songArtistLabelStudioName(song);
city = songArtistLabelStudioCity(song);
String chartName = null;
int position = 0;
ChartEntry chartEntry = new ChartEntry(chartName, songTitle, artistName, recordedAt, city, position);
return chartEntry;
}
use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class NestedProductPropertiesTest method shouldMapNestedTargetWitUpdate.
@ProcessorTest
public void shouldMapNestedTargetWitUpdate() {
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(null);
Chart result = new Chart();
result.setSong(new Song());
result.getSong().setTitle("Raspberry Beret");
ChartEntryToArtistUpdate.MAPPER.map(chartEntry, result);
assertThat(result.getName()).isEqualTo("US Billboard Hot Rock Songs");
assertThat(result.getSong()).isNotNull();
assertThat(result.getSong().getArtist()).isNotNull();
assertThat(result.getSong().getTitle()).isEqualTo("Raspberry Beret");
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(1);
}
use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesTest method shouldGenerateNestedReverse.
@ProcessorTest
@WithClasses({ ArtistToChartEntryReverse.class })
public void shouldGenerateNestedReverse() {
Song song1 = prepareSong();
ChartEntry chartEntry = ArtistToChartEntryReverse.MAPPER.mapForward(song1);
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");
// and now in reverse
Song song2 = ArtistToChartEntryReverse.MAPPER.mapReverse(chartEntry);
assertThat(song2).isNotNull();
assertThat(song2.getArtist()).isNotNull();
assertThat(song2.getArtist().getName()).isEqualTo("The Beatles");
assertThat(song2.getArtist().getLabel()).isNotNull();
assertThat(song2.getArtist().getLabel().getName()).isNull();
assertThat(song2.getArtist().getLabel().getStudio()).isNotNull();
assertThat(song2.getArtist().getLabel().getStudio().getCity()).isEqualTo("London");
assertThat(song2.getArtist().getLabel().getStudio().getName()).isEqualTo("Abbey Road");
}
use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesTest method shouldGenerateNestedUpdateReverse.
@ProcessorTest
@WithClasses({ ArtistToChartEntryUpdateReverse.class })
public void shouldGenerateNestedUpdateReverse() {
Song song1 = prepareSong();
ChartEntry chartEntry = ArtistToChartEntryUpdateReverse.MAPPER.mapForward(song1);
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");
// and now in reverse
Song song2 = new Song();
ArtistToChartEntryUpdateReverse.MAPPER.mapReverse(chartEntry, song2);
assertThat(song2).isNotNull();
assertThat(song2.getArtist()).isNotNull();
assertThat(song2.getArtist().getName()).isEqualTo("The Beatles");
assertThat(song2.getArtist().getLabel()).isNotNull();
assertThat(song2.getArtist().getLabel().getName()).isNull();
assertThat(song2.getArtist().getLabel().getStudio()).isNotNull();
assertThat(song2.getArtist().getLabel().getStudio().getCity()).isEqualTo("London");
assertThat(song2.getArtist().getLabel().getStudio().getName()).isEqualTo("Abbey Road");
}
Aggregations