Skip to content

Commit

Permalink
[WINDUPRULE-910] Rule for jakarta json binding (#862) (#873)
Browse files Browse the repository at this point in the history
(cherry picked from commit 778712e)

Co-authored-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
  • Loading branch information
github-actions[bot] and jmle committed Feb 23, 2023
1 parent 3199bc6 commit 45802f3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
32 changes: 32 additions & 0 deletions rules/rules-reviewed/eap8/eap7/jakarta-json-binding.windup.xml
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>
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;
}
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>

0 comments on commit 45802f3

Please sign in to comment.