Search in sources :

Example 16 with ChartEntry

use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.

the class ReversingNestedSourcePropertiesConstructorTest 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");
}
Also used : Song(org.mapstruct.ap.test.constructor.nestedsource.source.Song) BaseChartEntry(org.mapstruct.ap.test.constructor.nestedsource._target.BaseChartEntry) ChartEntry(org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 17 with ChartEntry

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

Example 18 with ChartEntry

use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry 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 19 with ChartEntry

use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.

the class ReversingNestedSourcePropertiesConstructorTest method shouldGenerateNestedReverseWithFactory.

@ProcessorTest
@WithClasses({ ArtistToChartEntryWithFactoryReverse.class })
public void shouldGenerateNestedReverseWithFactory() {
    Song song1 = prepareSong();
    ChartEntry chartEntry = ArtistToChartEntryWithFactoryReverse.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 = ArtistToChartEntryWithFactoryReverse.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) BaseChartEntry(org.mapstruct.ap.test.constructor.nestedsource._target.BaseChartEntry) ChartEntry(org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 20 with ChartEntry

use of org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry in project mapstruct by mapstruct.

the class ReversingNestedSourcePropertiesConstructorTest method shouldGenerateNestedComposedReverse.

@ProcessorTest
@WithClasses({ ArtistToChartEntryComposedReverse.class, ChartEntryComposed.class, ChartEntryLabel.class })
public void shouldGenerateNestedComposedReverse() {
    Song song1 = prepareSong();
    ChartEntryComposed chartEntry = ArtistToChartEntryComposedReverse.MAPPER.mapForward(song1);
    assertThat(chartEntry).isNotNull();
    assertThat(chartEntry.getArtistName()).isEqualTo("The Beatles");
    assertThat(chartEntry.getChartName()).isNull();
    assertThat(chartEntry.getLabel().getName()).isEqualTo("EMY");
    assertThat(chartEntry.getLabel().getCity()).isEqualTo("London");
    assertThat(chartEntry.getLabel().getRecordedAt()).isEqualTo("Abbey Road");
    assertThat(chartEntry.getPosition()).isEqualTo(0);
    assertThat(chartEntry.getSongTitle()).isEqualTo("A Hard Day's Night");
    // and now in reverse
    Song song2 = ArtistToChartEntryComposedReverse.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()).isEqualTo("EMY");
    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) ChartEntryComposed(org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntryComposed) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)22 ChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry)19 WithClasses (org.mapstruct.ap.testutil.WithClasses)16 ChartEntry (org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry)12 Chart (org.mapstruct.ap.test.nestedsourceproperties.source.Chart)10 Song (org.mapstruct.ap.test.constructor.nestedsource.source.Song)8 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)8 Test (org.junit.Test)4 Chart (org.mapstruct.ap.test.constructor.nestedsource.source.Chart)4 BaseChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.BaseChartEntry)4 BaseChartEntry (org.mapstruct.ap.test.constructor.nestedsource._target.BaseChartEntry)3 Artist (org.mapstruct.ap.test.constructor.nestedsource.source.Artist)2 Label (org.mapstruct.ap.test.constructor.nestedsource.source.Label)2 Studio (org.mapstruct.ap.test.constructor.nestedsource.source.Studio)2 Artist (org.mapstruct.ap.test.nestedsourceproperties.source.Artist)2 Label (org.mapstruct.ap.test.nestedsourceproperties.source.Label)2 Studio (org.mapstruct.ap.test.nestedsourceproperties.source.Studio)2 ChartEntryComposed (org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntryComposed)1 ChartEntryWithBase (org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntryWithBase)1 ChartEntryWithMapping (org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntryWithMapping)1