use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class WildCardTest method shouldGenerateSuperBoundTargetForgedIterableMethod.
@ProcessorTest
@WithClasses({ SourceSuperBoundTargetMapper.class, Source.class, SuperBoundTarget.class, Plan.class, Idea.class })
public void shouldGenerateSuperBoundTargetForgedIterableMethod() {
Source source = new Source();
SuperBoundTarget target = SourceSuperBoundTargetMapper.STM.map(source);
assertThat(target).isNotNull();
assertThat(target.getElements()).isNull();
generatedSource.forMapper(SourceSuperBoundTargetMapper.class).content().as("Should not contain FQN after super").doesNotContain("? super org.mapstruct.ap.test.collection.wildcard.Idea");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class ConditionalQualifierTest method conditionalMethodWithSourceParameter.
@ProcessorTest
@WithClasses({ ConditionalMethodWithSourceParameterMapper.class })
public void conditionalMethodWithSourceParameter() {
ConditionalMethodWithSourceParameterMapper mapper = ConditionalMethodWithSourceParameterMapper.INSTANCE;
EmployeeDto dto = new EmployeeDto();
dto.setName("Tester");
dto.setUniqueIdNumber("SSID-001");
dto.setCountry(null);
Employee employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
dto.setCountry("UK");
employee = mapper.map(dto);
assertThat(employee.getNin()).isEqualTo("SSID-001");
assertThat(employee.getSsid()).isNull();
dto.setCountry("US");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isEqualTo("SSID-001");
dto.setCountry("CH");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesTest method shouldIgnoreEverytingBelowArtist.
@ProcessorTest
@WithClasses({ ArtistToChartEntryWithIgnoresReverse.class })
public void shouldIgnoreEverytingBelowArtist() {
Song song1 = prepareSong();
ChartEntry chartEntry = ArtistToChartEntryWithIgnoresReverse.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 = ArtistToChartEntryWithIgnoresReverse.MAPPER.mapReverse(chartEntry);
assertThat(song2).isNotNull();
assertThat(song2.getArtist()).isNull();
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesTest method shouldGenerateNestedReverseWithFactory.
@ProcessorTest
@WithClasses({ ArtistToChartEntryWithFactoryReverse.class, SourceDtoFactory.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");
assertThat(SourceDtoFactory.isCreateSongCalled()).isTrue();
assertThat(SourceDtoFactory.isCreateStudioCalled()).isTrue();
assertThat(SourceDtoFactory.isCreateLabelCalled()).isTrue();
assertThat(SourceDtoFactory.isCreateArtistCalled()).isTrue();
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class ReversingNestedSourcePropertiesTest 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");
}
Aggregations