Skip to content

Commit

Permalink
WINDUPRULE-710 Divived Groovy rule in two different rules (#7)
Browse files Browse the repository at this point in the history
* 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
3 people committed Feb 4, 2021
1 parent 1ef7fa0 commit d58c073
Show file tree
Hide file tree
Showing 9 changed files with 313 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ ruleSet("quarkus1-11-hibernate-elasticsearch-compiled-groovy")
.addTargetTechnology(new TechnologyReference("quarkus", "[11,)"))
.addRule()
.when(SourceMode.isDisabled(),
Or.any(
Query.fromType(FileModel)
.withProperty(FileModel.IS_DIRECTORY, Boolean.TRUE)
.withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ".*/io/quarkus/hibernate/search/orm/elasticsearch\$"),
FileContent.matches("quarkus.hibernate-search-orm.elasticsearch.version").inFileNamed("application.properties")
)
)
Query.fromType(FileModel)
.withProperty(FileModel.IS_DIRECTORY, Boolean.TRUE)
.withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ".*/io/quarkus/hibernate/search/orm/elasticsearch\$")
)
.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
Expand All @@ -52,15 +49,44 @@ ruleSet("quarkus1-11-hibernate-elasticsearch-compiled-groovy")
folderLocationModel.setLength(1)
folderLocationModel.setSourceSnippit("Folder Match")
((Hint) Hint.titled("The default required status for Elasticsearch indexes is now yellow")
.withText("""The default required status for Elasticsearch indexes is now yellow.
If you have specific requirements and need to wait for indexes to be green on startup,
set quarkus.hibernate-search.elasticsearch.schema-management.required-status to green.
.withText("""The default required status for Elasticsearch indexes is now `yellow`.
If you have specific requirements and need to wait for indexes to be `green` on startup,
set `quarkus.hibernate-search.elasticsearch.schema-management.required-status` to `green`.
Refer to the guide below for more details about how to return to the previous behaviour.""")
.withIssueCategory(potentialIssueCategory)
.with(Link.to("Quarkus - Hibernate Search Guide", "https://quarkus.io/guides/hibernate-search-orm-elasticsearch"))
.with(Link.to("Quarkus - Migraton Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11"))
.with(Link.to("Quarkus - Migration Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11"))
.withEffort(1)
).performParameterized(event, context, folderLocationModel)
}
})
.withId("quarkus1-11-hibernate-elasticsearch-compiled-groovy-00000")
.addRule()
.when(SourceMode.isDisabled(),
FileContent.matches("quarkus.hibernate-search-orm.elasticsearch.version").inFileNamed("application.properties")
)
.perform(new AbstractIterationOperation<FileLocationModel>() {
void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) {
// ensure that the application.properties being searched for is present
// in the current application rather than any application in the MTA project
final String sourceBasePath = payload.getFile().getFilePath().replace("application.properties", "")
final String dependencyJarName = sourceBasePath.substring(sourceBasePath.lastIndexOf("/") + 1)
WindupConfigurationModel windupConfigurationModel = WindupConfigurationService.getConfigurationModel(event.getGraphContext())
boolean propertiesFileComesFromAnalyzedApplication = false
windupConfigurationModel.getInputPaths().each {
if (!propertiesFileComesFromAnalyzedApplication && it.filePath.endsWith(dependencyJarName)) propertiesFileComesFromAnalyzedApplication = true
}
if (!propertiesFileComesFromAnalyzedApplication) return
((Hint) Hint.titled("The default required status for Elasticsearch indexes is now yellow")
.withText("""The default required status for Elasticsearch indexes is now `yellow`.
If you have specific requirements and need to wait for indexes to be `green` on startup,
set `quarkus.hibernate-search.elasticsearch.schema-management.required-status` to `green`.
Refer to the guide below for more details about how to return to the previous behaviour.""")
.withIssueCategory(potentialIssueCategory)
.with(Link.to("Quarkus - Hibernate Search Guide", "https://quarkus.io/guides/hibernate-search-orm-elasticsearch"))
.with(Link.to("Quarkus - Migration Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11"))
.withEffort(1)
).performParameterized(event, context, payload)
}
})
.withId("quarkus1-11-hibernate-elasticsearch-compiled-groovy-00010")
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
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/hibernate-elasticsearch/testProperties.jar</testDataPath>
<sourceMode>true</sourceMode>
<sourceMode>false</sourceMode>
<rulePath>../quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy</rulePath>
<ruleset>
<rules>
<rule id="quarkus1-11-hibernate-elasticsearch-compiled-properties-groovy-00000-test">
<rule id="quarkus1-11-hibernate-elasticsearch-compiled-properties-groovy-00010-test">
<when>
<not>
<iterable-filter size="1">
<hint-exists message="The default required status for Elasticsearch indexes is now yellow"/>
<hint-exists message="The default required status for Elasticsearch indexes is now `yellow`"/>
</iterable-filter>
</not>
</when>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<when>
<not>
<iterable-filter size="1">
<hint-exists message="The default required status for Elasticsearch indexes is now yellow"/>
<hint-exists message="The default required status for Elasticsearch indexes is now `yellow`"/>
</iterable-filter>
</not>
</when>
Expand Down
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")
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>
123 changes: 123 additions & 0 deletions rules-reviewed/quarkus1/quarkus1-10/tests/data/pom.xml
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.
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>
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>

0 comments on commit d58c073

Please sign in to comment.