|
| 1 | +/* |
| 2 | + * Copyright 2022 the original author or authors. |
| 3 | + * <p> |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * <p> |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + package org.openrewrite.java.migrate.wro4j; |
| 17 | + |
| 18 | +import org.assertj.core.api.Assertions.assertThat |
| 19 | +import org.junit.jupiter.api.Test |
| 20 | +import org.openrewrite.Recipe |
| 21 | +import org.openrewrite.config.Environment |
| 22 | +import org.openrewrite.maven.MavenRecipeTest |
| 23 | + |
| 24 | +class UpgradeJaCoCoMavenPluginVersionTest : MavenRecipeTest { |
| 25 | + override val recipe: Recipe = Environment.builder() |
| 26 | + .scanRuntimeClasspath("org.openrewrite.java.migrate.jacoco") |
| 27 | + .build() |
| 28 | + .activateRecipes("org.openrewrite.java.migrate.jacoco.UpgradeJaCoCoMavenPluginVersion") |
| 29 | + |
| 30 | + @Test |
| 31 | + fun property() = assertChanged( |
| 32 | + before = """ |
| 33 | + <project> |
| 34 | + <modelVersion>4.0.0</modelVersion> |
| 35 | + |
| 36 | + <properties> |
| 37 | + <jacoco.version>0.8.1</jacoco.version> |
| 38 | + </properties> |
| 39 | + |
| 40 | + <groupId>com.mycompany.app</groupId> |
| 41 | + <artifactId>my-app</artifactId> |
| 42 | + <version>1</version> |
| 43 | + <build> |
| 44 | + <plugins> |
| 45 | + <plugin> |
| 46 | + <groupId>org.jacoco</groupId> |
| 47 | + <artifactId>jacoco-maven-plugin</artifactId> |
| 48 | + <version>${jacoco.version}</version> |
| 49 | + <executions> |
| 50 | + <execution> |
| 51 | + <goals> |
| 52 | + <goal>prepare-agent</goal> |
| 53 | + </goals> |
| 54 | + </execution> |
| 55 | + <execution> |
| 56 | + <id>report</id> |
| 57 | + <phase>prepare-package</phase> |
| 58 | + <goals> |
| 59 | + <goal>report</goal> |
| 60 | + </goals> |
| 61 | + </execution> |
| 62 | + </executions> |
| 63 | + </plugin> |
| 64 | + </plugins> |
| 65 | + </build> |
| 66 | + </project> |
| 67 | + """, |
| 68 | + after = """ |
| 69 | + <project> |
| 70 | + <modelVersion>4.0.0</modelVersion> |
| 71 | + |
| 72 | + <properties> |
| 73 | + <jacoco.version>0.8.7</jacoco.version> |
| 74 | + </properties> |
| 75 | + |
| 76 | + <groupId>com.mycompany.app</groupId> |
| 77 | + <artifactId>my-app</artifactId> |
| 78 | + <version>1</version> |
| 79 | + <build> |
| 80 | + <plugins> |
| 81 | + <plugin> |
| 82 | + <groupId>org.jacoco</groupId> |
| 83 | + <artifactId>jacoco-maven-plugin</artifactId> |
| 84 | + <version>${jacoco.version}</version> |
| 85 | + <executions> |
| 86 | + <execution> |
| 87 | + <goals> |
| 88 | + <goal>prepare-agent</goal> |
| 89 | + </goals> |
| 90 | + </execution> |
| 91 | + <execution> |
| 92 | + <id>report</id> |
| 93 | + <phase>prepare-package</phase> |
| 94 | + <goals> |
| 95 | + <goal>report</goal> |
| 96 | + </goals> |
| 97 | + </execution> |
| 98 | + </executions> |
| 99 | + </plugin> |
| 100 | + </plugins> |
| 101 | + </build> |
| 102 | + </project> |
| 103 | + """ |
| 104 | + ) |
| 105 | +} |
0 commit comments