mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#3077 Add test case
This commit is contained in:
parent
429cc3f914
commit
50d96eb367
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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._3077;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Named;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface Issue3077Mapper {
|
||||||
|
|
||||||
|
Issue3077Mapper INSTANCE = Mappers.getMapper( Issue3077Mapper.class );
|
||||||
|
|
||||||
|
class Source {
|
||||||
|
private final String source;
|
||||||
|
private final Source self;
|
||||||
|
|
||||||
|
public Source(String source, Source self) {
|
||||||
|
this.source = source;
|
||||||
|
this.self = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Source getSelf() {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Target {
|
||||||
|
private String value;
|
||||||
|
private Target self;
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Target getSelf() {
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelf(Target self) {
|
||||||
|
this.self = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Named("self")
|
||||||
|
@Mapping(target = "value", source = "source")
|
||||||
|
@Mapping(target = "self", qualifiedByName = "self")
|
||||||
|
Target map(Source source);
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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._3077;
|
||||||
|
|
||||||
|
import org.mapstruct.ap.testutil.IssueKey;
|
||||||
|
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||||
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
@WithClasses(Issue3077Mapper.class)
|
||||||
|
@IssueKey("3057")
|
||||||
|
class Issue3077MapperTest {
|
||||||
|
|
||||||
|
@ProcessorTest
|
||||||
|
void mapsSelf() {
|
||||||
|
Issue3077Mapper.Source sourceInner = new Issue3077Mapper.Source( "inner", null );
|
||||||
|
Issue3077Mapper.Source sourceOuter = new Issue3077Mapper.Source( "outer", sourceInner );
|
||||||
|
|
||||||
|
Issue3077Mapper.Target targetOuter = Issue3077Mapper.INSTANCE.map( sourceOuter );
|
||||||
|
|
||||||
|
assertThat( targetOuter.getValue() ).isEqualTo( "outer" );
|
||||||
|
assertThat( targetOuter.getSelf().getValue() ).isEqualTo( "inner" );
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user