Skip to content

Commit d3f479e

Browse files
committed
Update for compatibility with current rewrite snapshots
1 parent 01a8a88 commit d3f479e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/integTest/kotlin/org/openrewrite/java/testing/RunOnMavenProjectOnDisk.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class RunOnMavenProjectOnDisk {
136136
for (result in results) {
137137
println(result.before!!.sourcePath)
138138
println("-----------------------------------------")
139-
println(result.diff(SearchResult.PRINTER))
139+
println(result.diff(SearchResult.printer("~~>", "~~(%s)~~>")))
140140
}
141141
}
142142
}

src/main/java/org/openrewrite/java/testing/junit5/JUnitParamsRunnerToParameterized.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public J.Annotation visitAnnotation(J.Annotation annotation, ExecutionContext ex
119119
}
120120
} else if (anno.getArguments() != null && !anno.getArguments().isEmpty()){
121121
// This conversion is not supported add a comment to the annotation and the method name to the not supported list
122-
anno = anno.withComments(ListUtils.concat(anno.getComments(), new Comment(Comment.Style.LINE, " JunitParamsRunnerToParameterized conversion not supported", "\n" + anno.getPrefix().getIndent())));
122+
anno = anno.withComments(ListUtils.concat(anno.getComments(), new Comment(Comment.Style.LINE, " JunitParamsRunnerToParameterized conversion not supported", "\n" + anno.getPrefix().getIndent(), Markers.EMPTY)));
123123
J.MethodDeclaration m = getCursor().dropParentUntil(J.MethodDeclaration.class::isInstance).getValue();
124124
Set<String> unsupportedMethods = classDeclCursor.computeMessageIfAbsent(CONVERSION_NOT_SUPPORTED, v -> new HashSet<>());
125125
unsupportedMethods.add(m.getSimpleName());

src/main/java/org/openrewrite/java/testing/junit5/UpdateMockWebServer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import java.util.Collections;
3434
import java.util.UUID;
3535

36+
import static org.openrewrite.Tree.randomId;
37+
3638
/**
3739
* Recipe for converting JUnit4 okhttp3 MockWebServer Rules with their JUnit5 equivalent.
3840
* Note this recipe upgrades okhttp3 to version 4.x there are a few backwards incompatible changes: https://square.github.io/okhttp/upgrading_to_okhttp_4/#backwards-incompatible-changes
@@ -56,6 +58,8 @@ public class UpdateMockWebServer extends Recipe {
5658
)
5759
)).build());
5860

61+
UUID id = randomId();
62+
5963
@Override
6064
public String getDisplayName() {
6165
return "okhttp3 3.x MockWebserver @Rule To 4.x MockWebServer";
@@ -74,7 +78,7 @@ public J.CompilationUnit visitCompilationUnit(J.CompilationUnit cu, ExecutionCon
7478
J.CompilationUnit c = super.visitCompilationUnit(cu, executionContext);
7579
if (!FindTypes.find(cu, "org.junit.Rule").isEmpty()
7680
&& !FindTypes.find(cu, "okhttp3.mockwebserver.MockWebServer").isEmpty()) {
77-
c = c.withMarker(new RecipeSearchResult(UpdateMockWebServer.this));
81+
c = c.withMarkers(c.getMarkers().addOrUpdate(new RecipeSearchResult(id, UpdateMockWebServer.this)));
7882
}
7983
return c;
8084
}
@@ -163,4 +167,4 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
163167

164168

165169
}
166-
}
170+
}

0 commit comments

Comments
 (0)