Created
August 29, 2018 19:52
-
-
Save sjaakd/62355bd8c9be2ad98cb1678413f9d22f to your computer and use it in GitHub Desktop.
1599
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>MapStruct1599</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 User { | |
private boolean extraData; | |
public boolean isExtraData() { | |
return extraData; | |
} | |
public void setExtraData(boolean extraData) { | |
this.extraData = extraData; | |
} | |
} |
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 UserDto { | |
private boolean standardData; | |
public boolean isStandardData() { | |
return standardData; | |
} | |
public void setStandardData(boolean standardData) { | |
this.standardData = standardData; | |
} | |
} |
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 java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import org.mapstruct.Mapper; | |
import org.mapstruct.Mapping; | |
import org.mapstruct.Mappings; | |
import org.mapstruct.Qualifier; | |
import org.mapstruct.factory.Mappers; | |
@Mapper() | |
public interface UserMapper { | |
UserMapper INSTANCE = Mappers.getMapper( UserMapper.class ); | |
@Mappings({ | |
@Mapping(source = "extraData", target = "standardData", qualifiedBy = Reverse.class), | |
}) | |
abstract UserDto map(User user); | |
@Qualifier | |
@Target(ElementType.METHOD) | |
@Retention(RetentionPolicy.SOURCE) | |
@interface Reverse { } | |
@Reverse | |
default boolean reverse(boolean input) { | |
return !input; | |
} | |
} |
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() { | |
User user = new User(); | |
user.setExtraData( false ); | |
UserDto target = UserMapper.INSTANCE.map( user ); | |
assertThat( target ).isNotNull(); | |
assertThat( target.isStandardData() ).isTrue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment