Skip to content

Commit 581cb0f

Browse files
committed
Finish moving JavaParserBuilder.classpath() to JavaParserBuilder.classpathFromResources()
1 parent 328e0b1 commit 581cb0f

File tree

61 files changed

+296
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+296
-214
lines changed

build.gradle.kts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ description = "A rewrite module automating best practices and major version migr
1212
recipeDependencies {
1313
parserClasspath("org.assertj:assertj-core:3.+")
1414
parserClasspath("junit:junit:latest.release")
15+
parserClasspath("pl.pragmatists:JUnitParams:1.+")
1516
parserClasspath("org.junit.platform:junit-platform-suite-api:latest.release")
1617
parserClasspath("org.junit.jupiter:junit-jupiter-api:latest.release")
1718
parserClasspath("org.junit.jupiter:junit-jupiter-params:latest.release")
@@ -42,21 +43,4 @@ dependencies {
4243

4344
testImplementation("org.openrewrite:rewrite-java-17:$rewriteVersion")
4445
testImplementation("org.openrewrite:rewrite-groovy:$rewriteVersion")
45-
testRuntimeOnly("com.github.tomakehurst:wiremock-jre8:latest.release")
46-
47-
// "Before" framework dependencies
48-
testRuntimeOnly("junit:junit:latest.release")
49-
testRuntimeOnly("org.springframework:spring-test:4.+")
50-
testRuntimeOnly("pl.pragmatists:JUnitParams:1.+")
51-
testRuntimeOnly("com.squareup.okhttp3:mockwebserver:3.+")
52-
testRuntimeOnly("org.testng:testng:6.8")
53-
testRuntimeOnly("io.cucumber:cucumber-java8:7.+")
54-
testRuntimeOnly("io.cucumber:cucumber-java:7.+")
55-
testRuntimeOnly("io.cucumber:cucumber-plugin:7.+")
56-
testRuntimeOnly("io.cucumber:cucumber-junit-platform-engine:7.+")
57-
testRuntimeOnly("org.junit.platform:junit-platform-suite-api:latest.release")
58-
testRuntimeOnly("ch.qos.logback:logback-classic:latest.release")
59-
testRuntimeOnly("com.squareup.okhttp3:mockwebserver:3.14.9")
60-
testRuntimeOnly("org.powermock:powermock-api-mockito:1.7.+")
61-
testRuntimeOnly("org.mockito:mockito-core:3.+")
6246
}

src/main/java/org/openrewrite/java/testing/assertj/JUnitAssertEqualsToAssertThat.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ public String getDisplayName() {
3939
return "JUnit `assertEquals` to AssertJ";
4040
}
4141

42-
@Override
43-
public Duration getEstimatedEffortPerOccurrence() {
44-
return Duration.ofMinutes(5);
45-
}
46-
4742
@Override
4843
public String getDescription() {
4944
return "Convert JUnit-style `assertEquals()` to AssertJ's `assertThat().isEqualTo()`.";

src/main/java/org/openrewrite/java/testing/assertj/JUnitFailToAssertJFail.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
126126
}
127127

128128
private static class UnqualifiedMethodInvocations extends JavaIsoVisitor<ExecutionContext> {
129-
private final Supplier<JavaParser> ASSERTJ_JAVA_PARSER = () -> JavaParser.fromJavaVersion().classpath("assertj-core").build();
130129
private static final MethodMatcher ASSERTJ_FAIL_MATCHER = new MethodMatcher("org.assertj.core.api.Assertions" + " fail(..)");
131130

132131
@Override
@@ -147,7 +146,9 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
147146

148147
method = method.withTemplate(JavaTemplate.builder(this::getCursor, templateBuilder.toString())
149148
.staticImports("org.assertj.core.api.Assertions" + ".fail")
150-
.javaParser(ASSERTJ_JAVA_PARSER)
149+
.javaParser(() -> JavaParser.fromJavaVersion()
150+
.classpathFromResources(executionContext, "assertj-core-3.24.2")
151+
.build())
151152
.build(),
152153
method.getCoordinates().replace(),
153154
arguments.toArray()
Binary file not shown.

src/main/resources/META-INF/rewrite/classpath/cucumber-java-7.11.0.jar renamed to src/main/resources/META-INF/rewrite/classpath/cucumber-java-7.11.1.jar

712 KB
Binary file not shown.

src/main/resources/META-INF/rewrite/classpath/cucumber-java8-7.11.0.jar renamed to src/main/resources/META-INF/rewrite/classpath/cucumber-java8-7.11.1.jar

212 KB
Binary file not shown.

src/main/resources/META-INF/rewrite/classpath/cucumber-junit-platform-engine-7.11.0.jar renamed to src/main/resources/META-INF/rewrite/classpath/cucumber-junit-platform-engine-7.11.1.jar

49.7 KB
Binary file not shown.

src/main/resources/META-INF/rewrite/classpath/cucumber-plugin-7.11.0.jar renamed to src/main/resources/META-INF/rewrite/classpath/cucumber-plugin-7.11.1.jar

32.3 KB
Binary file not shown.

src/test/java/org/openrewrite/java/testing/assertj/JUnitAssertArrayEqualsToAssertThatTest.java

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.openrewrite.java.testing.assertj;
1717

1818
import org.junit.jupiter.api.Test;
19+
import org.openrewrite.InMemoryExecutionContext;
1920
import org.openrewrite.java.JavaParser;
2021
import org.openrewrite.test.RecipeSpec;
2122
import org.openrewrite.test.RewriteTest;
@@ -29,7 +30,8 @@ class JUnitAssertArrayEqualsToAssertThatTest implements RewriteTest {
2930
@Override
3031
public void defaults(RecipeSpec spec) {
3132
spec
32-
.parser(JavaParser.fromJavaVersion().classpath("junit"))
33+
.parser(JavaParser.fromJavaVersion()
34+
.classpathFromResources(new InMemoryExecutionContext(), "junit-jupiter-api-5.9.+"))
3335
.recipe(new JUnitAssertArrayEqualsToAssertThat());
3436
}
3537

@@ -39,7 +41,7 @@ void singleStaticMethodNoMessage() {
3941
rewriteRun(
4042
java(
4143
"""
42-
import org.junit.Test;
44+
import org.junit.jupiter.api.Test;
4345
4446
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4547
@@ -56,7 +58,7 @@ private Integer[] notification() {
5658
}
5759
""",
5860
"""
59-
import org.junit.Test;
61+
import org.junit.jupiter.api.Test;
6062
6163
import static org.assertj.core.api.Assertions.assertThat;
6264
@@ -83,7 +85,7 @@ void singleStaticMethodWithMessageLambda() {
8385
spec -> spec.typeValidationOptions(TypeValidation.none()),
8486
java(
8587
"""
86-
import org.junit.Test;
88+
import org.junit.jupiter.api.Test;
8789
8890
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
8991
@@ -98,7 +100,7 @@ private int[] notification() {
98100
}
99101
""",
100102
"""
101-
import org.junit.Test;
103+
import org.junit.jupiter.api.Test;
102104
103105
import static org.assertj.core.api.Assertions.assertThat;
104106
@@ -122,7 +124,7 @@ void doublesWithinNoMessage() {
122124
rewriteRun(
123125
java(
124126
"""
125-
import org.junit.Test;
127+
import org.junit.jupiter.api.Test;
126128
127129
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
128130
@@ -138,7 +140,7 @@ private double[] notification() {
138140
}
139141
""",
140142
"""
141-
import org.junit.Test;
143+
import org.junit.jupiter.api.Test;
142144
143145
import static org.assertj.core.api.Assertions.assertThat;
144146
import static org.assertj.core.api.Assertions.within;
@@ -165,7 +167,7 @@ void doublesWithinAndWithMessage() {
165167
spec -> spec.typeValidationOptions(TypeValidation.none()),
166168
java(
167169
"""
168-
import org.junit.Test;
170+
import org.junit.jupiter.api.Test;
169171
170172
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
171173
@@ -180,7 +182,7 @@ private double[] notification() {
180182
}
181183
""",
182184
"""
183-
import org.junit.Test;
185+
import org.junit.jupiter.api.Test;
184186
185187
import static org.assertj.core.api.Assertions.assertThat;
186188
import static org.assertj.core.api.Assertions.within;
@@ -206,7 +208,7 @@ void doublesObjectsWithMessage() {
206208
spec -> spec.typeValidationOptions(TypeValidation.none()),
207209
java(
208210
"""
209-
import org.junit.Test;
211+
import org.junit.jupiter.api.Test;
210212
211213
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
212214
@@ -221,7 +223,7 @@ private Double[] notification() {
221223
}
222224
""",
223225
"""
224-
import org.junit.Test;
226+
import org.junit.jupiter.api.Test;
225227
226228
import static org.assertj.core.api.Assertions.assertThat;
227229
@@ -245,10 +247,10 @@ void floatCloseToWithNoMessage() {
245247
rewriteRun(
246248
java(
247249
"""
248-
import org.junit.Test;
249-
250+
import org.junit.jupiter.api.Test;
251+
250252
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
251-
253+
252254
public class MyTest {
253255
@Test
254256
public void test() {
@@ -260,11 +262,11 @@ private float[] notification() {
260262
}
261263
""",
262264
"""
263-
import org.junit.Test;
264-
265+
import org.junit.jupiter.api.Test;
266+
265267
import static org.assertj.core.api.Assertions.assertThat;
266268
import static org.assertj.core.api.Assertions.within;
267-
269+
268270
public class MyTest {
269271
@Test
270272
public void test() {
@@ -286,7 +288,7 @@ void floatCloseToWithMessage() {
286288
spec -> spec.typeValidationOptions(TypeValidation.none()),
287289
java(
288290
"""
289-
import org.junit.Test;
291+
import org.junit.jupiter.api.Test;
290292
291293
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
292294
@@ -301,7 +303,7 @@ private float[] notification() {
301303
}
302304
""",
303305
"""
304-
import org.junit.Test;
306+
import org.junit.jupiter.api.Test;
305307
306308
import static org.assertj.core.api.Assertions.assertThat;
307309
import static org.assertj.core.api.Assertions.within;
@@ -327,7 +329,7 @@ void fullyQualifiedMethodWithMessage() {
327329
spec -> spec.typeValidationOptions(TypeValidation.none()),
328330
java(
329331
"""
330-
import org.junit.Test;
332+
import org.junit.jupiter.api.Test;
331333
332334
public class MyTest {
333335
@Test
@@ -341,7 +343,7 @@ private String[] notification() {
341343
}
342344
""",
343345
"""
344-
import org.junit.Test;
346+
import org.junit.jupiter.api.Test;
345347
346348
import static org.assertj.core.api.Assertions.assertThat;
347349

0 commit comments

Comments
 (0)