From 634bdd63f6a11683d2711c8481c16f8eed255fcd Mon Sep 17 00:00:00 2001 From: "Addo.Zhang" Date: Tue, 26 Nov 2024 21:46:46 +0800 Subject: [PATCH 1/2] Add a default constructor for test only to pass testing. Signed-off-by: Addo.Zhang --- .../writing-a-java-refactoring-recipe.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/authoring-recipes/writing-a-java-refactoring-recipe.md b/docs/authoring-recipes/writing-a-java-refactoring-recipe.md index bd2a9529a1..2834759eaa 100644 --- a/docs/authoring-recipes/writing-a-java-refactoring-recipe.md +++ b/docs/authoring-recipes/writing-a-java-refactoring-recipe.md @@ -56,6 +56,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Value; +import org.jetbrains.annotations.TestOnly; import org.jspecify.annotations.NonNull; import org.openrewrite.*; @@ -71,6 +72,11 @@ public class SayHelloRecipe extends Recipe { @NonNull String fullyQualifiedClassName; + @TestOnly + public SayHelloRecipe() { + fullyQualifiedClassName = ""; + } + // All recipes must be serializable. This is verified by RewriteTest.rewriteRun() in your tests. @JsonCreator public SayHelloRecipe(@NonNull @JsonProperty("fullyQualifiedClassName") String fullyQualifiedClassName) { @@ -99,6 +105,7 @@ package com.yourorg; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import org.jetbrains.annotations.TestOnly; import org.jspecify.annotations.NonNull; import org.openrewrite.*; @@ -136,6 +143,11 @@ public class SayHelloRecipe extends Recipe { return fullyQualifiedClassName; } + @TestOnly + public SayHelloRecipe() { + fullyQualifiedClassName = ""; + } + // All recipes must be serializable. This is verified by RewriteTest.rewriteRun() in your tests. @JsonCreator public SayHelloRecipe(@NonNull @JsonProperty("fullyQualifiedClassName") String fullyQualifiedClassName) { From 1ed313ce0f40f0f05c7c1973ef622c976db3acf8 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 26 Nov 2024 15:48:29 +0100 Subject: [PATCH 2/2] Remove `@TestOnly` annotations from Java recipe doc To minimize what folks need on the classpath. --- docs/authoring-recipes/writing-a-java-refactoring-recipe.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/authoring-recipes/writing-a-java-refactoring-recipe.md b/docs/authoring-recipes/writing-a-java-refactoring-recipe.md index 2834759eaa..96c715eca1 100644 --- a/docs/authoring-recipes/writing-a-java-refactoring-recipe.md +++ b/docs/authoring-recipes/writing-a-java-refactoring-recipe.md @@ -56,7 +56,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.EqualsAndHashCode; import lombok.Value; -import org.jetbrains.annotations.TestOnly; import org.jspecify.annotations.NonNull; import org.openrewrite.*; @@ -72,7 +71,6 @@ public class SayHelloRecipe extends Recipe { @NonNull String fullyQualifiedClassName; - @TestOnly public SayHelloRecipe() { fullyQualifiedClassName = ""; } @@ -105,7 +103,6 @@ package com.yourorg; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.jetbrains.annotations.TestOnly; import org.jspecify.annotations.NonNull; import org.openrewrite.*; @@ -143,7 +140,6 @@ public class SayHelloRecipe extends Recipe { return fullyQualifiedClassName; } - @TestOnly public SayHelloRecipe() { fullyQualifiedClassName = ""; }