fix(backend): Format

This commit is contained in:
2026-02-16 19:30:49 +01:00
parent 987f4efffe
commit fed3a2e574
4 changed files with 25 additions and 19 deletions

View File

@@ -23,7 +23,6 @@ class InitialApplicationFormSeeder(
private val versionService: ApplicationFormVersionService,
private val splitYamlLoader: SplitYamlLoader,
) : ApplicationRunner {
override fun run(args: ApplicationArguments) {
seedInitialFormIfMissing()
}

View File

@@ -20,7 +20,6 @@ class InitialApplicationFormTemplateSeeder(
private val userRepository: UserRepository,
private val splitYamlLoader: SplitYamlLoader,
) : ApplicationRunner {
override fun run(args: ApplicationArguments) {
seedInitialTemplateIfMissing()
}

View File

@@ -40,7 +40,10 @@ class SplitYamlLoader {
return processIncludes(mainContent, baseDir)
}
private fun processIncludes(content: String, baseDir: String): String {
private fun processIncludes(
content: String,
baseDir: String,
): String {
val result = StringBuilder()
content.lines().forEach { line ->
@@ -61,17 +64,21 @@ class SplitYamlLoader {
return result.toString()
}
private fun indentContent(content: String, indent: String): String {
private fun indentContent(
content: String,
indent: String,
): String {
val lines = content.lines()
return lines.mapIndexed { index, line ->
when {
index == 0 -> "- $line" // First line gets the list marker
line.isBlank() -> line
else -> " $line" // Subsequent lines get extra indent for being inside list item
return lines
.mapIndexed { index, line ->
when {
index == 0 -> "- $line" // First line gets the list marker
line.isBlank() -> line
else -> " $line" // Subsequent lines get extra indent for being inside list item
}
}.joinToString("\n") { line ->
if (line.isBlank()) line else indent + line
}
}.joinToString("\n") { line ->
if (line.isBlank()) line else indent + line
}
}
private fun loadResource(resourcePath: String): String =

View File

@@ -4,14 +4,14 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
class SplitYamlLoaderTest {
@Test
fun `loads template form from split files`() {
val loader = SplitYamlLoader()
val form = assertDoesNotThrow {
loader.loadApplicationForm("seed/template/_main.yaml")
}
val form =
assertDoesNotThrow {
loader.loadApplicationForm("seed/template/_main.yaml")
}
assert(form.isTemplate == true) { "Form should be a template" }
assert(form.name == "Name des IT-Systems") { "Form name should match" }
@@ -23,9 +23,10 @@ class SplitYamlLoaderTest {
fun `loads demo form from split files`() {
val loader = SplitYamlLoader()
val form = assertDoesNotThrow {
loader.loadApplicationForm("seed/demo/_main.yaml")
}
val form =
assertDoesNotThrow {
loader.loadApplicationForm("seed/demo/_main.yaml")
}
assert(form.isTemplate == false) { "Form should not be a template" }
assert(form.name == "SAP S/4HANA") { "Form name should match" }