#2537 Fix incorrect unmapped source property when only defined in Mapping#target

This commit is contained in:
Zegveld 2021-08-14 08:37:20 +02:00 committed by GitHub
parent 8ad55b164f
commit c1fa9bd0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 0 deletions

View File

@ -1170,6 +1170,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
.build();
handledTargets.add( targetPropertyName );
unprocessedSourceParameters.remove( sourceRef.getParameter() );
unprocessedSourceProperties.remove( sourceRef.getShallowestPropertyName() );
}
else {
errorOccured = true;

View File

@ -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() {
}
}

View File

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