Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEXT_RELEASE_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### Enhancements

* Breaking change:g (#3574) -
This reverts #2560, because we've decided that `@BeanMapping(ignoreByDefault = true)` should only be applied to target properties and not to source properties.
Source properties are ignored anyway, the `BeanMapping#unmappedSourcePolicy` should be used to control what should happen with unmapped source policy

### Bugs

### Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1764,10 +1764,6 @@ private ReportingPolicyGem getUnmappedSourcePolicy() {
if ( mappingReferences.isForForgedMethods() ) {
return ReportingPolicyGem.IGNORE;
}
// If we have ignoreByDefault = true, unprocessed source properties are not an issue.
if ( method.getOptions().getBeanMapping().isignoreByDefault() ) {
return ReportingPolicyGem.IGNORE;
}
return method.getOptions().getBeanMapping().unmappedSourcePolicy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
@Mapper(
unmappedTargetPolicy = ReportingPolicy.IGNORE,
unmappedSourcePolicy = ReportingPolicy.ERROR)
public interface SourceTargetMapper {
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
public interface ErroneousSourceTargetMapperWithIgnoreByDefault {
ErroneousSourceTargetMapperWithIgnoreByDefault INSTANCE = Mappers.getMapper(
ErroneousSourceTargetMapperWithIgnoreByDefault.class );

@Mapping(source = "one", target = "one")
@BeanMapping(ignoreByDefault = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@
public class IgnoreByDefaultSourcesTest {

@ProcessorTest
@WithClasses({ SourceTargetMapper.class, Source.class, Target.class })
public void shouldSucceed() {
@WithClasses({ ErroneousSourceTargetMapperWithIgnoreByDefault.class, Source.class, Target.class })
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = ErroneousSourceTargetMapperWithIgnoreByDefault.class,
kind = Kind.ERROR,
line = 23,
message = "Unmapped source property: \"other\".")
}
)
public void shouldRaiseErrorDueToNonIgnoredSourcePropertyWithBeanMappingIgnoreByDefault() {
}

@ProcessorTest
Expand Down