mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2537 Fix incorrect unmapped source property when only defined in Mapping#target
This commit is contained in:
parent
8ad55b164f
commit
c1fa9bd0bd
@ -1170,6 +1170,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
|
||||
.build();
|
||||
handledTargets.add( targetPropertyName );
|
||||
unprocessedSourceParameters.remove( sourceRef.getParameter() );
|
||||
unprocessedSourceProperties.remove( sourceRef.getShallowestPropertyName() );
|
||||
}
|
||||
else {
|
||||
errorOccured = true;
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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._2537;
|
||||
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
|
||||
/**
|
||||
* implicit source-target mapping should list the source property as being mapped.
|
||||
*
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@WithClasses( { UnmappedSourcePolicyWithImplicitSourceMapper.class } )
|
||||
@IssueKey( "2537" )
|
||||
public class ImplicitSourceTest {
|
||||
|
||||
@ProcessorTest
|
||||
public void situationCompilesWithoutErrors() {
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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._2537;
|
||||
|
||||
import org.mapstruct.BeanMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@Mapper( unmappedSourcePolicy = ReportingPolicy.ERROR )
|
||||
public interface UnmappedSourcePolicyWithImplicitSourceMapper {
|
||||
@BeanMapping( ignoreByDefault = true )
|
||||
@Mapping( target = "property" )
|
||||
Target map(Source source);
|
||||
|
||||
class Source {
|
||||
private String property;
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
}
|
||||
|
||||
class Target {
|
||||
private String property;
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user