From 8bb09275797ca97868e2ed899640f5050243da0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Posto=C5=82owicz?= Date: Tue, 16 Aug 2022 16:40:07 +0200 Subject: [PATCH 1/2] DO NOT MERGE --- parent/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index 1c031a7b71..ec686bd641 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -363,8 +363,8 @@ maven-compiler-plugin 3.8.1 - 1.8 - 1.8 + 11 + 11 From 33303712e0023040c82cf4b166cccfea6e36d912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Posto=C5=82owicz?= Date: Tue, 16 Aug 2022 16:40:20 +0200 Subject: [PATCH 2/2] wip --- .../ap/test/bugs/_2937/Issue2937Mapper.java | 129 ++++++++++++++++++ .../ap/test/bugs/_2937/Issue2937Test.java | 26 ++++ 2 files changed, 155 insertions(+) create mode 100644 processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Mapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Test.java diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Mapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Mapper.java new file mode 100644 index 0000000000..c944156a9e --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Mapper.java @@ -0,0 +1,129 @@ +package org.mapstruct.ap.test.bugs._2937; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Condition; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, + collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED) +public interface Issue2937Mapper { + + PersonDTO toDTO(final Person entity); + Person toEntity(final PersonDTO dto); + + AddressDTO toDTO(final Address entity); + Address toEntity(final AddressDTO dto); + + @Condition + default boolean isConditionSatified(Collection sourceCollection) { + return false; + } + + class PersonDTO { + + private Set addresses = new HashSet(); + + public void setAddresses(Set addresses) { + this.addresses = addresses; + } + + public Set getAddresses() { + return this.addresses; + } + + public void addAddress(AddressDTO customerAddressVar) { + if (customerAddressVar != null) { + this.addresses.add(customerAddressVar); + customerAddressVar.setPerson(this); + } + } + + public void removeAddress(AddressDTO customerAddressVar) { + if (customerAddressVar != null) { + this.addresses.remove(customerAddressVar); + } + } + + } + + class Address { + + private String addressLine; + + private Person person; + + public String getAddressLine() { + return addressLine; + } + + public void setAddressLine(String addressLine) { + this.addressLine = addressLine; + } + + public void setPerson(Person person) { + this.person = person; + } + + public Person getPerson() { + return this.person; + } + + } + + class AddressDTO { + + private String addressLine; + + private PersonDTO person; + + public String getAddressLine() { + return addressLine; + } + + public void setAddressLine(String addressLine) { + this.addressLine = addressLine; + } + + public void setPerson(PersonDTO person) { + this.person = person; + } + + public PersonDTO getPerson() { + return this.person; + } + + } + + class Person { + + private Set
addresses = new HashSet
(); + + + public void setAddresses(Set
addresses) { + this.addresses = addresses; + } + + public Set
getAddresses() { + return this.addresses; + } + + public void addAddress(Address customerAddressVar) { + if (customerAddressVar != null) { + this.addresses.add(customerAddressVar); + customerAddressVar.setPerson(this); + } + } + + public void removeAddress(Address customerAddressVar) { + if (customerAddressVar != null) { + this.addresses.remove(customerAddressVar); + } + } + + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Test.java new file mode 100644 index 0000000000..7ef4a3880c --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_2937/Issue2937Test.java @@ -0,0 +1,26 @@ +package org.mapstruct.ap.test.bugs._2937; + +import org.mapstruct.ap.testutil.IssueKey; +import org.mapstruct.ap.testutil.ProcessorTest; +import org.mapstruct.ap.testutil.WithClasses; + +@WithClasses({ + Issue2937Mapper.class +}) +@IssueKey("2937") +class Issue2937Test { + + @ProcessorTest + void shouldCompile() { + } +} + + +//class Issue2891Test { +// +// @RegisterExtension +// final GeneratedSource generatedSource = new GeneratedSource() +// .addComparisonToFixtureFor( Issue2891Mapper.class ); +// +// +//} \ No newline at end of file