From 8941f6de6b0847833beb6528bd22e3f55ac23f7c Mon Sep 17 00:00:00 2001 From: Tubby Date: Thu, 22 May 2025 14:35:07 +0200 Subject: [PATCH 1/4] added ConfigurationPropertiesDefaultValueTest for LST contains invalid nodes --- ...nfigurationPropertiesDefaultValueTest.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java diff --git a/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java new file mode 100644 index 000000000..590f9c1a0 --- /dev/null +++ b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2024 the original author or authors. + *

+ * Licensed under the Moderne Source Available License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://docs.moderne.io/licensing/moderne-source-available-license + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.java.spring.boot3; + +import org.junit.jupiter.api.Test; +import org.openrewrite.java.JavaParser; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; +import static org.openrewrite.java.Assertions.*; + +class ConfigurationPropertiesDefaultValueTest implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec.parser(JavaParser.fromJavaVersion() + .classpath("spring-boot") + ); + } + + @Test + void lstContainsErroneousNodes() { + rewriteRun( + //language=java + java( + """ + import org.springframework.boot.context.properties.ConfigurationProperties; + import org.springframework.boot.context.properties.bind.DefaultValue; + + @ConfigurationProperties("nl.tubby") + record TestTubbyProperties( + @DefaultValue("https://www.tubby.nl") String url + ) { + } + """, + """ + import org.springframework.boot.context.properties.ConfigurationProperties; + import org.springframework.boot.context.properties.bind.DefaultValue; + + @ConfigurationProperties("nl.tubby") + record TestTubbyProperties( + @DefaultValue("https://www.tubby.nl") String url + ) { + } + """ + ) + ); + } +} From 53751a2c61d1012871b09c09b642c30a189531e1 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 31 May 2025 14:47:20 +0200 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../boot3/ConfigurationPropertiesDefaultValueTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java index 590f9c1a0..5fae8b6db 100644 --- a/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java +++ b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java @@ -16,7 +16,9 @@ package org.openrewrite.java.spring.boot3; import org.junit.jupiter.api.Test; -import org.openrewrite.java.JavaParser; +import org.openrewrite.DocumentExample; + +import static org.openrewrite.java.Assertions.java; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; import static org.openrewrite.java.Assertions.*; @@ -30,6 +32,7 @@ public void defaults(RecipeSpec spec) { ); } + @DocumentExample @Test void lstContainsErroneousNodes() { rewriteRun( @@ -54,7 +57,7 @@ record TestTubbyProperties( @DefaultValue("https://www.tubby.nl") String url ) { } - """ + """ ) ); } From 1b940fdd0bf832c464d2ebafae950c18a6a4e926 Mon Sep 17 00:00:00 2001 From: Laurens Westerlaken Date: Fri, 6 Jun 2025 20:09:25 +0200 Subject: [PATCH 3/4] Fix compile issue --- .../spring/boot3/ConfigurationPropertiesDefaultValueTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java index 5fae8b6db..f163ef73d 100644 --- a/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java +++ b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java @@ -19,6 +19,8 @@ import org.openrewrite.DocumentExample; import static org.openrewrite.java.Assertions.java; + +import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; import static org.openrewrite.java.Assertions.*; From d861cee2e6c1235296457e7227af6675b4cbb48e Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 10 Jun 2025 12:29:49 +0200 Subject: [PATCH 4/4] Update ConfigurationPropertiesDefaultValueTest.java --- .../boot3/ConfigurationPropertiesDefaultValueTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java index f163ef73d..335e2acea 100644 --- a/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java +++ b/src/testWithSpringBoot_3_4/java/org/openrewrite/java/spring/boot3/ConfigurationPropertiesDefaultValueTest.java @@ -17,13 +17,11 @@ import org.junit.jupiter.api.Test; import org.openrewrite.DocumentExample; - -import static org.openrewrite.java.Assertions.java; - import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; -import static org.openrewrite.java.Assertions.*; + +import static org.openrewrite.java.Assertions.java; class ConfigurationPropertiesDefaultValueTest implements RewriteTest {