EN · DE · RU · FR · ES

#346: SortAndCheckI18nPropertiesTest.kt

projectforge-application/src/test/kotlin/org/projectforge/development/SortAndCheckI18nPropertiesTest.kt Type: Kotlin · Role: Test · Source: projectforge-application/src/test/kotlin/org/projectforge/development/SortAndCheckI18nPropertiesTest.kt 69 lines · 39 code · 23 comments · 7 blank
Unit/integration test for SortAndCheckI18nProperties. Validates correctness of the corresponding production class behavior.

Code Structure

Annotations: Test

Classes: SortAndCheckI18nPropertiesTest

Functions (3): fixApostrophCharsAndReplaceUTFCharTest, multilineHandlingTest, check

Properties (3): germanText, multiline, reducedMultiline

Imports: 2 packages

Package: org.projectforge.development

Source Code (abridged)

package org.projectforge.development

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

class SortAndCheckI18nPropertiesTest {
  @Test
  fun fixApostrophCharsAndReplaceUTFCharTest() {
    check("", "")
    check("'", "'")
    check("'text", "'text")
    check("text'", "text'")
    check("Don't believe the hype.", "Don't believe the hype.")
    check("Don''t believe the hype.", "Don''t believe the hype.")
    check("Don''t escape '{0}'.", "Don't escape '{0}'.")
    check("Field ''\${label}'' is", "Field ''\${label}'' is")
    val germanText = "Dies ist ein gültiger Deutscher Text mit allen Umlauten: äöüÄÖÜß"
    check(
      "Dies ist ein gültiger Deutscher Text mit allen Umlauten: äöüÄÖÜß",
      germanText
    )
  }

  @Test
  fun multilineHandlingTest() {
    assertEquals("", SortAndCheckI18nPropertiesMain.reduceMultiLine(""))
    assertEquals("test", SortAndCheckI18nPropertiesMain.reduceMultiLine("test"))
    assertEquals("test... (multiline)", SortAndCheckI18nPropertiesMain.reduceMultiLine("test\\\nline 2"))
    // println(multiline)
    assertEquals(reducedMultiline, SortAndCheckI18nPropertiesMain.reduceMultiLine(multiline))

    assertEquals("", SortAndCheckI18nPropertiesMain.commentMultiLine(""))
    assertEquals("test", SortAndCheckI18nPropertiesMain.commentMultiLine("test"))
    assertEquals("test\\\n#line 2", SortAndCheckI18nPropertiesMain.commentMultiLine("test\\\nline 2"))
  }

  private fun check(expected: String, src: String) {
    assertEquals(expected, SortAndCheckI18nPropertiesMain.fixApostrophCharsAndReplaceUTFChars(src))
  }

  private val multiline =
    """### Two factor authentication\n\n1. Simply scan this barcode with your smartphone.\n\
2. Your authenticator app should be opened.\n3. Done.\n\nEvery time ProjectForge requests a code, enter the displayed code in your Authenticator app.\n\nYou may setup others Authenticator apps on different devices as a backup, if you want.\n\n> 2FA are valid up to 30 days (depends on the security level of the used functionality), please use the stay-logge-in functionality on login to prevent annoying 2FA requests.\n"""
  private val reducedMultiline =
    """### Two factor authentication\n\n1. Simply scan this barcode with your smartphone.\n... (multiline)"""
}

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
6995a945c Migration stuff in progress...
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.