EN · DE · RU · FR · ES

#346: SortAndCheckI18nPropertiesTest.kt

projectforge-application/src/test/kotlin/org/projectforge/development/SortAndCheckI18nPropertiesTest.kt Тип: Kotlin · Роль: Тест · Источник: projectforge-application/src/test/kotlin/org/projectforge/development/SortAndCheckI18nPropertiesTest.kt 69 строк · 39 кода · 23 комментария · 7 пустых
Модульный/интеграционный тест для SortAndCheckI18nProperties. Проверяет корректность поведения соответствующего производственного класса.

Структура кода

Аннотации: Test

Классы: SortAndCheckI18nPropertiesTest

Функции (3): fixApostrophCharsAndReplaceUTFCharTest, multilineHandlingTest, check

Свойства (3): germanText, multiline, reducedMultiline

Импорты: 2 пакета

Пакет: org.projectforge.development

Исходный код (сокращён)

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

868d6abb7 2025 -> 2026
63081666f Заголовки исходных файлов: 2024-> 2025.
6995a945c Работа над миграцией в процессе...
b6092df09 Авторское право 2023 -> 2024
ab45d51fa Авторское право 2001-2022 -> 2001-2023.