|
| 1 | +package io.jenkins.tools.pluginmodernizer.core.recipes; |
| 2 | + |
| 3 | +import static org.openrewrite.maven.Assertions.pomXml; |
| 4 | + |
| 5 | +import org.junit.jupiter.api.Test; |
| 6 | +import org.openrewrite.test.RecipeSpec; |
| 7 | +import org.openrewrite.test.RewriteTest; |
| 8 | + |
| 9 | +public class IsUsingBomTest implements RewriteTest { |
| 10 | + |
| 11 | + @Override |
| 12 | + public void defaults(RecipeSpec spec) { |
| 13 | + spec.recipe(new IsUsingBom()); |
| 14 | + } |
| 15 | + |
| 16 | + @Test |
| 17 | + void testNotUsingBom() throws Exception { |
| 18 | + rewriteRun( |
| 19 | + pomXml( |
| 20 | + """ |
| 21 | + <?xml version="1.0" encoding="UTF-8"?> |
| 22 | + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 23 | + <modelVersion>4.0.0</modelVersion> |
| 24 | + <parent> |
| 25 | + <groupId>org.jenkins-ci.plugins</groupId> |
| 26 | + <artifactId>plugin</artifactId> |
| 27 | + <version>4.88</version> |
| 28 | + <relativePath /> |
| 29 | + </parent> |
| 30 | + <groupId>io.jenkins.plugins</groupId> |
| 31 | + <artifactId>empty</artifactId> |
| 32 | + <version>1.0.0-SNAPSHOT</version> |
| 33 | + <packaging>hpi</packaging> |
| 34 | + <name>Empty Plugin</name> |
| 35 | + </project> |
| 36 | + """)); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void testWithBom() throws Exception { |
| 41 | + rewriteRun( |
| 42 | + pomXml( |
| 43 | + """ |
| 44 | + <?xml version="1.0" encoding="UTF-8"?> |
| 45 | + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 46 | + <modelVersion>4.0.0</modelVersion> |
| 47 | + <parent> |
| 48 | + <groupId>org.jenkins-ci.plugins</groupId> |
| 49 | + <artifactId>plugin</artifactId> |
| 50 | + <version>4.88</version> |
| 51 | + <relativePath /> |
| 52 | + </parent> |
| 53 | + <groupId>io.jenkins.plugins</groupId> |
| 54 | + <artifactId>empty</artifactId> |
| 55 | + <version>1.0.0-SNAPSHOT</version> |
| 56 | + <packaging>hpi</packaging> |
| 57 | + <name>Empty Plugin</name> |
| 58 | + <dependencyManagement> |
| 59 | + <dependencies> |
| 60 | + <dependency> |
| 61 | + <groupId>io.jenkins.tools.bom</groupId> |
| 62 | + <artifactId>bom-2.452.x</artifactId> |
| 63 | + <version>3814.v9563d972079a_</version> |
| 64 | + <type>pom</type> |
| 65 | + <scope>import</scope> |
| 66 | + </dependency> |
| 67 | + </dependencies> |
| 68 | + </dependencyManagement> |
| 69 | + </project> |
| 70 | + """, |
| 71 | + """ |
| 72 | + <!--~~(Project is using Jenkins bom)~~>--><?xml version="1.0" encoding="UTF-8"?> |
| 73 | + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 74 | + <modelVersion>4.0.0</modelVersion> |
| 75 | + <parent> |
| 76 | + <groupId>org.jenkins-ci.plugins</groupId> |
| 77 | + <artifactId>plugin</artifactId> |
| 78 | + <version>4.88</version> |
| 79 | + <relativePath /> |
| 80 | + </parent> |
| 81 | + <groupId>io.jenkins.plugins</groupId> |
| 82 | + <artifactId>empty</artifactId> |
| 83 | + <version>1.0.0-SNAPSHOT</version> |
| 84 | + <packaging>hpi</packaging> |
| 85 | + <name>Empty Plugin</name> |
| 86 | + <dependencyManagement> |
| 87 | + <dependencies> |
| 88 | + <dependency> |
| 89 | + <groupId>io.jenkins.tools.bom</groupId> |
| 90 | + <artifactId>bom-2.452.x</artifactId> |
| 91 | + <version>3814.v9563d972079a_</version> |
| 92 | + <type>pom</type> |
| 93 | + <scope>import</scope> |
| 94 | + </dependency> |
| 95 | + </dependencies> |
| 96 | + </dependencyManagement> |
| 97 | + </project> |
| 98 | + """)); |
| 99 | + } |
| 100 | +} |
0 commit comments