Skip to content

Commit

Permalink
Add test to FindMinimumDependencyVersion finding multiple dependenc…
Browse files Browse the repository at this point in the history
…ies (#128)

* Add test to `FindMinimumDependencyVersion` finding multiple dependencies

This now works as expected since a related fix in rewrite: openrewrite/rewrite@3c314df

* Minor polish to apply best practices

---------

Co-authored-by: Tim te Beek <[email protected]>
  • Loading branch information
2 people authored and sambsnyd committed Dec 11, 2024
1 parent 8dfdea0 commit 4c300e5
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openrewrite.java.dependencies.search;

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

Expand All @@ -31,6 +32,7 @@ public void defaults(RecipeSpec spec) {
spec.recipe(new FindMinimumDependencyVersion("com.fasterxml.jackson*", "jackson-core", "2.14-2.16"));
}

@DocumentExample
@Test
void minimumMaven() {
rewriteRun(
Expand Down Expand Up @@ -163,4 +165,66 @@ void noMatchBecauseVersionIsOutsideRange() {
)
);
}

@Test
void findMultiple() {
rewriteRun(
//language=yaml
spec -> spec.recipeFromYaml("""
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.MyRecipe
description: composite recipe finding 2 versions.
recipeList:
- org.openrewrite.java.dependencies.search.FindMinimumDependencyVersion:
groupIdPattern: com.fasterxml.jackson.core
artifactIdPattern: jackson-core
version: 2.14-2.16
- org.openrewrite.java.dependencies.search.FindMinimumDependencyVersion:
groupIdPattern: commons-lang
artifactIdPattern: commons-lang
version: 2.5-2.7
""", "org.openrewrite.MyRecipe"),
//language=xml
pomXml(
"""
<project>
<groupId>org.openrewrite</groupId>
<artifactId>core</artifactId>
<version>0.1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
""",
"""
<!--~~(com.fasterxml.jackson.core:jackson-core:2.15.0)~~>--><!--~~(commons-lang:commons-lang:2.6)~~>--><project>
<groupId>org.openrewrite</groupId>
<artifactId>core</artifactId>
<version>0.1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
"""
)
);
}
}

0 comments on commit 4c300e5

Please sign in to comment.