EN · DE · RU · FR · ES

#346: SortAndCheckI18nPropertiesTest.kt

projectforge-application/src/test/kotlin/org/projectforge/development/SortAndCheckI18nPropertiesTest.kt Tipo: Kotlin · Rol: Prueba · Fuente: projectforge-application/src/test/kotlin/org/projectforge/development/SortAndCheckI18nPropertiesTest.kt 69 líneas · 39 código · 23 comentarios · 7 en blanco
Prueba unitaria/de integración para SortAndCheckI18nProperties. Valida la corrección del comportamiento de la clase de producción correspondiente.

Estructura del código

Anotaciones: Test

Clases: SortAndCheckI18nPropertiesTest

Funciones (3): fixApostrophCharsAndReplaceUTFCharTest, multilineHandlingTest, check

Propiedades (3): germanText, multiline, reducedMultiline

Importaciones: 2 paquetes

Paquete: org.projectforge.development

Código fuente (resumido)

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)"""
}

Historial de Git

868d6abb7 2025 -> 2026
63081666f Encabezados de archivos fuente: 2024-> 2025.
6995a945c Migración en progreso...
b6092df09 Derechos de autor 2023 -> 2024
ab45d51fa Derechos de autor 2001-2022 -> 2001-2023.