From b71b4e8e154b9c24614a23cff29d7a037960b1b1 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 4 Feb 2024 21:04:17 +0000 Subject: [PATCH] refactor: Use `Tree.randomId()` in LST constructors Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.UseTreeRandomId?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../testing/junit5/JUnitParamsRunnerToParameterized.java | 2 +- .../java/testing/junit5/UpdateMockWebServer.java | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/openrewrite/java/testing/junit5/JUnitParamsRunnerToParameterized.java b/src/main/java/org/openrewrite/java/testing/junit5/JUnitParamsRunnerToParameterized.java index 539304166..f4bb84386 100644 --- a/src/main/java/org/openrewrite/java/testing/junit5/JUnitParamsRunnerToParameterized.java +++ b/src/main/java/org/openrewrite/java/testing/junit5/JUnitParamsRunnerToParameterized.java @@ -258,7 +258,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex // If the method is an init-method then add a static modifier if necessary if (initMethods.contains(m.getSimpleName()) || initMethodReferences.containsValue(m.getSimpleName())) { if (m.getModifiers().stream().noneMatch(it -> J.Modifier.Type.Static.equals(it.getType()))) { - J.Modifier staticModifier = new J.Modifier(UUID.randomUUID(), Space.format(" "), Markers.EMPTY, null, J.Modifier.Type.Static, new ArrayList<>()); + J.Modifier staticModifier = new J.Modifier(Tree.randomId(), Space.format(" "), Markers.EMPTY, null, J.Modifier.Type.Static, new ArrayList<>()); m = maybeAutoFormat(m, m.withModifiers(ListUtils.concat(m.getModifiers(), staticModifier)), ctx, getCursor().getParentTreeCursor()); } } diff --git a/src/main/java/org/openrewrite/java/testing/junit5/UpdateMockWebServer.java b/src/main/java/org/openrewrite/java/testing/junit5/UpdateMockWebServer.java index 5a1e05ccd..05eb54297 100644 --- a/src/main/java/org/openrewrite/java/testing/junit5/UpdateMockWebServer.java +++ b/src/main/java/org/openrewrite/java/testing/junit5/UpdateMockWebServer.java @@ -15,10 +15,7 @@ */ package org.openrewrite.java.testing.junit5; -import org.openrewrite.ExecutionContext; -import org.openrewrite.Preconditions; -import org.openrewrite.Recipe; -import org.openrewrite.TreeVisitor; +import org.openrewrite.*; import org.openrewrite.internal.ListUtils; import org.openrewrite.internal.lang.Nullable; import org.openrewrite.java.AnnotationMatcher; @@ -31,7 +28,6 @@ import org.openrewrite.marker.Markers; import java.util.List; -import java.util.UUID; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; @@ -127,7 +123,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex if (method.getBody() != null) { if (method.getThrows() == null || method.getThrows().stream() .noneMatch(n -> TypeUtils.isOfClassType(n.getType(), IO_EXCEPTION_FQN))) { - J.Identifier ioExceptionIdent = new J.Identifier(UUID.randomUUID(), + J.Identifier ioExceptionIdent = new J.Identifier(Tree.randomId(), Space.format(" "), Markers.EMPTY, emptyList(),