Skip to content

Commit 9c857e4

Browse files
refactor: Java 17 features for tests
Use this link to re-run the recipe: https://app.moderne.io/builder/PM23vSNHB?organizationId=ODQ2MGExMTUtNDg0My00N2EwLTgzMGMtNGE1NGExMTBmZDkw Co-authored-by: Moderne <[email protected]>
1 parent 95fb827 commit 9c857e4

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

src/test/java/org/openrewrite/java/migrate/BouncyCastleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void updateBouncyCastle(String value) {
9494
mavenProject("project",
9595
//language=xml
9696
pomXml(
97-
String.format("""
97+
"""
9898
<project>
9999
<modelVersion>4.0.0</modelVersion>
100100
@@ -110,7 +110,7 @@ void updateBouncyCastle(String value) {
110110
</dependency>
111111
</dependencies>
112112
</project>
113-
""", value),
113+
""".formatted(value),
114114
spec -> spec
115115
.after(identity())
116116
.afterRecipe(doc -> assertThat(doc.getMarkers().findFirst(MavenResolutionResult.class)

src/test/java/org/openrewrite/java/migrate/jacoco/UpgradeJaCoCoTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void pluginWithProperty() {
5757
</build>
5858
</project>
5959
""",
60-
spec -> spec.after(pomXml -> String.format("""
60+
spec -> spec.after(pomXml -> """
6161
<project>
6262
<properties>
6363
<jacoco.version>%s</jacoco.version>
@@ -75,7 +75,7 @@ void pluginWithProperty() {
7575
</plugins>
7676
</build>
7777
</project>
78-
""", JACOCO_VERSION_PATTERN.matcher(pomXml).results().findFirst().get().group(1)))
78+
""".formatted(JACOCO_VERSION_PATTERN.matcher(pomXml).results().findFirst().get().group(1)))
7979
)
8080
);
8181
}
@@ -114,7 +114,7 @@ void pluginAndDepWithProperty() {
114114
</build>
115115
</project>
116116
""",
117-
spec -> spec.after(pomXml -> String.format("""
117+
spec -> spec.after(pomXml -> """
118118
<project>
119119
<properties>
120120
<jacoco.version>%s</jacoco.version>
@@ -142,7 +142,7 @@ void pluginAndDepWithProperty() {
142142
</plugins>
143143
</build>
144144
</project>
145-
""", JACOCO_VERSION_PATTERN.matcher(pomXml).results().findFirst().get().group(1))
145+
""".formatted(JACOCO_VERSION_PATTERN.matcher(pomXml).results().findFirst().get().group(1))
146146
)
147147
)
148148
);
@@ -189,7 +189,7 @@ void pluginAndDepAndDepMgmt() {
189189
</build>
190190
</project>
191191
""",
192-
spec -> spec.after(pomXml -> String.format("""
192+
spec -> spec.after(pomXml -> """
193193
<project>
194194
<groupId>com.mycompany.app</groupId>
195195
<artifactId>my-app</artifactId>
@@ -223,7 +223,7 @@ void pluginAndDepAndDepMgmt() {
223223
</plugins>
224224
</build>
225225
</project>
226-
""", versionPattern.matcher(pomXml).results().findFirst().get().group(1))
226+
""".formatted(versionPattern.matcher(pomXml).results().findFirst().get().group(1))
227227
)
228228
)
229229
);
@@ -273,7 +273,7 @@ void pluginAndDepAndDepMgmtWithProperty() {
273273
</build>
274274
</project>
275275
""",
276-
spec -> spec.after(pomXml -> String.format("""
276+
spec -> spec.after(pomXml -> """
277277
<project>
278278
<properties>
279279
<jacoco.version>%s</jacoco.version>
@@ -311,7 +311,7 @@ void pluginAndDepAndDepMgmtWithProperty() {
311311
</plugins>
312312
</build>
313313
</project>
314-
""", JACOCO_VERSION_PATTERN.matcher(pomXml).results().findFirst().get().group(1))
314+
""".formatted(JACOCO_VERSION_PATTERN.matcher(pomXml).results().findFirst().get().group(1))
315315
)
316316
)
317317
);

src/test/java/org/openrewrite/java/migrate/lang/UseTextBlocksTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,17 @@ public static void main(String[] args) {
537537
""")
538538
@Test
539539
void textBlockDemo() {
540-
String s1 = "\n=========================================================" +
541-
"\n " +
542-
"\n Welcome to Spring Integration! " +
543-
"\n " +
544-
"\n For more information please visit: " +
545-
"\n https://www.springsource.org/spring-integration " +
546-
"\n " +
547-
"\n=========================================================";
540+
String s1 = """
541+
542+
=========================================================
543+
\s
544+
Welcome to Spring Integration! \s
545+
\s
546+
For more information please visit: \s
547+
https://www.springsource.org/spring-integration \s
548+
\s
549+
=========================================================\
550+
""";
548551
String s2 = """
549552
550553
=========================================================

0 commit comments

Comments
 (0)