mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1648 Source properties defined in Mapping should not be reported as unmapped
This commit is contained in:
parent
b651ad34b5
commit
a3ba57c372
@ -486,6 +486,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
|
||||
.nullValuePropertyMappingStrategy( mapping.getNullValuePropertyMappingStrategy() )
|
||||
.build();
|
||||
handledTargets.add( propertyName );
|
||||
unprocessedSourceProperties.remove( mapping.getSourceName() );
|
||||
unprocessedSourceParameters.remove( sourceRef.getParameter() );
|
||||
}
|
||||
else {
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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._1648;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
@Mapper(unmappedSourcePolicy = ReportingPolicy.ERROR)
|
||||
public interface Issue1648Mapper {
|
||||
|
||||
Issue1648Mapper INSTANCE = Mappers.getMapper( Issue1648Mapper.class );
|
||||
|
||||
@Mapping(target = "targetValue", source = "sourceValue")
|
||||
Target map(Source source);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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._1648;
|
||||
|
||||
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("1648")
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
@WithClasses({
|
||||
Issue1648Mapper.class,
|
||||
Source.class,
|
||||
Target.class,
|
||||
})
|
||||
public class Issue1648Test {
|
||||
|
||||
@Test
|
||||
public void shouldCorrectlyMarkSourceAsUsed() {
|
||||
Source source = new Source();
|
||||
source.setSourceValue( "value" );
|
||||
|
||||
Target target = Issue1648Mapper.INSTANCE.map( source );
|
||||
|
||||
assertThat( target.getTargetValue() ).isEqualTo( "value" );
|
||||
}
|
||||
}
|
@ -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._1648;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
public class Source {
|
||||
|
||||
private String sourceValue;
|
||||
|
||||
public String getSourceValue() {
|
||||
return sourceValue;
|
||||
}
|
||||
|
||||
public void setSourceValue(String sourceValue) {
|
||||
this.sourceValue = sourceValue;
|
||||
}
|
||||
}
|
@ -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._1648;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
public class Target {
|
||||
|
||||
private String targetValue;
|
||||
|
||||
public String getTargetValue() {
|
||||
return targetValue;
|
||||
}
|
||||
|
||||
public void setTargetValue(String targetValue) {
|
||||
this.targetValue = targetValue;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user