Here is the complete HTML translated into French, with the language set to `fr` and the FR link marked as active. The title includes `[FR]` as requested. ```html #292 : GroovyEngineTest.java [FR]
EN · DE · RU · FR · ES

#292 : GroovyEngineTest.java

plugins/org.projectforge.plugins.todo/src/test/java/org/projectforge/plugins/todo/GroovyEngineTest.java Type : Java · Rôle : Test · Source : plugins/org.projectforge.plugins.todo/src/test/java/org/projectforge/plugins/todo/GroovyEngineTest.java 87 lignes · 56 code · 22 commentaires · 9 vides
Test unitaire/intégration pour GroovyEngine. Valide la correction du comportement de la classe de production correspondante.

Structure du code

Paquetage : org.projectforge.plugins.todo

Classes : GroovyEngineTest

Étend : AbstractTestBase

Méthodes (3) : renderTest, mailTemplateTest, preprocesTest

Champs (1) : configurationService

Importations : 13 paquetages

Code source (abrégé)

package org.projectforge.plugins.todo;

import org.junit.jupiter.api.Test;
import org.projectforge.ProjectForgeVersion;
import org.projectforge.business.configuration.ConfigurationService;
import org.projectforge.business.scripting.GroovyEngine;
import org.projectforge.common.i18n.Priority;
import org.projectforge.framework.persistence.history.FlatDisplayHistoryEntry;
import org.projectforge.framework.persistence.user.entities.PFUserDO;
import org.projectforge.business.test.AbstractTestBase;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Locale;
import java.util.TimeZone;

import static org.junit.jupiter.api.Assertions.*;

public class GroovyEngineTest extends AbstractTestBase {
  @Autowired
  private ConfigurationService configurationService;

  @Test
  public void renderTest() {
    final GroovyEngine engine = new GroovyEngine(configurationService, Locale.GERMAN, TimeZone.getTimeZone("UTC"));
    engine.putVariable("name", "Kai");

    final String res = engine.executeTemplate("Hallo $name, your locale is '<%= pf.getI18nString(\"locale.de\") %>'.");
    assertEquals("Hallo Kai, your locale is 'Deutsch'.", res);
    assertEquals("Hallo Kai, your locale is 'Deutsch'. " + ProjectForgeVersion.APP_ID + "\n Finished: Englisch", engine
            .executeTemplateFile("scripting/template.txt"));
  }

  @Test
  public void mailTemplateTest() {
    final GroovyEngine engine = new GroovyEngine(configurationService, Locale.GERMAN, TimeZone.getTimeZone("UTC"));
    PFUserDO user = new PFUserDO();
    user.setFirstname("Kai");
    user.setLastname("Reinhard");
    user.setLocale(Locale.GERMAN);
    engine.putVariable("recipient", user);
    ToDoDO todo = new ToDoDO();
    todo.setType(ToDoType.IMPROVEMENT);
    todo.setPriority(Priority.HIGH);
    todo.setReporter(user);
    todo.setAssignee(user);
    engine.putVariable("todo", todo);
    engine.putVariable("title", "ToDo");
    engine.putVariable("history", new ArrayList<FlatDisplayHistoryEntry>());
    engine.putVariable("requestUrl", "https://localhost:8443/wa/toDoEditPage/id/42");
    final String result = engine.executeTemplateFile("mail/todoChangeNotification.html");
    assertTrue(result.contains("hoch"), "I18n priority attendue.");
    assertTrue(result.contains("Verbesserung"), "Clé I18n pour le type d'amélioration attendue.");
  }

  @Test
  public void preprocesTest() {
    final GroovyEngine engine = new GroovyEngine(configurationService, Locale.GERMAN, TimeZone.getTimeZone("UTC"));
    assertNull(engine.preprocessGroovyXml(null));
    assertEquals("", engine.preprocessGroovyXml(""));
    assertEquals("<% if (value != null) { %>", engine.preprocessGroovyXml("<groovy>if (value != null) {</groovy>"));
    assertEquals("<%= value %>", engine.preprocessGroovyXml("<groovy-out>value</groovy-out>"));
  }
}

Historique Git

868d6abb7 2025 -> 2026
63081666f En-têtes de fichiers source : 2024 -> 2025.
176cb32d7 WIP : Gradle
d18c899b5 Refonte des entrées d'historique, FlatDisplayHistoryEntries et DisplayHistoryEntries...
b6092df09 Droits d'auteur 2023 -> 2024