use of org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntryWithMapping in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesConstructorTest method shouldGenerateNestedWithMappingReverse.
@ProcessorTest
@WithClasses({ ArtistToChartEntryWithMappingReverse.class, ChartEntryWithMapping.class })
public void shouldGenerateNestedWithMappingReverse() {
Song song1 = prepareSong();
ChartEntryWithMapping chartEntry = ArtistToChartEntryWithMappingReverse.MAPPER.mapForward(song1);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistId()).isEqualTo(1);
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 = ArtistToChartEntryWithMappingReverse.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.nestedsourceproperties._target.ChartEntryWithMapping in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesTest method shouldGenerateNestedWithMappingReverse.
@ProcessorTest
@WithClasses({ ArtistToChartEntryWithMappingReverse.class, ChartEntryWithMapping.class })
public void shouldGenerateNestedWithMappingReverse() {
Song song1 = prepareSong();
ChartEntryWithMapping chartEntry = ArtistToChartEntryWithMappingReverse.MAPPER.mapForward(song1);
assertThat(chartEntry).isNotNull();
assertThat(chartEntry.getArtistId()).isEqualTo(1);
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 = ArtistToChartEntryWithMappingReverse.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");
}
Aggregations