Search in sources :

Example 1 with ChartEntryWithBase

use of org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntryWithBase in project mapstruct by mapstruct.

the class ReversingNestedSourcePropertiesConstructorTest method shouldGenerateNestedWithConfigReverse.

@ProcessorTest
@WithClasses({ ArtistToChartEntryWithConfigReverse.class, ArtistToChartEntryConfig.class, BaseChartEntry.class, ChartEntryWithBase.class })
public void shouldGenerateNestedWithConfigReverse() {
    Song song1 = prepareSong();
    ChartEntryWithBase chartEntry = ArtistToChartEntryWithConfigReverse.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 = ArtistToChartEntryWithConfigReverse.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");
}
Also used : Song(org.mapstruct.ap.test.constructor.nestedsource.source.Song) ChartEntryWithBase(org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntryWithBase) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with ChartEntryWithBase

use of org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntryWithBase in project mapstruct by mapstruct.

the class ReversingNestedSourcePropertiesTest method shouldGenerateNestedWithConfigReverse.

@ProcessorTest
@WithClasses({ ArtistToChartEntryWithConfigReverse.class, ArtistToChartEntryConfig.class, BaseChartEntry.class, ChartEntryWithBase.class })
public void shouldGenerateNestedWithConfigReverse() {
    Song song1 = prepareSong();
    ChartEntryWithBase chartEntry = ArtistToChartEntryWithConfigReverse.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 = ArtistToChartEntryWithConfigReverse.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");
}
Also used : Song(org.mapstruct.ap.test.nestedsourceproperties.source.Song) ChartEntryWithBase(org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntryWithBase) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)2 WithClasses (org.mapstruct.ap.testutil.WithClasses)2 ChartEntryWithBase (org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntryWithBase)1 Song (org.mapstruct.ap.test.constructor.nestedsource.source.Song)1 ChartEntryWithBase (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntryWithBase)1 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)1