#3077 Add test case

This commit is contained in:
Filip Hrisafov 2022-11-12 10:04:03 +01:00
parent 429cc3f914
commit 50d96eb367
2 changed files with 96 additions and 0 deletions

View File

@ -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);
}

View File

@ -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" );
}
}