Skip to content

Commit e6a361d

Browse files
committed
Fix button div line separators
1 parent 2e819c8 commit e6a361d

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportSection.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ public class SpringBootUpgradeReportSection {
5151
private static final String GITHUB_ISSUE = "**Issue:** https://github.com/spring-projects-experimental/spring-boot-migrator/issues/%1$d[#%1$d^, role=\"ext-link\"] + %n";
5252
private static final String GITHUB_CONTRIBUTOR = "https://github.com/%1$s[@%1$s^, role=\"ext-link\"]";
5353
private static final String ls = System.lineSeparator();
54+
55+
public static final String BUTTON_CODE = """
56+
++++
57+
<div class="run-a-recipe" recipe="<RECIPE>">
58+
</div>
59+
++++
60+
""".replace("\n", System.lineSeparator());
61+
5462
/**
5563
* The spring project(s)/modules this change comes from.
5664
*
@@ -263,13 +271,7 @@ private void renderRecipeButton(StringBuilder sb, String recipe) {
263271
<span class="visually-hidden">Loading...</span>
264272
</button>
265273
*/
266-
String buttonCode = """
267-
++++
268-
<div class="run-a-recipe" recipe="<RECIPE>">
269-
</div>
270-
++++
271-
""";
272-
buttonCode = buttonCode.replace("<RECIPE>", recipe);
274+
String buttonCode = BUTTON_CODE.replace("<RECIPE>", recipe);
273275
sb.append(buttonCode);
274276
}
275277
}

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

+2-18
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public void shouldStartWith(@Language("adoc") String expectedOutput, Map<String,
104104
verify(assertion);
105105
}
106106

107-
108107
private Map<String, String> defaultMap() {
109108
String path = Path
110109
.of(".")
@@ -214,14 +213,7 @@ private String replaceRecipeButtonCodeFromExpectedOutput(SpringBootUpgradeReport
214213
if (sectionUnderTest.getRemediation().getPossibilities().isEmpty()) {
215214
String recipe = sectionUnderTest.getRemediation().getRecipe();
216215
if (recipe != null) {
217-
String target = """
218-
219-
++++
220-
<div class="run-a-recipe" recipe="<RECIPE>">
221-
</div>
222-
++++
223-
224-
""";
216+
String target = "%n%s%n".formatted(SpringBootUpgradeReportSection.BUTTON_CODE);
225217
buttonCodes.add(target.replace("<RECIPE>", recipe));
226218
}
227219
} else {
@@ -232,14 +224,7 @@ private String replaceRecipeButtonCodeFromExpectedOutput(SpringBootUpgradeReport
232224
.map(RemediationPossibility::getRecipe)
233225
.filter(Objects::nonNull)
234226
.map(recipe -> {
235-
String target = """
236-
237-
++++
238-
<div class="run-a-recipe" recipe="<RECIPE>">
239-
</div>
240-
++++
241-
242-
""";
227+
String target = "%n%s%n".formatted(SpringBootUpgradeReportSection.BUTTON_CODE);
243228
return target.replace("<RECIPE>", recipe);
244229
})
245230
.collect(Collectors.toList());
@@ -263,7 +248,6 @@ private void withRecipes(Consumer<Recipes> recipesConsumer) {
263248
}
264249

265250
private String replacePlaceHolders(String expectedOutput, Map<String, String> templateVariables) {
266-
StringBuffer sb = new StringBuffer();
267251
// hacked, there's most probably a better way but ST couldn't digest html code
268252
for (Map.Entry<String, String> kv : templateVariables.entrySet()) {
269253
String key = "<" + kv.getKey() + ">";

0 commit comments

Comments
 (0)