-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WINDUPRULE-910] Rule for jakarta json binding (#862)
(cherry picked from commit 778712e)
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
rules/rules-reviewed/eap8/eap7/jakarta-json-binding.windup.xml
This file contains 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,32 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="jakarta-json-binding" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<metadata> | ||
<description> | ||
This ruleset provides analysis of Java EE applications that need to migrate to Jakarta JSON Binding 3.0. | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final" /> | ||
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" /> | ||
</dependencies> | ||
<targetTechnology id="eap" versionRange="[8,9)" /> | ||
</metadata> | ||
<rules> | ||
<rule id="jakarta-json-binding-00010"> | ||
<when> | ||
<javaclass references="jakarta.json.bind.annotation.JsonbCreator"> | ||
<location>ANNOTATION</location> | ||
</javaclass> | ||
</when> | ||
<perform> | ||
<hint title="Types annotated with the jakarta.json.bind.annotation.JsonbCreator annotation no longer require all parameters to be present" effort="1" category-id="potential"> | ||
<message> | ||
By default, types annotated with the `jakarta.json.bind.annotation.JsonbCreator` annotation no longer require all parameters to be present in the JSON content. Default values will be used if the JSON being parsed is missing one of the parameters. | ||
The EE 8 behavior of requiring that all parameters be present in the JSON can be turned on by calling `jakarta.json.bind.JsonbConfig().withCreatorParametersRequired(true)`. | ||
</message> | ||
</hint> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> |
6 changes: 6 additions & 0 deletions
6
rules/rules-reviewed/eap8/eap7/tests/data/jakarta-json-binding/JakartaJsonBinding.java
This file contains 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,6 @@ | ||
import jakarta.json.bind.annotation.JsonbCreator; | ||
|
||
@JsonbCreator | ||
public class JakartaJsonBinding { | ||
public String value; | ||
} |
22 changes: 22 additions & 0 deletions
22
rules/rules-reviewed/eap8/eap7/tests/jakarta-json-binding.windup.test.xml
This file contains 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,22 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="jakarta-json-binding-tests" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<testDataPath>data/jakarta-json-binding</testDataPath> | ||
<rulePath>../jakarta-json-binding.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="jakarta-json-binding-00010-test"> | ||
<when> | ||
<not> | ||
<hint-exists message="By default, types annotated with the `jakarta.json.bind.annotation.JsonbCreator` annotation no longer require all parameters to be present in the JSON content. Default values will be used if the JSON being parsed is missing one of the parameters.*"/> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[jakarta-json-binding-00010] The hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |