Skip to content

Commit fd5faf6

Browse files
authored
Move testcontainers into TypeTable (#685)
To work around testcontainers/testcontainers-java#8338
1 parent ef601e0 commit fd5faf6

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ recipeDependencies {
2929
parserClasspath("org.powermock:powermock-core:1.6.5")
3030
parserClasspath("org.springframework:spring-test:6.1.+")
3131
parserClasspath("org.testng:testng:7.+")
32+
parserClasspath("org.testcontainers:testcontainers:1.20.6")
3233
parserClasspath("pl.pragmatists:JUnitParams:1.+")
3334
}
3435

@@ -49,8 +50,6 @@ dependencies {
4950
compileOnly("org.projectlombok:lombok:latest.release")
5051
annotationProcessor("org.projectlombok:lombok:latest.release")
5152

52-
implementation("org.testcontainers:testcontainers:latest.release")
53-
5453
testImplementation("org.openrewrite:rewrite-java-17")
5554
testImplementation("org.openrewrite:rewrite-groovy")
5655
testImplementation("org.openrewrite:rewrite-test")

src/main/java/org/openrewrite/java/testing/testcontainers/ExplicitContainerImage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
6767
public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
6868
J.NewClass nc = super.visitNewClass(newClass, ctx);
6969
if (methodMatcher.matches(nc)) {
70-
Expression constructorArgument = getConstructorArgument(nc);
70+
Expression constructorArgument = getConstructorArgument(nc, ctx);
7171
return nc.withArguments(singletonList(constructorArgument))
7272
.withMethodType(nc.getMethodType()
7373
.withParameterTypes(singletonList(constructorArgument.getType()))
@@ -76,12 +76,12 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
7676
return nc;
7777
}
7878

79-
private Expression getConstructorArgument(J.NewClass newClass) {
79+
private Expression getConstructorArgument(J.NewClass newClass, ExecutionContext ctx) {
8080
if (parseImage != null && parseImage) {
8181
maybeAddImport("org.testcontainers.utility.DockerImageName");
8282
return JavaTemplate.builder("DockerImageName.parse(\"" + image + "\")")
8383
.imports("org.testcontainers.utility.DockerImageName")
84-
.javaParser(JavaParser.fromJavaVersion().classpath("testcontainers"))
84+
.javaParser(JavaParser.fromJavaVersion().classpathFromResources(ctx, "testcontainers"))
8585
.build()
8686
.apply(getCursor(), newClass.getCoordinates().replace())
8787
.withPrefix(Space.EMPTY);
912 KB
Binary file not shown.

0 commit comments

Comments
 (0)