From 1a7a077df9bc54bedcb7a85b9af5d11955689be9 Mon Sep 17 00:00:00 2001 From: jcarranzan Date: Tue, 26 Nov 2024 11:20:56 +0100 Subject: [PATCH] Add test to verify correct application order of update recipes This test ensures that during the Quarkus update process, the update recipes are applied in the correct order to prevent incorrect dependency transformations. It address the issue https://github.com/quarkusio/quarkus/issues/44183 (cherry picked from commit 9fff9cc8e371800ba5d848bf4c045fcea3639a5f) --- .../cli/update/QuarkusCli35to315UpdateIT.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/update/QuarkusCli35to315UpdateIT.java diff --git a/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/update/QuarkusCli35to315UpdateIT.java b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/update/QuarkusCli35to315UpdateIT.java new file mode 100644 index 000000000..ae553a30c --- /dev/null +++ b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/update/QuarkusCli35to315UpdateIT.java @@ -0,0 +1,58 @@ +package io.quarkus.ts.quarkus.cli.update; + +import static io.quarkus.test.util.QuarkusCLIUtils.getDependencies; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.util.List; + +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.model.Dependency; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.bootstrap.QuarkusCliRestService; + +public class QuarkusCli35to315UpdateIT extends AbstractQuarkusCliUpdateIT { + private static final DefaultArtifactVersion oldVersion = new DefaultArtifactVersion("3.5"); + private static final DefaultArtifactVersion newVersion = new DefaultArtifactVersion("3.15"); + + public QuarkusCli35to315UpdateIT() { + super(oldVersion, newVersion); + } + + /** + * Test that updating from Quarkus 3.5 to 3.15 correctly transforms + * the 'quarkus-rest-client-reactive-jackson' extension to 'quarkus-rest-client-jackson', + * and does not incorrectly transform it to 'quarkus-resteasy-client-jackson'. + * This test addresses a specific issue where the update recipes could apply in the wrong order, + * causing incorrect dependency transformations. More info here:https://github.com/quarkusio/quarkus/issues/44183 + * + */ + @Tag("https://github.com/quarkusio/quarkus/issues/44183") + @Test + public void testCorrectRecipesOrder() throws XmlPullParserException, IOException { + + QuarkusCliRestService app = quarkusCLIAppManager + .createApplicationWithExtensions("quarkus-rest-client-reactive-jackson"); + + quarkusCLIAppManager.updateApp(app); + List dependencies = getDependencies(app); + assertTrue( + dependencies.stream().anyMatch(dependency -> dependency.getArtifactId().equals("quarkus-rest-client-jackson")), + "'quarkus-rest-client-jackson' should be present after the update."); + + assertFalse( + dependencies.stream() + .anyMatch(dependency -> dependency.getArtifactId().equals("quarkus-rest-client-reactive-jackson")), + "'quarkus-rest-client-reactive-jackson' should not be present after the update."); + + assertFalse( + dependencies.stream() + .anyMatch(dependency -> dependency.getArtifactId().equals("quarkus-resteasy-client-jackson")), + "'quarkus-resteasy-client-jackson' should not be present after the update."); + } + +}