mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2124 Add extra test case
This commit is contained in:
parent
ef3cbc1b36
commit
bdc58b9602
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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._2124;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
public class CommitComment {
|
||||||
|
|
||||||
|
private final Integer issueId;
|
||||||
|
|
||||||
|
public CommitComment(Integer issueId) {
|
||||||
|
this.issueId = issueId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIssueId() {
|
||||||
|
return issueId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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._2124;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Named;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface Issue2124Mapper {
|
||||||
|
|
||||||
|
Issue2124Mapper INSTANCE = Mappers.getMapper( Issue2124Mapper.class );
|
||||||
|
|
||||||
|
@Mapping(target = "issueId", source = "comment.issueId", qualifiedByName = "mapped")
|
||||||
|
CommitComment clone(CommitComment comment, String otherSource);
|
||||||
|
|
||||||
|
@Named("mapped")
|
||||||
|
default Integer mapIssueNumber(int issueNumber) {
|
||||||
|
return issueNumber * 2;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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._2124;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
|
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
@IssueKey("2124")
|
||||||
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
|
@WithClasses({
|
||||||
|
CommitComment.class,
|
||||||
|
Issue2124Mapper.class
|
||||||
|
})
|
||||||
|
public class Issue2124Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldCompile() {
|
||||||
|
|
||||||
|
CommitComment clone = Issue2124Mapper.INSTANCE.clone( new CommitComment( 100 ), null );
|
||||||
|
assertThat( clone ).isNotNull();
|
||||||
|
assertThat( clone.getIssueId() ).isEqualTo( 200 );
|
||||||
|
|
||||||
|
clone = Issue2124Mapper.INSTANCE.clone( new CommitComment( null ), null );
|
||||||
|
assertThat( clone ).isNotNull();
|
||||||
|
assertThat( clone.getIssueId() ).isNull();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user