Skip to content
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

[WINDUPRULE-910] Rule for jakarta json binding #862

Merged
merged 1 commit into from
Feb 21, 2023
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
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>