Skip to content

Commit ae950fb

Browse files
authored
Add support to SpringBootUpgradeReportTestSupport to verify that a section is not rendered
- Fix GitHub issue for report section - Trim left when creating bulletlists with freemarker
1 parent 7923d5f commit ae950fb

File tree

5 files changed

+156
-276
lines changed

5 files changed

+156
-276
lines changed

components/sbm-recipes-boot-upgrade/report.html

Lines changed: 0 additions & 174 deletions
This file was deleted.

components/sbm-recipes-boot-upgrade/src/main/resources/recipes/boot-new-report.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@
8181
The scan found properties with `spring.data` prefix but no dependency matching `org.springframework.data:.*`.
8282
8383
<#list matches as match>
84-
* file://${match.absolutePath}[`${match.relativePath}`]
84+
* file://${match.absolutePath}[`${match.relativePath}`]<#lt>
8585
<#list match.propertiesFound as property>
86-
** `${property}`
86+
** `${property}`<#lt>
8787
</#list>
8888
</#list>
8989
9090
remediation: |-
9191
Either add `spring-data` dependency, rename the property or remove it in case it's not required anymore.
92-
gitHubIssue: 123
92+
gitHubIssue: 441
9393
recipe: boot-2.7-3.0-upgrade-report
9494
contributors:
9595
- "Fabian Krüger[@fabapp2]"

components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/ChangesToDataPropertiesReportTest.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.sbm.boot.upgrade_27_30.report;
1717

18+
import org.assertj.core.api.Assertions;
1819
import org.junit.jupiter.api.DisplayName;
1920
import org.junit.jupiter.api.Test;
2021
import org.springframework.sbm.boot.properties.SpringApplicationPropertiesPathMatcher;
@@ -31,8 +32,8 @@
3132
public class ChangesToDataPropertiesReportTest {
3233

3334
@Test
34-
@DisplayName("Changes to Data Properties")
35-
void changesToDataPropertiesSection() {
35+
@DisplayName("Changes to Data Properties should render")
36+
void changesToDataPropertiesSection_renders() {
3637
ProjectContext context = TestProjectContext.buildProjectContext()
3738
.addRegistrar(new SpringBootApplicationPropertiesRegistrar(new SpringApplicationPropertiesPathMatcher()))
3839
.addProjectResource("src/main/resources/application.properties", "spring.data.foo=bar")
@@ -44,7 +45,7 @@ void changesToDataPropertiesSection() {
4445
.shouldRenderAs(
4546
"""
4647
=== Changes to Data Properties
47-
Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/123[#123], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"]
48+
Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/441[#441], Contributors: https://github.com/fabapp2[@fabapp2^, role="ext-link"]
4849
4950
==== What Changed
5051
The data prefix has been reserved for Spring Data and any properties under the `data` prefix imply that Spring
@@ -53,10 +54,10 @@ void changesToDataPropertiesSection() {
5354
==== Why is the application affected
5455
The scan found properties with `spring.data` prefix but no dependency matching `org.springframework.data:.*`.
5556
56-
* file://<PATH>/src/main/resources/application.properties[`src/main/resources/application.properties`]
57-
** `spring.data.foo`
58-
* file://<PATH>/src/main/resources/application-another.properties[`src/main/resources/application-another.properties`]
59-
** `spring.data.here`
57+
* file://<PATH>/src/main/resources/application.properties[`src/main/resources/application.properties`]
58+
** `spring.data.foo`
59+
* file://<PATH>/src/main/resources/application-another.properties[`src/main/resources/application-another.properties`]
60+
** `spring.data.here`
6061
6162
==== Remediation
6263
Either add `spring-data` dependency, rename the property or remove it in case it's not required anymore.
@@ -65,4 +66,18 @@ void changesToDataPropertiesSection() {
6566
.of(".").toAbsolutePath().resolve(TestProjectContext.getDefaultProjectRoot()).toString()));
6667
}
6768

69+
@Test
70+
@DisplayName("Changes to Data Properties shouldn't render")
71+
void changesToDataPropertiesSection_notRendered() {
72+
ProjectContext context = TestProjectContext.buildProjectContext()
73+
.addRegistrar(new SpringBootApplicationPropertiesRegistrar(new SpringApplicationPropertiesPathMatcher()))
74+
.addProjectResource("src/main/resources/application.properties", "data.foo=bar")
75+
.addProjectResource("src/main/resources/application-another.properties", "data.here=there")
76+
.build();
77+
78+
SpringBootUpgradeReportTestSupport.generatedSection("Changes to Data Properties")
79+
.fromProjectContext(context)
80+
.shouldNotRender();
81+
}
82+
6883
}

0 commit comments

Comments
 (0)