-
-
Notifications
You must be signed in to change notification settings - Fork 1k
#3902: validate unknown properties in @Ignored #3908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
06e377b
test: add failing test for unknown property in @Ignored
znight1020 9965bcc
fix: validate unknown properties in @Ignored
znight1020 225c268
build: exclude issue #3902 from full feature test of integration test
znight1020 6899c04
refactor: improve error message for unknown property in @Ignored
znight1020 192a17a
refactor: rename issue mapper
znight1020 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
processor/src/test/java/org/mapstruct/ap/test/bugs/_3902/ErroneousIssue3902Mapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * 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._3902; | ||
|
|
||
| import org.mapstruct.Ignored; | ||
| import org.mapstruct.Mapper; | ||
| import org.mapstruct.factory.Mappers; | ||
|
|
||
| /** | ||
| * Mapper for testing bug #3902. | ||
| * | ||
| * @author znight1020 | ||
| */ | ||
| @Mapper | ||
| public interface ErroneousIssue3902Mapper { | ||
|
|
||
| ErroneousIssue3902Mapper INSTANCE = Mappers.getMapper( ErroneousIssue3902Mapper.class ); | ||
|
|
||
| @Ignored(targets = {"name", "foo", "bar"}) | ||
| ZooDto mapWithOneKnownAndMultipleUnknowns(Zoo source); | ||
|
|
||
| @Ignored(targets = {"name", "address", "foo"}) | ||
| ZooDto mapWithMultipleKnownAndOneUnknown(Zoo source); | ||
|
|
||
| class Zoo { | ||
| private String name; | ||
| private String address; | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getAddress() { | ||
| return address; | ||
| } | ||
|
|
||
| public void setAddress(String address) { | ||
| this.address = address; | ||
| } | ||
| } | ||
|
|
||
| class ZooDto { | ||
| private String name; | ||
| private String address; | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getAddress() { | ||
| return address; | ||
| } | ||
|
|
||
| public void setAddress(String address) { | ||
| this.address = address; | ||
| } | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
processor/src/test/java/org/mapstruct/ap/test/bugs/_3902/Issue3902Test.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * 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._3902; | ||
|
|
||
| import org.mapstruct.ap.testutil.IssueKey; | ||
| import org.mapstruct.ap.testutil.ProcessorTest; | ||
| import org.mapstruct.ap.testutil.WithClasses; | ||
| import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; | ||
| import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; | ||
| import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; | ||
|
|
||
| /** | ||
| * Verifies that using an unknown property in {@code @Ignored} yields a proper | ||
| * compile error instead of an internal processor error. | ||
| * | ||
| * @author znight1020 | ||
| */ | ||
| @WithClasses({ErroneousIssue3902Mapper.class}) | ||
| @IssueKey("3902") | ||
| public class Issue3902Test { | ||
|
|
||
| @ProcessorTest | ||
| @ExpectedCompilationOutcome( | ||
| value = CompilationResult.FAILED, | ||
| diagnostics = { | ||
| // Test case: mapWithOneKnownAndMultipleUnknowns | ||
| @Diagnostic( | ||
| type = ErroneousIssue3902Mapper.class, | ||
| kind = javax.tools.Diagnostic.Kind.ERROR, | ||
| line = 23, | ||
| message = "No property named \"foo\" exists in @Ignored for target type " + | ||
| "\"ErroneousIssue3902Mapper.ZooDto\"" | ||
| ), | ||
| @Diagnostic( | ||
| type = ErroneousIssue3902Mapper.class, | ||
| kind = javax.tools.Diagnostic.Kind.ERROR, | ||
| line = 23, | ||
| message = "No property named \"bar\" exists in @Ignored for target type " + | ||
| "\"ErroneousIssue3902Mapper.ZooDto\"" | ||
| ), | ||
|
|
||
| // Test case: mapWithMultipleKnownAndOneUnknown | ||
| @Diagnostic( | ||
| type = ErroneousIssue3902Mapper.class, | ||
| kind = javax.tools.Diagnostic.Kind.ERROR, | ||
| line = 26, | ||
| message = "No property named \"foo\" exists in @Ignored for target type " + | ||
| "\"ErroneousIssue3902Mapper.ZooDto\"" | ||
| ) | ||
| } | ||
| ) | ||
| public void shouldFailOnUnknownPropertiesInIgnored() { | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we removed the
mostSimilarPropertyfrom this error message?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, my main focus was on fixing the NullPointerException and ensuring a clear, specific error message for
@Ignoredwas reported. I completely overlooked adding the "Did you mean" suggestion, my apologies for that.Adding it would be much more consistent with the other 'Unknown property' errors. Should I create a new PR for this enhancement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if you could create another PR and add that as well