Search in sources :

Example 1 with ChartPositions

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

the class NestedSourcePropertiesTest method shouldUseAddAsTargetAccessor.

@ProcessorTest
@WithClasses({ ArtistToChartEntryAdder.class, ChartPositions.class, AdderUsageObserver.class })
public void shouldUseAddAsTargetAccessor() {
    AdderUsageObserver.setUsed(false);
    Song song = new Song();
    song.setPositions(Arrays.asList(3, 5));
    Chart chart = new Chart();
    chart.setSong(song);
    ChartPositions positions = ArtistToChartEntryAdder.MAPPER.map(chart);
    assertThat(positions).isNotNull();
    assertThat(positions.getPositions()).containsExactly(3L, 5L);
    assertThat(AdderUsageObserver.isUsed()).isTrue();
}
Also used : Song(org.mapstruct.ap.test.nestedsourceproperties.source.Song) ChartPositions(org.mapstruct.ap.test.nestedsourceproperties._target.ChartPositions) Chart(org.mapstruct.ap.test.nestedsourceproperties.source.Chart) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with ChartPositions

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

the class NestedSourcePropertiesTest method shouldUseGetAsTargetAccessor.

@ProcessorTest
@WithClasses({ ArtistToChartEntryGetter.class, ChartPositions.class, AdderUsageObserver.class })
public void shouldUseGetAsTargetAccessor() {
    AdderUsageObserver.setUsed(false);
    Song song = new Song();
    song.setPositions(Arrays.asList(3, 5));
    Chart chart = new Chart();
    chart.setSong(song);
    ChartPositions positions = ArtistToChartEntryGetter.MAPPER.map(chart);
    assertThat(positions).isNotNull();
    assertThat(positions.getPositions()).containsExactly(3L, 5L);
    assertThat(AdderUsageObserver.isUsed()).isFalse();
}
Also used : Song(org.mapstruct.ap.test.nestedsourceproperties.source.Song) ChartPositions(org.mapstruct.ap.test.nestedsourceproperties._target.ChartPositions) Chart(org.mapstruct.ap.test.nestedsourceproperties.source.Chart) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

ChartPositions (org.mapstruct.ap.test.nestedsourceproperties._target.ChartPositions)2 Chart (org.mapstruct.ap.test.nestedsourceproperties.source.Chart)2 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)2 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)2 WithClasses (org.mapstruct.ap.testutil.WithClasses)2