Skip to content

Commit 59cdd58

Browse files
committed
Add unit test
1 parent a321036 commit 59cdd58

1 file changed

Lines changed: 135 additions & 31 deletions

File tree

rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactIdTest.java

Lines changed: 135 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ void changeDependencyGroupIdAndArtifactIdWithDeepHierarchy() {
12481248
"quarkus-core",
12491249
"io.quarkus",
12501250
"quarkus-arc",
1251-
null,
1251+
"2.8.3.Final",
12521252
null
12531253
)
12541254
),
@@ -1285,42 +1285,42 @@ void changeDependencyGroupIdAndArtifactIdWithDeepHierarchy() {
12851285
mavenProject("subchild",
12861286
pomXml(
12871287
"""
1288-
<project>
1289-
<parent>
1290-
<groupId>com.mycompany.app</groupId>
1291-
<artifactId>child</artifactId>
1292-
<version>1</version>
1293-
</parent>
1288+
<project>
1289+
<parent>
12941290
<groupId>com.mycompany.app</groupId>
1295-
<artifactId>subchild</artifactId>
1291+
<artifactId>child</artifactId>
12961292
<version>1</version>
1297-
<dependencies>
1298-
<dependency>
1299-
<groupId>io.quarkus</groupId>
1300-
<artifactId>quarkus-core</artifactId>
1301-
<version>2.8.0.Final</version>
1302-
</dependency>
1303-
</dependencies>
1304-
</project>
1293+
</parent>
1294+
<groupId>com.mycompany.app</groupId>
1295+
<artifactId>subchild</artifactId>
1296+
<version>1</version>
1297+
<dependencies>
1298+
<dependency>
1299+
<groupId>io.quarkus</groupId>
1300+
<artifactId>quarkus-core</artifactId>
1301+
<version>2.8.0.Final</version>
1302+
</dependency>
1303+
</dependencies>
1304+
</project>
13051305
""",
13061306
"""
1307-
<project>
1308-
<parent>
1309-
<groupId>com.mycompany.app</groupId>
1310-
<artifactId>child</artifactId>
1311-
<version>1</version>
1312-
</parent>
1307+
<project>
1308+
<parent>
13131309
<groupId>com.mycompany.app</groupId>
1314-
<artifactId>subchild</artifactId>
1310+
<artifactId>child</artifactId>
13151311
<version>1</version>
1316-
<dependencies>
1317-
<dependency>
1318-
<groupId>io.quarkus</groupId>
1319-
<artifactId>quarkus-arc</artifactId>
1320-
<version>2.8.0.Final</version>
1321-
</dependency>
1322-
</dependencies>
1323-
</project>
1312+
</parent>
1313+
<groupId>com.mycompany.app</groupId>
1314+
<artifactId>subchild</artifactId>
1315+
<version>1</version>
1316+
<dependencies>
1317+
<dependency>
1318+
<groupId>io.quarkus</groupId>
1319+
<artifactId>quarkus-arc</artifactId>
1320+
<version>2.8.3.Final</version>
1321+
</dependency>
1322+
</dependencies>
1323+
</project>
13241324
"""
13251325
)
13261326
)
@@ -1676,4 +1676,108 @@ void changeDependencyGroupIdAndArtifactIdWithVersionProperty() {
16761676
)
16771677
);
16781678
}
1679+
1680+
@Test
1681+
void changeDependencyGroupIdAndArtifactIdWithDeepHierarchydWithVersionProperty() {
1682+
rewriteRun(
1683+
spec -> spec.recipe(new ChangeDependencyGroupIdAndArtifactId(
1684+
"io.quarkus",
1685+
"quarkus-core",
1686+
"io.quarkus",
1687+
"quarkus-arc",
1688+
"2.8.3.Final",
1689+
null
1690+
)
1691+
),
1692+
pomXml(
1693+
"""
1694+
<project>
1695+
<groupId>com.mycompany.app</groupId>
1696+
<artifactId>parent</artifactId>
1697+
<version>1</version>
1698+
<modules>
1699+
<module>child</module>
1700+
</modules>
1701+
<properties>
1702+
<quarkus.version>2.8.0.Final</quarkus.version>
1703+
</properties>
1704+
</project>
1705+
""",
1706+
"""
1707+
<project>
1708+
<groupId>com.mycompany.app</groupId>
1709+
<artifactId>parent</artifactId>
1710+
<version>1</version>
1711+
<modules>
1712+
<module>child</module>
1713+
</modules>
1714+
<properties>
1715+
<quarkus.version>2.8.3.Final</quarkus.version>
1716+
</properties>
1717+
</project>
1718+
"""
1719+
),
1720+
mavenProject("child",
1721+
pomXml(
1722+
"""
1723+
<project>
1724+
<parent>
1725+
<groupId>com.mycompany.app</groupId>
1726+
<artifactId>parent</artifactId>
1727+
<version>1</version>
1728+
</parent>
1729+
<groupId>com.mycompany.app</groupId>
1730+
<artifactId>child</artifactId>
1731+
<version>1</version>
1732+
<modules>
1733+
<module>subchild</module>
1734+
</modules>
1735+
</project>
1736+
"""
1737+
),
1738+
mavenProject("subchild",
1739+
pomXml(
1740+
"""
1741+
<project>
1742+
<parent>
1743+
<groupId>com.mycompany.app</groupId>
1744+
<artifactId>child</artifactId>
1745+
<version>1</version>
1746+
</parent>
1747+
<groupId>com.mycompany.app</groupId>
1748+
<artifactId>subchild</artifactId>
1749+
<version>1</version>
1750+
<dependencies>
1751+
<dependency>
1752+
<groupId>io.quarkus</groupId>
1753+
<artifactId>quarkus-core</artifactId>
1754+
<version>${quarkus.version}</version>
1755+
</dependency>
1756+
</dependencies>
1757+
</project>
1758+
""",
1759+
"""
1760+
<project>
1761+
<parent>
1762+
<groupId>com.mycompany.app</groupId>
1763+
<artifactId>child</artifactId>
1764+
<version>1</version>
1765+
</parent>
1766+
<groupId>com.mycompany.app</groupId>
1767+
<artifactId>subchild</artifactId>
1768+
<version>1</version>
1769+
<dependencies>
1770+
<dependency>
1771+
<groupId>io.quarkus</groupId>
1772+
<artifactId>quarkus-arc</artifactId>
1773+
<version>${quarkus.version}</version>
1774+
</dependency>
1775+
</dependencies>
1776+
</project>
1777+
"""
1778+
)
1779+
)
1780+
)
1781+
);
1782+
}
16791783
}

0 commit comments

Comments
 (0)