use of org.mapstruct.ap.test.collection.adder._target.Target in project mapstruct by mapstruct.
the class AdderTest method testAddOnlyGetter.
@ProcessorTest
public void testAddOnlyGetter() throws DogException {
AdderUsageObserver.setUsed(false);
Source source = new Source();
source.setPets(Arrays.asList("mouse"));
TargetOnlyGetter target = SourceTargetMapper.INSTANCE.toTargetOnlyGetter(source);
assertThat(target).isNotNull();
assertThat(target.getPets().size()).isEqualTo(1);
assertThat(target.getPets().get(0)).isEqualTo(2L);
assertTrue(AdderUsageObserver.isUsed());
}
use of org.mapstruct.ap.test.collection.adder._target.Target in project mapstruct by mapstruct.
the class AdderTest method useIterationNameFromSource.
@IssueKey("1478")
@ProcessorTest
public void useIterationNameFromSource() {
generatedSource.addComparisonToFixtureFor(SourceTargetMapperWithDifferentProperties.class);
SourceWithPets source = new SourceWithPets();
source.setPets(Arrays.asList("dog", "cat"));
TargetWithAnimals target = SourceTargetMapperWithDifferentProperties.INSTANCE.map(source);
assertThat(target.getAnimals()).containsExactly("dog", "cat");
}
use of org.mapstruct.ap.test.collection.adder._target.Target in project mapstruct by mapstruct.
the class AdderTest method testShouldPreferHumanSingular.
@ProcessorTest
public void testShouldPreferHumanSingular() {
AdderUsageObserver.setUsed(false);
SourceTeeth source = new SourceTeeth();
source.setTeeth(Arrays.asList("moler"));
TargetHuman target = SourceTargetMapper.INSTANCE.toTargetHuman(source);
assertThat(target).isNotNull();
assertThat(target.getTeeth().size()).isEqualTo(1);
assertThat(target.getTeeth().get(0)).isEqualTo(3);
assertTrue(AdderUsageObserver.isUsed());
}
use of org.mapstruct.ap.test.collection.adder._target.Target in project mapstruct by mapstruct.
the class AdderTest method testMissingImport.
@IssueKey("310")
@ProcessorTest
public void testMissingImport() {
generatedSource.addComparisonToFixtureFor(Source2Target2Mapper.class);
Source2 source = new Source2();
source.setAttributes(Arrays.asList(new Foo()));
Target2 target = Source2Target2Mapper.INSTANCE.toTarget(source);
assertThat(target).isNotNull();
assertThat(target.getAttributes().size()).isEqualTo(1);
}
use of org.mapstruct.ap.test.collection.adder._target.Target in project mapstruct by mapstruct.
the class AdderTest method testAddWithExistingTarget.
@IssueKey("241")
@ProcessorTest
public void testAddWithExistingTarget() {
AdderUsageObserver.setUsed(false);
Source source = new Source();
source.setPets(Arrays.asList("mouse"));
Target target = new Target();
target.setPets(new ArrayList<>(Arrays.asList(1L)));
SourceTargetMapper.INSTANCE.toExistingTarget(source, target);
assertThat(target).isNotNull();
assertThat(target.getPets().size()).isEqualTo(2);
assertThat(target.getPets().get(0)).isEqualTo(1L);
assertThat(target.getPets().get(1)).isEqualTo(2L);
assertTrue(AdderUsageObserver.isUsed());
}
Aggregations