Created
August 29, 2018 20:23
-
-
Save sjaakd/8f81545237192c6917e81c3340fb86d1 to your computer and use it in GitHub Desktop.
issue1599
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mapstruct.ap.test.bugs; | |
public class Country { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mapstruct.ap.test.bugs; | |
public class CountryDto { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mapstruct.ap.test.bugs; | |
import org.mapstruct.Mapper; | |
import org.mapstruct.Mapping; | |
import org.mapstruct.Mappings; | |
import org.mapstruct.Named; | |
import org.mapstruct.factory.Mappers; | |
@Mapper | |
public interface CountryMapper { | |
CountryMapper INSTANCE = Mappers.getMapper(CountryMapper.class); | |
@Named("toCountryDtoObject") | |
public abstract CountryDto toCountryDto(Country entity); | |
@Mappings({ | |
@Mapping(source = "pk.country", target = "country", qualifiedByName = "toCountryDtoObject") | |
}) | |
public abstract ProvinceDto toProvinceDto(Province entity); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright MapStruct Authors. | |
* | |
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | |
*/ | |
package org.mapstruct.ap.test.bugs; | |
import org.junit.Test; | |
import static org.assertj.core.api.Assertions.assertThat; | |
public class Issue1599Test { | |
@Test | |
public void shouldGenerateCorrectMapping() { | |
Country country = new Country(); | |
Province province = new Province(); | |
Province.InnerPK innerPK = new Province.InnerPK(); | |
province.setPk( innerPK ); | |
innerPK.setCountry( country ); | |
ProvinceDto target = CountryMapper.INSTANCE.toProvinceDto( province ); | |
assertThat( target ).isNotNull(); | |
assertThat( target.getCountry() ).isNotNull(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.mycompany</groupId> | |
<artifactId>MapStruct1597</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<dependencies> | |
<dependency> | |
<groupId>org.mapstruct</groupId> | |
<artifactId>mapstruct</artifactId> | |
<version>1.2.0.Final</version> | |
</dependency> | |
<dependency> | |
<groupId>org.mapstruct</groupId> | |
<artifactId>mapstruct-processor</artifactId> | |
<version>1.2.0.Final</version> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.12</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.assertj</groupId> | |
<artifactId>assertj-core</artifactId> | |
<version>3.10.0</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<pluginManagement> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.0</version> | |
<configuration> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
</plugins> | |
</pluginManagement> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mapstruct.ap.test.bugs; | |
public class Province { | |
private InnerPK pk; | |
public InnerPK getPk() { | |
return pk; | |
} | |
public void setPk(InnerPK pk) { | |
this.pk = pk; | |
} | |
public static class InnerPK { | |
private Country country; | |
public Country getCountry() { | |
return country; | |
} | |
public void setCountry(Country country) { | |
this.country = country; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mapstruct.ap.test.bugs; | |
public class ProvinceDto { | |
private CountryDto country; | |
public CountryDto getCountry() { | |
return country; | |
} | |
public void setCountry(CountryDto country) { | |
this.country = country; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment