diff --git a/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MultiModuleAwareActionDeserializer.java b/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MultiModuleAwareActionDeserializer.java index 20249dda7..047e0e9ad 100644 --- a/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MultiModuleAwareActionDeserializer.java +++ b/components/sbm-core/src/main/java/org/springframework/sbm/engine/recipe/MultiModuleAwareActionDeserializer.java @@ -25,8 +25,13 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +/*** + * + * @deprecated Use "One Action implementation per use case" instead, see https://github.com/spring-projects-experimental/spring-boot-migrator/discussions/345 + */ @Component @RequiredArgsConstructor +@Deprecated(forRemoval = true) public class MultiModuleAwareActionDeserializer implements ActionDeserializer { protected final ObjectMapper yamlObjectMapper; diff --git a/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/ConditionDeserializerTest.java b/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/ConditionDeserializerTest.java new file mode 100644 index 000000000..b256f2f8c --- /dev/null +++ b/components/sbm-core/src/test/java/org/springframework/sbm/engine/recipe/ConditionDeserializerTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.engine.recipe; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.sbm.java.migration.conditions.HasMemberAnnotation; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Fabian Krüger + */ +class ConditionDeserializerTest { + @Test + void deserializeCondition() throws JsonProcessingException { + String yaml = + """ + type: org.springframework.sbm.java.migration.conditions.HasMemberAnnotation + annotation: "some.Annotation" + """; + + ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + SimpleModule moule = new SimpleModule("ConditionModule"); + AutowireCapableBeanFactory beanFactory = Mockito.mock(AutowireCapableBeanFactory.class); + moule.addDeserializer(Condition.class, new ConditionDeserializer(objectMapper, beanFactory)); + objectMapper.registerModule(moule); + + Condition condition = objectMapper.readValue(yaml, Condition.class); + + assertThat(condition).isInstanceOf(HasMemberAnnotation.class); + HasMemberAnnotation typedCondition = (HasMemberAnnotation) condition; + assertThat(typedCondition.getDescription()).isEqualTo("If there are any fields annotated with some.Annotation"); + assertThat(typedCondition).hasFieldOrPropertyWithValue("annotation", "some.Annotation"); + } +} \ No newline at end of file diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionDeserializer.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionDeserializer.java deleted file mode 100644 index 97b0eca43..000000000 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionDeserializer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2021 - 2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * 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.springframework.sbm.boot.upgrade_27_30.report; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; -import org.springframework.sbm.engine.recipe.Action; -import org.springframework.sbm.engine.recipe.ActionDeserializer; -import org.springframework.stereotype.Component; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -/** - * @author Fabian Krüger - */ -@Component -public class SpringBootUpgradeReportActionDeserializer implements ActionDeserializer { - @Override - public Action deserialize(ObjectMapper tolerantObjectMapper, Class actionClass, JsonNode node, AutowireCapableBeanFactory beanFactory) { - try { - SpringBootUpgradeReportAction action = (SpringBootUpgradeReportAction) tolerantObjectMapper.convertValue(node, actionClass); - - JsonNode dataProviderNode = node.get("dataProvider"); - if(dataProviderNode != null) { - String className = dataProviderNode.textValue(); - if(className == null || className.isEmpty()) { - throw new IllegalArgumentException("dataProvider for Action '"+action.getDescription()+"' was found but no fully qualified classname was provided."); - } - Class aClass = Class.forName(className); - Constructor constructor = aClass.getConstructor(null); - Object o = constructor.newInstance(); - SpringBootUpgradeReportAction.DataProvider dataProvider = (SpringBootUpgradeReportAction.DataProvider) o; - action.setDataProvider(dataProvider); - } - - JsonNode sections = node.get("sections"); - if (sections != null) { - if(ArrayNode.class.isInstance(sections)) { - ArrayNode arrayNode = (ArrayNode) sections; - for(int i=0; i < arrayNode.size(); i++) { - JsonNode helper = arrayNode.get(i).get("helper"); - String type = helper.textValue(); - Class aClass = Class.forName(type); - Constructor constructor = aClass.getConstructor(null); - Object o = constructor.newInstance(); - SpringBootUpgradeReportSection.Helper cast = (SpringBootUpgradeReportSection.Helper) aClass.cast(o); - SpringBootUpgradeReportSection section = action.getSections().get(i); - section.setHelper(cast); - beanFactory.autowireBean(section); - } - } - } else { - throw new IllegalArgumentException("Could not find required field 'sections' for SpringBootUpgradeReportAction with description '"+action.getDescription()+"'."); - } - beanFactory.autowireBean(action); - return action; - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - @Override - public boolean canHandle(Class key) { - return SpringBootUpgradeReportAction.class.isAssignableFrom(key); - } -} diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSection.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSection.java index 0299606b2..4fc32b554 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSection.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSection.java @@ -47,36 +47,16 @@ @Setter public class SpringBootUpgradeReportSection { - private static final String ls = System.lineSeparator(); - - /** - * Helper acting as {@link Condition} and data provide for a {@link SpringBootUpgradeReportSection}. - * @deprecated Use {@link AbstractHelper} instead - */ - @Deprecated(forRemoval = true) - public interface Helper extends Condition { - /** - * @return {@code Map} the model data for the template. - */ - Map getData(); - } - - public static abstract class AbstractHelper implements Helper { - - @Override - public String getDescription() { - return ""; - } - } - public static final String CHANGE_HEADER = "What Changed"; public static final String AFFECTED = "Why is the application affected"; public static final String REMEDIATION = "Remediation"; - - public boolean shouldRender(ProjectContext context) { - return helper.evaluate(context); - } - + private static final String ls = System.lineSeparator(); + /** + * The spring project(s)/modules this change comes from. + * + * e.g. {@code spring-boot} and {@code actuator} + */ + private List projects; /** * Section title */ @@ -108,15 +88,22 @@ public boolean shouldRender(ProjectContext context) { @NotNull private Set contributors; - @JsonIgnore - private Helper helper; + @NotNull + private SpringBootUpgradeReportSectionHelper helper; + @JsonIgnore @Autowired private SpringBootUpgradeReportFreemarkerSupport freemarkerSupport; + public boolean shouldRender(ProjectContext context) { + return helper.evaluate(context); + } + + + public String render(ProjectContext context) { if (getHelper().evaluate(context)) { - Map params = getHelper().getData(); + Map params = getHelper().getData(); try (StringWriter writer = new StringWriter()) { String templateContent = buildTemplate(); @@ -137,7 +124,7 @@ public String render(ProjectContext context) { throw new IllegalArgumentException("Could not render Section '"+ getTitle()+"', evaluating the context returned false"); } - private void renderTemplate(Map params, StringWriter writer, String templateContent) throws IOException, TemplateException { + private void renderTemplate(Map params, StringWriter writer, String templateContent) throws IOException, TemplateException { String templateName = getTitle().replace(" ", "") + UUID.randomUUID(); freemarkerSupport.getStringLoader().putTemplate(templateName, templateContent); Template t = freemarkerSupport.getConfiguration().getTemplate(templateName); @@ -207,20 +194,19 @@ private void renderLineBreak(StringBuilder sb) { sb.append(ls); } - private void renderGitHubInfo(StringBuilder sb) { + void renderGitHubInfo(StringBuilder sb) { if(gitHubIssue != null) { - sb.append("Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/").append(gitHubIssue).append("[#").append(gitHubIssue).append("^, role=\"ext-link\"]"); - } - if(contributors != null && gitHubIssue != null) { - sb.append(", "); - } else { - sb.append(ls); + sb.append("**Issue:** https://github.com/spring-projects-experimental/spring-boot-migrator/issues/").append(gitHubIssue).append("[#").append(gitHubIssue).append("^, role=\"ext-link\"] ").append(" + ").append(ls); } if(contributors != null) { List authors = getAuthors(); - sb.append("Contributors: "); + sb.append("**Contributors:** "); String authorsString = authors.stream().map(a -> "https://github.com/" + a.getHandle() + "[@" + a.getHandle() + "^, role=\"ext-link\"]").collect(Collectors.joining(", ")); - sb.append(authorsString).append(ls); + sb.append(authorsString).append(" + ").append(ls); + } + if(projects != null){ + String projectsList = projects.stream().collect(Collectors.joining(", ")); + sb.append("**Projects:** ").append(projectsList).append(ls); } } @@ -229,6 +215,10 @@ private void renderSectionTitle(StringBuilder sb) { } public List getAuthors() { + if(contributors == null) { + return List.of(); + } + return contributors.stream() .map(c -> { Matcher matcher = Pattern.compile("(.*)\\[(.*)\\]").matcher(c); diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSectionHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSectionHelper.java new file mode 100644 index 000000000..f11a19885 --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSectionHelper.java @@ -0,0 +1,37 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.boot.upgrade_27_30.report; + +import org.springframework.sbm.engine.recipe.Condition; + +import java.util.Map; + +/** + * Helper base class which is {@link Condition} and data provider for a {@link SpringBootUpgradeReportSection}. + * + * @author Fabian Krüger + */ +public abstract class SpringBootUpgradeReportSectionHelper implements Condition { + /** + * @return {@code Map} the model data for the template. + */ + public abstract Map getData(); + + @Override + public String getDescription() { + return ""; + } +} diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java index fb68e0d91..e43acbed6 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationHelper.java @@ -16,6 +16,7 @@ package org.springframework.sbm.boot.upgrade_27_30.report.helper; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.build.api.BuildFile; import org.springframework.sbm.build.api.Module; import org.springframework.sbm.engine.context.ProjectContext; @@ -29,7 +30,7 @@ /** * @author Fabian Krüger */ -public class ActuatorEndpointsSanitizationHelper extends SpringBootUpgradeReportSection.AbstractHelper> { +public class ActuatorEndpointsSanitizationHelper extends SpringBootUpgradeReportSectionHelper> { private static final String ACTUATOR_GROUP_ID = "org.springframework.boot"; private static final String ACTUATOR_ARTIFACT_ID = "spring-boot-actuator"; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/AddSpringBootRepositoriesHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/AddSpringBootRepositoriesHelper.java index 202ae7aab..d94c35238 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/AddSpringBootRepositoriesHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/AddSpringBootRepositoriesHelper.java @@ -17,18 +17,14 @@ package org.springframework.sbm.boot.upgrade_27_30.report.helper; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.build.migration.conditions.NoPluginRepositoryExistsCondition; import org.springframework.sbm.build.migration.conditions.NoRepositoryExistsCondition; import org.springframework.sbm.engine.context.ProjectContext; import java.util.Map; -public class AddSpringBootRepositoriesHelper implements SpringBootUpgradeReportSection.Helper{ - @Override - public String getDescription() { - return null; - } - +public class AddSpringBootRepositoriesHelper extends SpringBootUpgradeReportSectionHelper { @Override public boolean evaluate(ProjectContext context) { return new NoRepositoryExistsCondition().evaluate(context) && new NoPluginRepositoryExistsCondition().evaluate(context); diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java index 96cbdad3d..bc77ba395 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java @@ -18,6 +18,7 @@ import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.project.resource.RewriteSourceFileHolder; @@ -26,7 +27,7 @@ import java.util.Map; import java.util.stream.Collectors; -public class BannerSupportHelper implements SpringBootUpgradeReportSection.Helper> { +public class BannerSupportHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java index eb1cef43d..945aedc54 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java @@ -21,6 +21,7 @@ import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFilter; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.build.migration.conditions.NoDependencyExistMatchingRegex; import org.springframework.sbm.engine.context.ProjectContext; @@ -34,7 +35,7 @@ /** * @author Fabian Krüger */ -public class ChangesToDataPropertiesHelper implements SpringBootUpgradeReportSection.Helper> { +public class ChangesToDataPropertiesHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelper.java index 5fec2bfb8..09e11a313 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelper.java @@ -20,6 +20,7 @@ import org.springframework.sbm.boot.common.finder.MatchingMethod; import org.springframework.sbm.boot.common.finder.SpringBeanMethodDeclarationFinder; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import java.util.HashMap; @@ -27,7 +28,7 @@ import java.util.Map; import java.util.stream.Collectors; -public class CommonsMultipartResolverHelper implements SpringBootUpgradeReportSection.Helper>{ +public class CommonsMultipartResolverHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; private static final String COMMONS_MULTIPART_RESOLVER_CLASS = "org.springframework.web.multipart.commons.CommonsMultipartResolver"; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConditionOnlyHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConditionOnlyHelper.java new file mode 100644 index 000000000..14af5b578 --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConditionOnlyHelper.java @@ -0,0 +1,46 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.boot.upgrade_27_30.report.helper; + +import lombok.Setter; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; +import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.engine.recipe.Condition; + +import java.util.Map; + +/** + * Helper for {@link org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection} that takes a {@link Condition} and returns empty map as data. + * + * Meant to be used to reuse existing {@link Condition}s for {@link SpringBootUpgradeReportSectionHelper}. + * + * @author Fabian Krüger + */ +public class ConditionOnlyHelper extends SpringBootUpgradeReportSectionHelper { + + @Setter + private Condition condition; + + @Override + public boolean evaluate(ProjectContext context) { + return condition.evaluate(context); + } + + @Override + public Map getData() { + return Map.of(); + } +} diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java index 7fce8ff2a..719f91196 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingHelper.java @@ -24,6 +24,7 @@ import org.openrewrite.java.tree.J; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.OpenRewriteSourceFilesFinder; import org.springframework.sbm.project.resource.RewriteSourceFileHolder; @@ -34,7 +35,7 @@ import java.util.stream.Collectors; -public class ConstructorBindingHelper implements SpringBootUpgradeReportSection.Helper> { +public class ConstructorBindingHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; private List constructorBindingFiles; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/DoNothingAlwaysTrueHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/DoNothingAlwaysTrueHelper.java new file mode 100644 index 000000000..03b0cf116 --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/DoNothingAlwaysTrueHelper.java @@ -0,0 +1,37 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.boot.upgrade_27_30.report.helper; + +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; +import org.springframework.sbm.engine.context.ProjectContext; + +import java.util.Map; + +/** + * @author Fabian Krüger + */ +public class DoNothingAlwaysTrueHelper extends SpringBootUpgradeReportSectionHelper { + @Override + public boolean evaluate(ProjectContext context) { + return true; + } + + @Override + public Map getData() { + return Map.of(); + } +} diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelper.java index 9aae32ddb..ca4e5d1fd 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatHelper.java @@ -18,6 +18,7 @@ import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.filter.LoggingDateFormatPropertyFinder; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.properties.api.PropertiesSource; @@ -27,7 +28,7 @@ /** * @author Fabian Krüger */ -public class LoggingDateFormatHelper implements SpringBootUpgradeReportSection.Helper> { +public class LoggingDateFormatHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; private List propertiesSources; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java index d0e2afb74..d820c3bcb 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelper.java @@ -22,6 +22,7 @@ import org.openrewrite.java.tree.J; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.project.resource.RewriteSourceFileHolder; import org.springframework.sbm.support.openrewrite.GenericOpenRewriteRecipe; @@ -31,7 +32,7 @@ import java.util.Map; import java.util.stream.Collectors; -public class PagingAndSortingHelper implements SpringBootUpgradeReportSection.Helper> { +public class PagingAndSortingHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; private List pagingAndSortingRepo; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java index 7c0e0b5a3..a7852df4b 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesHelper.java @@ -20,6 +20,7 @@ import org.openrewrite.java.tree.J; import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.java.api.JavaSource; import org.springframework.sbm.java.impl.OpenRewriteJavaSource; @@ -32,7 +33,7 @@ /** * @author Fabian Krüger */ -public class SpringMVCAndWebFluxUrlMatchingChangesHelper implements SpringBootUpgradeReportSection.Helper> { +public class SpringMVCAndWebFluxUrlMatchingChangesHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; private static final String SPRING_REST_CONTROLLER_FQN = "org.springframework.web.bind.annotation.RestController"; diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeDependenciesHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeDependenciesHelper.java index 64ce3c693..7e30f4052 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeDependenciesHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeDependenciesHelper.java @@ -18,6 +18,7 @@ import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportAction; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.java.api.JavaSource; @@ -27,7 +28,7 @@ /** * @author Fabian Krüger */ -public class UpgradeDependenciesHelper implements SpringBootUpgradeReportSection.Helper> { +public class UpgradeDependenciesHelper extends SpringBootUpgradeReportSectionHelper> { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; @Override diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeSpringBootVersionHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeSpringBootVersionHelper.java index 6208a4c07..ea02b47b0 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeSpringBootVersionHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/UpgradeSpringBootVersionHelper.java @@ -17,6 +17,7 @@ import org.springframework.sbm.boot.common.conditions.IsSpringBootProject; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.java.api.JavaSource; @@ -26,7 +27,7 @@ /** * @author Fabian Krüger */ -public class UpgradeSpringBootVersionHelper implements SpringBootUpgradeReportSection.Helper { +public class UpgradeSpringBootVersionHelper extends SpringBootUpgradeReportSectionHelper { public static final String VERSION_PATTERN = "(2\\.7\\..*)|(3\\.0\\..*)"; @Override diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportActionDeserializer.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportActionDeserializer.java new file mode 100644 index 000000000..2d932003b --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportActionDeserializer.java @@ -0,0 +1,63 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.boot.upgrade_27_30.report.yaml; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.node.ArrayNode; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportAction; +import org.springframework.sbm.engine.recipe.Action; +import org.springframework.sbm.engine.recipe.ActionDeserializer; +import org.springframework.sbm.engine.recipe.Condition; +import org.springframework.sbm.engine.recipe.ConditionDeserializer; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * @author Fabian Krüger + */ +@Component +public class SpringBootUpgradeReportActionDeserializer implements ActionDeserializer { + + protected final AutowireCapableBeanFactory beanFactory; + + public SpringBootUpgradeReportActionDeserializer(AutowireCapableBeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + + // @Override + public Action deserialize(ObjectMapper tolerantObjectMapper, Class actionClass, JsonNode node, AutowireCapableBeanFactory beanFactory) { + SpringBootUpgradeReportAction action = (SpringBootUpgradeReportAction) tolerantObjectMapper.convertValue(node, actionClass); + beanFactory.autowireBean(action); + action.getSections().stream().forEach(s -> beanFactory.autowireBean(s)); + return action; + } + + // @Override + public boolean canHandle(Class key) { + return SpringBootUpgradeReportAction.class.isAssignableFrom(key); + } + +} diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportSectionHelperDeserializer.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportSectionHelperDeserializer.java new file mode 100644 index 000000000..e06d7547a --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportSectionHelperDeserializer.java @@ -0,0 +1,124 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.boot.upgrade_27_30.report.yaml; + +import com.fasterxml.jackson.core.JacksonException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.node.TextNode; +import org.jetbrains.annotations.NotNull; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; +import org.springframework.sbm.boot.upgrade_27_30.report.helper.ConditionOnlyHelper; +import org.springframework.sbm.engine.recipe.Condition; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +/** + * Custom Jackson deserializer to deserialize SpringBootUpgradeSectionHelper with and without declared conditon. + * + *
+ *  helper: fully.qualified.path.TheHelper
+ * 
+ * + * and + * + *
+ *  helper:
+ *    type: org.springframework.sbm.boot.upgrade_27_30.report.helper.ConditionOnlyHelper
+ *    conditon:
+ *      type: fully.qualified.ConditionClassName
+ *      optionalParam: some-param
+ * 
+ * @author Fabian Krüger + */ +public class SpringBootUpgradeReportSectionHelperDeserializer extends StdDeserializer { + + public SpringBootUpgradeReportSectionHelperDeserializer() { + super(SpringBootUpgradeReportSectionHelper.class); + } + + @Override + public SpringBootUpgradeReportSectionHelper deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException { + + TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser); + try { + // helper in section, 'helper: some.helper.ClassName' + if(treeNode.getClass().isAssignableFrom(TextNode.class)) { + Class helperClass = classFromTextNode((TextNode) treeNode); + if( ! SpringBootUpgradeReportSectionHelper.class.isAssignableFrom(helperClass)) { + throw new IllegalArgumentException("Helper must be of type " + SpringBootUpgradeReportSectionHelper.class.getName()); + } + return (SpringBootUpgradeReportSectionHelper) helperClass.getConstructor().newInstance(); + } + // helper in section with condition + else if(treeNode.path("type") != null && treeNode.path("type").path("condition") != null) { + if (treeNode.path("type").getClass().isAssignableFrom(TextNode.class)) { + Class helperClass = classFromTextNode((TextNode) treeNode.path("type")); + if (helperClass.isAssignableFrom(ConditionOnlyHelper.class)) { + ConditionOnlyHelper coh = (ConditionOnlyHelper) helperClass.getConstructor().newInstance(); + Condition condition = jsonParser.getCodec().treeToValue(treeNode.path("condition"), Condition.class); + coh.setCondition(condition); + return coh; + } else { + throw new IllegalArgumentException(String.format("Helper with condition must extend %s", ConditionOnlyHelper.class.getSimpleName())); + } + } else { + throw exceptionWithExample(); + } + } + throw exceptionWithExample(); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (InstantiationException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } + } + + @NotNull + private Class classFromTextNode(TextNode treeNode) throws ClassNotFoundException { + String className = treeNode.asText(); + Class aClass = Class.forName(className); + return aClass; + } + + private IllegalArgumentException exceptionWithExample() { + return new IllegalArgumentException( + String.format( + """ + Helper must be given. + 1. Without condition: + helper: + 2. With condition: + helper: + type: + conditon: + type: + optionalParam: + """, + ConditionOnlyHelper.class.getSimpleName()) + ); + } + +} diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportYamlDeserializationConfiguration.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportYamlDeserializationConfiguration.java new file mode 100644 index 000000000..27a28a3ab --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/yaml/SpringBootUpgradeReportYamlDeserializationConfiguration.java @@ -0,0 +1,47 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.boot.upgrade_27_30.report.yaml; + +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSectionHelper; + +/** + * Register module with upgrade report specific yaml deserializers with + * {@code yamlObjectMapper} Bean declared in {@link org.springframework.sbm.engine.recipe.YamlObjectMapperConfiguration}. + * + * @author Fabian Krüger + */ +@Configuration +public class SpringBootUpgradeReportYamlDeserializationConfiguration { + + @EventListener + public void onApplicationEvent(ContextRefreshedEvent event) { + YAMLMapper yamlObjectMapper = event.getApplicationContext().getBean(YAMLMapper.class); + + SpringBootUpgradeReportSectionHelperDeserializer springBootUpgradeReportSectionHelperDeserializer = new SpringBootUpgradeReportSectionHelperDeserializer(); + SimpleModule module = + new SimpleModule("SpringBootUpgradeReportDeserializer", new Version(1, 0, 0, null, null, null)); + module.addDeserializer(SpringBootUpgradeReportSectionHelper.class, springBootUpgradeReportSectionHelperDeserializer); + + yamlObjectMapper.registerModule(module); + } + +} diff --git a/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/27_30/report/sbu30-report.yaml b/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/27_30/report/sbu30-report.yaml index adc5292b9..db0513dd3 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/27_30/report/sbu30-report.yaml +++ b/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/27_30/report/sbu30-report.yaml @@ -27,8 +27,8 @@ :idprefix: :idseparator: - :toc: left - :sectnumlevels: 3 - :toclevels: 3 + :sectnumlevels: 2 + :toclevels: 2 :tabsize: 4 :numbered: :sectanchors: @@ -181,6 +181,7 @@ # recipe: sbu30-225-actuator-endpoint-sanitization projects: - spring-boot + - actuator gitHubIssue: 445 contributors: - "Fabian Krüger[@fabapp2]" diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/RemoveImageBannerTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/RemoveImageBannerTest.java index eb7bd199f..8d3e941bf 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/RemoveImageBannerTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/RemoveImageBannerTest.java @@ -16,7 +16,7 @@ package org.springframework.sbm.boot.upgrade_27_30; import org.junit.jupiter.api.Test; -import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportActionDeserializer; +import org.springframework.sbm.boot.upgrade_27_30.report.yaml.SpringBootUpgradeReportActionDeserializer; import org.springframework.sbm.build.util.PomBuilder; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.recipe.Recipe; diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportDeserializationTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportDeserializationTest.java new file mode 100644 index 000000000..46737de44 --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportDeserializationTest.java @@ -0,0 +1,285 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.sbm.boot.upgrade_27_30.report; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import lombok.Getter; +import lombok.Setter; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.sbm.boot.upgrade_27_30.report.helper.BannerSupportHelper; +import org.springframework.sbm.boot.upgrade_27_30.report.helper.ConditionOnlyHelper; +import org.springframework.sbm.boot.upgrade_27_30.report.yaml.SpringBootUpgradeReportSectionHelperDeserializer; +import org.springframework.sbm.boot.upgrade_27_30.report.helper.UpgradeDependenciesHelper; +import org.springframework.sbm.boot.upgrade_27_30.report.yaml.SpringBootUpgradeReportActionDeserializer; +import org.springframework.sbm.boot.upgrade_27_30.report.yaml.SpringBootUpgradeReportYamlDeserializationConfiguration; +import org.springframework.sbm.common.migration.conditions.TrueCondition; +import org.springframework.sbm.engine.context.ProjectContextHolder; +import org.springframework.sbm.engine.recipe.*; +import org.springframework.sbm.java.migration.conditions.HasImportStartingWith; +import org.springframework.test.util.ReflectionTestUtils; + +import java.io.IOException; +import java.net.URISyntaxException; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +/** + * @author Fabian Krüger + */ +@SpringBootTest(classes = { + SpringBootUpgradeReportYamlDeserializationConfiguration.class, + YamlObjectMapperConfiguration.class, + SpringBootUpgradeReportDataProvider.class, + ProjectContextHolder.class, + SpringBootUpgradeReportFreemarkerSupport.class, + SpringBootUpgradeReportFileSystemRenderer.class, + SpringBootUpgradeReportActionDeserializer.class, + ActionDeserializerRegistry.class +}) +public class SpringBootUpgradeReportDeserializationTest { + + @Autowired + private ObjectMapper yamlObjectMapper; + + @Test + void deserializeAction() throws IOException, URISyntaxException { + + String yaml = """ + - name: sbu30-report + description: Create a report for Spring Boot Upgrade from 2.7.x to 3.0.x + condition: + type: org.springframework.sbm.boot.common.conditions.IsSpringBootProject + versionPattern: "2\\\\.7\\\\..*" + + actions: + + - type: org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportAction + file: report + condition: + type: org.springframework.sbm.common.migration.conditions.TrueCondition + + dataProvider: org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportDataProvider + + header: |- + The header... + with two lines + sections: + + - title: Upgrade Dependencies + helper: org.springframework.sbm.boot.upgrade_27_30.report.helper.UpgradeDependenciesHelper + change: |- + Spring Boot 3.0 upgraded many used dependencies.\s + Also, dependencies previously in the `javax` packages use the new `jakarta` packages now. + WARNING: THis is a dummy and needs to be replaced with the matching changes from the release notes! + affected: |- + List the found dependencies here? + remediation: + description: |- + A comprehensive list of affected dependencies and their new replacements + recipe: sbu30-upgrade-dependencies + contributors: + - "Fabian Krüger[@fabapp2]" + + footer: |- + We want to say thank you to all Contributors! + Generated by Spring Boot Migrator (experimental) + """; + + Recipe[] recipe = yamlObjectMapper.readValue(yaml, Recipe[].class); + + assertThat(recipe[0].getActions()).hasSize(1); + assertThat(recipe[0].getActions().get(0)).isInstanceOf(SpringBootUpgradeReportAction.class); + SpringBootUpgradeReportAction action = (SpringBootUpgradeReportAction) recipe[0].getActions().get(0); + assertThat(action.getCondition()).isInstanceOf(TrueCondition.class); + assertThat(action.getDataProvider()).isInstanceOf(SpringBootUpgradeReportDataProvider.class); + assertThat(action.getHeader()).isEqualTo(""" + The header... + with two lines"""); + assertThat(action.getFooter()).isEqualTo(""" + We want to say thank you to all Contributors! + Generated by Spring Boot Migrator (experimental)"""); + + assertThat(action.getSections()).hasSize(1); + SpringBootUpgradeReportSection section = (SpringBootUpgradeReportSection) action.getSections().get(0); + assertThat(section.getTitle()).isEqualTo("Upgrade Dependencies"); + assertThat(section.getHelper()).isInstanceOf(UpgradeDependenciesHelper.class); + assertThat(section.getChange()).isEqualTo(""" + Spring Boot 3.0 upgraded many used dependencies.\s + Also, dependencies previously in the `javax` packages use the new `jakarta` packages now. + WARNING: THis is a dummy and needs to be replaced with the matching changes from the release notes!"""); + assertThat(section.getAffected()).isEqualTo(""" + List the found dependencies here?"""); + assertThat(section.getContributors()).hasSize(1); + assertThat(section.getContributors().iterator().next()).isEqualTo("Fabian Krüger[@fabapp2]"); + + assertThat(section.getRemediation()).isInstanceOf(Remediation.class); + Remediation remediation = section.getRemediation(); + assertThat(remediation.getDescription()).isEqualTo("A comprehensive list of affected dependencies and their new replacements"); + assertThat(remediation.getRecipe()).isEqualTo("sbu30-upgrade-dependencies"); + } + + + @Test + void conditionOnlyHelper() throws JsonProcessingException { + + String yaml = + """ + type: org.springframework.sbm.boot.upgrade_27_30.report.helper.ConditionOnlyHelper + condition: + type: org.springframework.sbm.java.migration.conditions.HasImportStartingWith + value: "a.b" + """; + + AutowireCapableBeanFactory beanFactory = mock(AutowireCapableBeanFactory.class); + ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + SimpleModule module = new SimpleModule("HelperModule"); + module.addDeserializer(SpringBootUpgradeReportSectionHelper.class, new SpringBootUpgradeReportSectionHelperDeserializer()); + module.addDeserializer(Condition.class, new ConditionDeserializer(objectMapper, beanFactory)); + objectMapper.registerModule(module); + + SpringBootUpgradeReportSectionHelper helper = objectMapper.readValue(yaml, SpringBootUpgradeReportSectionHelper.class); + + assertThat(helper).isInstanceOf(ConditionOnlyHelper.class); + ConditionOnlyHelper concreteHelper = (ConditionOnlyHelper) helper; + HasImportStartingWith condition = (HasImportStartingWith) ReflectionTestUtils.getField(concreteHelper, "condition"); + assertThat(condition).hasFieldOrPropertyWithValue("value", "a.b"); + } + + + @Setter + @Getter + public static class HoldingHelper { + private SpringBootUpgradeReportSectionHelper helper; + } + + @Test + void standardHelper() throws JsonProcessingException { + String yaml = + """ + helper: org.springframework.sbm.boot.upgrade_27_30.report.helper.BannerSupportHelper + """; + + ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + SimpleModule module = new SimpleModule("HelperModule"); + module.addDeserializer(SpringBootUpgradeReportSectionHelper.class, new SpringBootUpgradeReportSectionHelperDeserializer()); + objectMapper.registerModule(module); + + HoldingHelper helper = objectMapper.readValue(yaml, HoldingHelper.class); + assertThat(helper).isNotNull(); + assertThat(helper.getHelper()).isInstanceOf(BannerSupportHelper.class); + } + + @Test + void sectionCanHaveConditionOnly() throws JsonProcessingException { + String yaml = """ + type: org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportAction + file: report + condition: + type: org.springframework.sbm.boot.common.conditions.IsSpringBootProject + versionPattern: "2\\\\.7\\\\..*" + dataProvider: org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportDataProvider + header: |- + The header... + with two lines + sections: + - title: Title 1 + helper: + type: org.springframework.sbm.boot.upgrade_27_30.report.helper.ConditionOnlyHelper + condition: + type: org.springframework.sbm.java.migration.conditions.HasImportStartingWith + value: "a.b" + change: |- + The change + affected: |- + List the found dependencies here? + remediation: + description: |- + A comprehensive list of affected dependencies and their new replacements + recipe: sbu30-upgrade-dependencies + contributors: + - "Fabian Krüger[@fabapp2]" + """; + + AutowireCapableBeanFactory beanFactory = mock(AutowireCapableBeanFactory.class); + ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + SimpleModule module = new SimpleModule("HelperModule"); + module.addDeserializer(SpringBootUpgradeReportSectionHelper.class, new SpringBootUpgradeReportSectionHelperDeserializer()); + module.addDeserializer(Condition.class, new ConditionDeserializer(objectMapper, beanFactory)); + objectMapper.registerModule(module); + + SpringBootUpgradeReportAction action = objectMapper.readValue(yaml, SpringBootUpgradeReportAction.class); + assertThat(action.getSections().get(0).getHelper()).isInstanceOf(ConditionOnlyHelper.class); + ConditionOnlyHelper helper = (ConditionOnlyHelper) action.getSections().get(0).getHelper(); + assertThat(helper.getData()).hasSize(0); + HasImportStartingWith condition = (HasImportStartingWith) ReflectionTestUtils.getField(helper, "condition"); + assertThat(condition.getValue()).isEqualTo("a.b"); + } + + @Test + void sectionCanHaveConditionOnly2() throws JsonProcessingException { + String yaml = """ + type: org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportAction + file: report + condition: + type: org.springframework.sbm.boot.common.conditions.IsSpringBootProject + versionPattern: "2\\\\.7\\\\..*" + dataProvider: org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportDataProvider + header: |- + The header... + with two lines + sections: + - title: Title 2 + helper: org.springframework.sbm.boot.upgrade_27_30.report.helper.BannerSupportHelper + change: |- + The change 2 + affected: |- + Affected 2 + remediation: + description: |- + Remediation description 2 + recipe: sbu30-upgrade-dependencies + contributors: + - "Fabian Krüger[@fabapp2]" + """; + + AutowireCapableBeanFactory beanFactory = mock(AutowireCapableBeanFactory.class); + ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + SimpleModule module = new SimpleModule("HelperModule"); + module.addDeserializer(SpringBootUpgradeReportSectionHelper.class, new SpringBootUpgradeReportSectionHelperDeserializer()); + module.addDeserializer(Condition.class, new ConditionDeserializer(objectMapper, beanFactory)); +// module.addDeserializer(SpringBootUpgradeReportAction.class, new SpringBootUpgradeReportActionDeserializer(objectMapper, beanFactory)); + objectMapper.registerModule(module); + + SpringBootUpgradeReportAction action = objectMapper.readValue(yaml, SpringBootUpgradeReportAction.class); + + assertThat(action.getSections().get(0).getHelper()).isInstanceOf(BannerSupportHelper.class); + } + + +} diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportTestSupport.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportTestSupport.java index 69b015b4d..55576b4d5 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportTestSupport.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportTestSupport.java @@ -17,6 +17,8 @@ import lombok.Getter; import lombok.Setter; +import org.springframework.sbm.boot.upgrade_27_30.report.yaml.SpringBootUpgradeReportActionDeserializer; +import org.springframework.sbm.boot.upgrade_27_30.report.yaml.SpringBootUpgradeReportYamlDeserializationConfiguration; import org.springframework.sbm.engine.context.ProjectContext; import org.springframework.sbm.engine.context.ProjectContextHolder; import org.springframework.sbm.engine.recipe.Recipe; @@ -25,7 +27,6 @@ import org.springframework.sbm.test.RecipeTestSupport; import org.springframework.sbm.testhelper.common.utils.TestDiff; import org.springframework.test.util.ReflectionTestUtils; -import org.stringtemplate.v4.ST; import java.nio.file.Path; import java.util.ArrayList; @@ -184,12 +185,26 @@ private void verify(Consumer assertion) { action.apply(builderData.getContext()); String renderedSection = sectionUnderTest.render(builderData.getContext()); String renderedSectionWithoutButtonCode = replaceRecipeButtonCodeFromExpectedOutput(sectionUnderTest, renderedSection); - - assertion.accept(renderedSectionWithoutButtonCode); + String renderedSectionWithGitHubInfo = removeGitHubInfoFromExpectedOutput(sectionUnderTest, renderedSectionWithoutButtonCode); + assertion.accept(renderedSectionWithGitHubInfo); }); } } + /** + * Adds the GitHub metadata section at the top of every section. + */ + private String removeGitHubInfoFromExpectedOutput(SpringBootUpgradeReportSection sectionUnderTest, String renderedSectionWithoutButtonCode) { + // if GitHub info is not given + StringBuilder sb = new StringBuilder(); + sectionUnderTest.renderGitHubInfo(sb); + if( ! renderedSectionWithoutButtonCode.startsWith("=== " + sectionUnderTest.getTitle() +"\n" + sb.toString())) { + fail("Missing GitHub info: " + sb.toString() + " rendered section was: \n " + renderedSectionWithoutButtonCode); + } + String asciidocTitle = "=== " + sectionUnderTest.getTitle() + "\n"; + return renderedSectionWithoutButtonCode.replace(asciidocTitle + sb.toString(), asciidocTitle); + } + /** * Another hack, removing the expected button code added to the Asciidoc to free tests from asserting invisible * code of buttons to apply a recipe. @@ -242,7 +257,8 @@ private void withRecipes(Consumer recipesConsumer) { SpringBootUpgradeReportActionDeserializer.class, SpringBootUpgradeReportFreemarkerSupport.class, SpringBootUpgradeReportFileSystemRenderer.class, - SpringBootUpgradeReportDataProvider.class + SpringBootUpgradeReportDataProvider.class, + SpringBootUpgradeReportYamlDeserializationConfiguration.class ); } diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationReportSectionTest.java index 5186bbf62..b4ceefcdf 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ActuatorEndpointsSanitizationReportSectionTest.java @@ -59,8 +59,7 @@ void shouldRender() { .fromProjectContext(context) .shouldRenderAs(""" === Actuator Endpoints Sanitization - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/445[#445^, role="ext-link"], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"] - + ==== What Changed Since, the `/env` and `/configprops` endpoints can contains sensitive values, all values are always masked by default. This used to be case only for keys considered to be sensitive. diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportReportSectionTest.java index 13e2a3494..9dfb21b02 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportReportSectionTest.java @@ -39,8 +39,7 @@ public void rendersBannerSupportInformation() { .shouldRenderAs( """ === Banner support - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/150[#150^, role="ext-link"], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"], https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] - + ==== What Changed Support for image-based application banners has been removed. banner.gif, banner.jpg, and banner.png files are now ignored and should be replaced with a text-based banner.txt file. diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java index 496abeb70..eaa6f8c34 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesReportSectionTest.java @@ -44,7 +44,6 @@ void changesToDataPropertiesSection_renders() { .shouldRenderAs( """ === Changes to Data Properties - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/441[#441^, role="ext-link"], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"] ==== What Changed The data prefix has been reserved for Spring Data and any properties under the `spring.data` prefix imply that Spring diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelperTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelperTest.java index 507104dfc..8434fbc01 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelperTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/CommonsMultipartResolverHelperTest.java @@ -55,7 +55,6 @@ public CommonsMultipartResolver commonsMultipartResolver() { .shouldRenderAs( """ === Commons Multipart Upload - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/541[#541^, role="ext-link"], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] ==== What Changed Support for Spring Framework’s `CommonsMultipartResolver` has been removed following its removal in Spring Framework 6 @@ -121,7 +120,6 @@ public CommonsMultipartResolver songMultiPartUploader() { .shouldRenderAs( """ === Commons Multipart Upload - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/541[#541^, role="ext-link"], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] ==== What Changed Support for Spring Framework’s `CommonsMultipartResolver` has been removed following its removal in Spring Framework 6 diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingReportSectionTest.java index b136cde17..5e76ca1c5 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ConstructorBindingReportSectionTest.java @@ -72,7 +72,6 @@ public String getFrom() { .shouldRenderAs( """ === Constructor Binding - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/166[#166^, role="ext-link"], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] ==== What Changed When using constructor bound @ConfigurationProperties the @ConstructorBinding annotation diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java index cb53126a0..2d3ec0c27 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/LoggingDateFormatReportSectionTest.java @@ -42,7 +42,6 @@ void shouldRenderSectionWhenNoPropertiesExist() { .shouldRenderAs( """ === Logging Date Format - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/489[#489^, role="ext-link"], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"] ==== What Changed The default format for the date and time component of log messages for Logback and Log4j2 has changed to @@ -75,7 +74,6 @@ void shouldRenderSectionWhenPropertyNotDefined() { .shouldRenderAs( """ === Logging Date Format - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/489[#489^, role="ext-link"], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"] ==== What Changed The default format for the date and time component of log messages for Logback and Log4j2 has changed to diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelperTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelperTest.java index 33939e7f6..f8da2e444 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelperTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/PagingAndSortingHelperTest.java @@ -58,7 +58,6 @@ public class A {} .shouldRenderAs( """ === Paging and sorting repository - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/518[#518^, role="ext-link"], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] ==== What Changed Sorting repositories no longer extend their respective CRUD repository. @@ -119,7 +118,6 @@ public class A {} .shouldRenderAs( """ === Paging and sorting repository - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/518[#518^, role="ext-link"], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] ==== What Changed Sorting repositories no longer extend their respective CRUD repository. @@ -180,7 +178,6 @@ public class A {} .shouldRenderAs( """ === Paging and sorting repository - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/518[#518^, role="ext-link"], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] ==== What Changed Sorting repositories no longer extend their respective CRUD repository. @@ -268,7 +265,6 @@ public class A {} .shouldRenderAs( """ === Paging and sorting repository - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/518[#518^, role="ext-link"], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] ==== What Changed Sorting repositories no longer extend their respective CRUD repository. diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesReportSectionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesReportSectionTest.java index 623b7fa88..f9751fd1c 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesReportSectionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/SpringMVCAndWebFluxUrlMatchingChangesReportSectionTest.java @@ -67,7 +67,6 @@ public class AnotherClass {}; String expectedOutput = """ === Spring MVC and WebFlux URL matching changes - Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/522[#522^, role="ext-link"], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"] ==== What Changed As of Spring Framework 6.0, the trailing slash matching configuration option has been deprecated and its default value set to `false`. diff --git a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/conditions/IsSpringBootProject.java b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/conditions/IsSpringBootProject.java index a0aad1bd9..eb7735f06 100644 --- a/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/conditions/IsSpringBootProject.java +++ b/components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/conditions/IsSpringBootProject.java @@ -36,7 +36,7 @@ public void setVersionPattern(String versionPattern) { @Override public String getDescription() { - return null; + return "Checks if scanned project is Spring Boot project"; } @Override diff --git a/pom.xml b/pom.xml index ca5e7181a..a13e86514 100644 --- a/pom.xml +++ b/pom.xml @@ -32,8 +32,7 @@ - scm:git:https://github.com/spring-projects-experimental/spring-boot-migrator.git - + scm:git:https://github.com/spring-projects-experimental/spring-boot-migrator.git scm:git:https://github.com/spring-projects-experimental/spring-boot-migrator https://github.com/spring-projects-experimental/spring-boot-migrator 0.13.0 @@ -370,11 +369,10 @@ maven-release-plugin 3.0.0-M7 - scm:git:https://github.com/spring-projects-experimental/spring-boot-migrator.git - + scm:git:https://github.com/spring-projects-experimental/spring-boot-migrator.git true @{project.version} - release +