Test category
+Checks the greeting name length
+diff --git a/com.avaloq.tools.ddk.check.core.test/resource/com/avaloq/tools/ddk/check/core/test/docgen/ExecutionEnvironment.check b/com.avaloq.tools.ddk.check.core.test/resource/com/avaloq/tools/ddk/check/core/test/docgen/ExecutionEnvironment.check new file mode 100644 index 0000000000..f05da22ca7 --- /dev/null +++ b/com.avaloq.tools.ddk.check.core.test/resource/com/avaloq/tools/ddk/check/core/test/docgen/ExecutionEnvironment.check @@ -0,0 +1,25 @@ +package com.avaloq.tools.ddk.check.validation + +import com.avaloq.tools.ddk.check.testLanguage.Greeting + +catalog ExecutionEnvironment +for grammar com.avaloq.tools.ddk.check.TestLanguage { + + category DefaultCategory "Test category" { + + /** Checks the greeting name length */ + onSave error GreetingNameLength "Greeting name length" (String defaultName = "Franz") + message "Greeting name {0}" { + + for Greeting g { + if (g.name.length > 5) { + issue bind ("too long") data namelength (null) + } else if (g.name.equals(defaultName)) { + issue bind ("must not be Franz") data franzname (null) + } + } + + } + + } +} diff --git a/com.avaloq.tools.ddk.check.core.test/resource/com/avaloq/tools/ddk/check/core/test/docgen/ExecutionEnvironment.html b/com.avaloq.tools.ddk.check.core.test/resource/com/avaloq/tools/ddk/check/core/test/docgen/ExecutionEnvironment.html new file mode 100644 index 0000000000..2a754921cf --- /dev/null +++ b/com.avaloq.tools.ddk.check.core.test/resource/com/avaloq/tools/ddk/check/core/test/docgen/ExecutionEnvironment.html @@ -0,0 +1,171 @@ + + +
+ + +Checks the greeting name length
+Check catalog for com.avaloq.tools.ddk.check.TestLanguage
+ +Warning to indicate that this catalog is active.
+Test formal parameter access.
+The {@code ExecutionEnvironment.check} and {@code LibraryChecks.check} fixtures and the + * expected output snapshots are verbatim copies of the committed artifacts in + * {@code com.avaloq.tools.ddk.check.test.runtime} (sources under {@code src/} and the generated + * snapshot under {@code docs/}). This test parses the catalogs in-memory, runs the generators + * and asserts byte-identical output against those golden files, guarding the migrated generators + * against regressions. It runs in a normal CI test run (no {@code eclipse-run}, no Maven profile).
+ */ +@InjectWith(CheckInjectorProvider.class) +@ExtendWith(InjectionExtension.class) +@SuppressWarnings("nls") +public class CheckDocGenerationTest extends AbstractCheckTestCase { + + /** Folder (relative to this class' package) holding the input fixtures and golden snapshots. */ + private static final String FIXTURES = "docgen/"; + + @Inject + private CheckGenerator generator; + + @Inject + private CheckDocumentationTemplates templates; + + @Inject + private Injector injector; + + @Override + protected Injector getInjector() { + return injector; + } + + /** + * The per-catalog HTML page emitted by {@link CheckGenerator#compileDoc(CheckCatalog)} must match + * the committed golden snapshot for each catalog. + */ + @Test + public void testCompileDocMatchesGolden() { + final XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); + final CheckCatalog executionEnvironment = parse(resourceSet, "ExecutionEnvironment.check"); + final CheckCatalog libraryChecks = parse(resourceSet, "LibraryChecks.check"); + + assertGolden("ExecutionEnvironment.html", generator.compileDoc(executionEnvironment)); + assertGolden("LibraryChecks.html", generator.compileDoc(libraryChecks)); + } + + /** + * The aggregated {@code toc.xml} and {@code contexts.xml} emitted by + * {@link CheckDocumentationTemplates} across both catalogs must match the committed golden snapshot. + */ + @Test + public void testCompileTocAndContextsMatchGolden() { + final XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class); + final List"); + builder.append(sorted.size(), " "); + builder.append(" catalog"); + if (sorted.size() != 1) { + builder.append("s"); + } + builder.append(" documented.
"); + builder.newLineIfNotEmpty(); + builder.append(" "); + builder.append(""); + builder.append(description, " "); + builder.append("
"); + builder.newLineIfNotEmpty(); + } + builder.append(" "); + builder.append(""); + builder.append(formattedDescription, " "); + builder.append("
"); + builder.newLineIfNotEmpty(); + } + if (!catalog.getChecks().isEmpty() || !catalog.getCategories().isEmpty()) { + builder.append(" "); + builder.append(""); + builder.newLine(); + } + builder.append(" "); + builder.append(""); + builder.append(formattedCategoryDescription, " "); + builder.append("
"); + builder.newLineIfNotEmpty(); + } + for (final Check check : category.getChecks()) { + builder.append(" "); + builder.append(checkArticle(check), " "); + builder.newLineIfNotEmpty(); + } + builder.append("«formattedDescription»
- «ENDIF» - «body» - - - - ''' - - def bodyDoc(CheckCatalog catalog)''' - «FOR check:catalog.checks» -Message: «check.message.replacePlaceholder»
Message: «check.message.replacePlaceholder»
-Message: Greeting name ...
-Checks the greeting name length
+Check catalog for com.avaloq.tools.ddk.check.TestLanguage
-Message: Catalog is active
-Message: Cache was not injected
-Message: ...
-Message: ...
-Check catalog for com.avaloq.tools.ddk.check.TestLanguage
+ +Warning to indicate that this catalog is active.
+Test formal parameter access.
+2 catalogs documented.
+Check catalog for com.avaloq.tools.ddk.check.TestLanguage
+Checks the greeting name length
+Warning to indicate that this catalog is active.
+Test formal parameter access.
+2 catalogs documented.
+