forked from windup/windup-rulesets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WINDUPRULE-710 Divived Groovy rule in two different rules (#7)
* WINDUPRULE-708 Quarkus Release 1.11 - Jackson (windup#523) * WINDUPRULE-708 Quarkus Release 1.11 - Jackson * WINDUPRULE-708 - rename tests to be consistent with rules * WINDUPRULE-708 changed to quarkus1 target so new quarkus1 folder under rules-reviewed Co-authored-by: Phil Cattanach <pcattana@pcattana.remote.csb> * WINDUPRULE-710 Divived Groovy rule in two different rules Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com> Co-authored-by: Phil Cattanach <pcattana@pcattana.remote.csb>
- Loading branch information
1 parent
1ef7fa0
commit d58c073
Showing
9 changed files
with
313 additions
and
15 deletions.
There are no files selected for viewing
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
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
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
58 changes: 58 additions & 0 deletions
58
rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.groovy
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,58 @@ | ||
import org.jboss.windup.config.GraphRewrite | ||
import org.jboss.windup.config.metadata.TechnologyReference | ||
import org.jboss.windup.config.operation.iteration.AbstractIterationOperation | ||
import org.jboss.windup.config.query.Query | ||
import org.jboss.windup.config.query.QueryPropertyComparisonType | ||
import org.jboss.windup.graph.model.FileLocationModel | ||
import org.jboss.windup.graph.model.WindupConfigurationModel | ||
import org.jboss.windup.graph.model.resource.FileModel | ||
import org.jboss.windup.graph.service.GraphService | ||
import org.jboss.windup.graph.service.WindupConfigurationService | ||
import org.jboss.windup.reporting.category.IssueCategory | ||
import org.jboss.windup.reporting.category.IssueCategoryRegistry | ||
import org.jboss.windup.reporting.config.Hint | ||
import org.jboss.windup.reporting.config.Link | ||
import org.jboss.windup.rules.apps.java.condition.SourceMode | ||
import org.ocpsoft.rewrite.context.EvaluationContext | ||
|
||
final IssueCategory potentialIssueCategory = new IssueCategoryRegistry().getByID(IssueCategoryRegistry.POTENTIAL) | ||
|
||
ruleSet("quarkus1-11-resteasy-jackson-groovy") | ||
.addSourceTechnology(new TechnologyReference("quarkus1", "(,10]")) | ||
.addTargetTechnology(new TechnologyReference("quarkus1", "[11,)")) | ||
.addRule() | ||
.when(SourceMode.isDisabled(), | ||
Query.fromType(FileModel) | ||
.withProperty(FileModel.IS_DIRECTORY, Boolean.TRUE) | ||
.withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ".*/io/quarkus/jackson\$")) | ||
.perform(new AbstractIterationOperation<FileModel>() { | ||
void perform(GraphRewrite event, EvaluationContext context, FileModel payload) { | ||
//ensure that the dependency being searched for is present in the current application | ||
//rather than any application in the MTA project | ||
final String sourceBasePath = payload.getFilePath().replace("/io/quarkus/jackson", "") | ||
final String dependencyJarName = sourceBasePath.substring(sourceBasePath.lastIndexOf("/") + 1) | ||
WindupConfigurationModel windupConfigurationModel = WindupConfigurationService.getConfigurationModel(event.getGraphContext()) | ||
boolean packageComesFromAnalyzedApplication = false | ||
windupConfigurationModel.getInputPaths().each { | ||
if (!packageComesFromAnalyzedApplication && it.filePath.endsWith(dependencyJarName)) packageComesFromAnalyzedApplication = true | ||
} | ||
if (!packageComesFromAnalyzedApplication) return | ||
final GraphService<FileLocationModel> fileLocationService = new GraphService<>(event.getGraphContext(), FileLocationModel.class) | ||
final FileLocationModel folderLocationModel = fileLocationService.create() | ||
folderLocationModel.setFile(payload) | ||
folderLocationModel.setColumnNumber(1) | ||
folderLocationModel.setLineNumber(1) | ||
folderLocationModel.setLength(1) | ||
folderLocationModel.setSourceSnippit("Folder Match") | ||
((Hint) Hint.titled("The Jackson ObjectMapper ignores unknown properties") | ||
.withText("""The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions now ignores unknown properties | ||
(by disabling the `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` feature). | ||
Refer to the guide below for more details about how to return to the previous behaviour.""") | ||
.withIssueCategory(potentialIssueCategory) | ||
.with(Link.to("Quarkus - Writing JSON REST Services", "https://quarkus.io/guides/rest-json#jackson")) | ||
.with(Link.to("Quarkus - Migraton Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11")) | ||
.withEffort(1) | ||
).performParameterized(event, context, folderLocationModel) | ||
} | ||
}) | ||
.withId("quarkus1-11-resteasy-jackson-groovy-00000") |
42 changes: 42 additions & 0 deletions
42
rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.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,42 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="quarkus1-11-resteasy-jackson" | ||
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 gives hints for upgrading to quarkus 1.11 for applications that use Jackson | ||
</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" /> | ||
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" /> | ||
</dependencies> | ||
<!-- The major version is implied by the target, the minor is reflected in the verionRange --> | ||
<sourceTechnology id="quarkus1" versionRange="(,10]"/> | ||
<targetTechnology id="quarkus1" versionRange="[11,)"/> | ||
</metadata> | ||
<rules> | ||
<rule id="quarkus1-11-resteasy-jackson-00000"> | ||
<when> | ||
<graph-query discriminator="WindupJavaConfigurationModel" as="discard"> | ||
<property type="BOOLEAN" name="sourceMode">true</property> | ||
</graph-query> | ||
<project> | ||
<artifact groupId="io.quarkus" artifactId="quarkus-resteasy-jackson"/> | ||
</project> | ||
</when> | ||
<perform> | ||
<iteration over="default"> | ||
<hint title="The Jackson ObjectMapper ignores unknown properties" effort="1" category-id="potential"> | ||
<message> | ||
The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions now ignores unknown properties | ||
(by disabling the `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` feature). | ||
Refer to the guide below for more details about how to return to the previous behaviour. | ||
</message> | ||
<link title="Quarkus - Writing JSON REST Services" href="https://quarkus.io/guides/rest-json#jackson" /> | ||
<link title="Quarkus - Migraton Guide 1.11" href="https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11" /> | ||
</hint> | ||
</iteration> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> |
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,123 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.acme</groupId> | ||
<artifactId>rest-json-quickstart</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<properties> | ||
<quarkus-plugin.version>1.10.0.Final</quarkus-plugin.version> | ||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> | ||
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id> | ||
<quarkus.platform.version>1.10.0.Final</quarkus.platform.version> | ||
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${quarkus.platform.group-id}</groupId> | ||
<artifactId>${quarkus.platform.artifact-id}</artifactId> | ||
<version>${quarkus.platform.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-jackson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>native-image</goal> | ||
</goals> | ||
<configuration> | ||
<enableHttpUrlHandler>true</enableHttpUrlHandler> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
...reviewed/quarkus1/quarkus1-10/tests/quarkus1-11-resteasy-jackson-compiled.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,25 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="quarkus1-11-resteasy-jackson-compiled-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/test.jar</testDataPath> | ||
<sourceMode>false</sourceMode> | ||
<rulePath>../quarkus1-11-resteasy-jackson.windup.groovy</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="quarkus1-11-resteasy-jackson-groovy-00000-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions*"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[quarkus1-11-resteasy-jackson-groovy-00000-test] The Jackson ObjectMapper hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |
24 changes: 24 additions & 0 deletions
24
rules-reviewed/quarkus1/quarkus1-10/tests/quarkus1-11-resteasy-jackson.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,24 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="quarkus1-11-resteasy-jackson-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/</testDataPath> | ||
<rulePath>../quarkus1-11-resteasy-jackson.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="quarkus1-11-resteasy-jackson-00000-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions*"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[quarkus1-11-resteasy-jackson-00000] The Jackson `ObjectMapper` hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |