Add optional Reference root field to Bjoern spec files#97
Conversation
Co-authored-by: Mehtrick <4493019+Mehtrick@users.noreply.github.com>
Reference root field to Bjoern spec files
There was a problem hiding this comment.
Pull request overview
Adds a new optional root-level Reference: field to .zgr spec files and propagates it through parsing, validation, code generation (Javadoc), and AsciiDoc documentation generation.
Changes:
- Extend the YAML model + domain model to include
Reference, with helpers to convert Markdown link syntax to Javadoc/AsciiDoc links. - Include
Reference:in keyword validation and update relevant tests/spec fixtures. - Render the reference in generated Javadoc (
@see …) and in the AsciiDoc template.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/resources/reference.zgr | Adds a fixture spec containing a Reference: Markdown link. |
| src/test/java/de/mehtrick/bjoern/parser/BjoernValidatorTest.java | Updates expected allowed-keyword list to include Reference:. |
| src/test/java/de/mehtrick/bjoern/generator/builder/BjoernFeatureTestClassBuilderTest.java | Adds a test asserting @see and HTML anchor appear in generated class Javadoc. |
| src/test/java/de/mehtrick/bjoern/asciidoc/AsciiDocBuildTest.java | Adds a smoke test for doc generation with a reference spec. |
| src/test/java/de/mehtrick/bjoern/BjoernParserTest.java | Adds tests for parsing and converting reference values (markdown, plain text, malformed, null). |
| src/main/resources/asciidoc.ftlh | Renders Reference: block in generated AsciiDoc. |
| src/main/java/de/mehtrick/bjoern/parser/validator/validations/BjoernKeywords.java | Adds REFERENCE("Reference:") to the validator keyword list. |
| src/main/java/de/mehtrick/bjoern/parser/modell/BjoernZGRModell.java | Adds Reference field mapping in the YAML POJO. |
| src/main/java/de/mehtrick/bjoern/parser/modell/Bjoern.java | Adds reference plus conversion helpers for Javadoc and AsciiDoc link formats. |
| src/main/java/de/mehtrick/bjoern/generator/builder/BjoernFeatureTestClassBuilder.java | Appends @see <reference> to generated abstract class Javadoc when present. |
| Assertions.assertThatExceptionOfType(BjoernValidatorException.class).isThrownBy(() -> { | ||
| bjoernValidator.validate(" WrongKeyword \r\n \r\n anotherWrongOne", "defaultpath"); | ||
| } | ||
| ).withMessageContaining("ValidationError at line 1: The line starts with an invalid Keyword. Found \" WrongKeyword \". Allowed Keywords are: Given:,When:,Then:,Background:,Feature:,- Scenario:,Scenarios:,-. This check is case-sensitive!") | ||
| .withMessageContaining("ValidationError at line 3: The line starts with an invalid Keyword. Found \" anotherWrongOne\". Allowed Keywords are: Given:,When:,Then:,Background:,Feature:,- Scenario:,Scenarios:,-. This check is case-sensitive!"); | ||
| ).withMessageContaining("ValidationError at line 1: The line starts with an invalid Keyword. Found \" WrongKeyword \". Allowed Keywords are: Given:,When:,Then:,Background:,Feature:,Reference:,- Scenario:,Scenarios:,-. This check is case-sensitive!") | ||
| .withMessageContaining("ValidationError at line 3: The line starts with an invalid Keyword. Found \" anotherWrongOne\". Allowed Keywords are: Given:,When:,Then:,Background:,Feature:,Reference:,- Scenario:,Scenarios:,-. This check is case-sensitive!"); |
There was a problem hiding this comment.
Now that Reference: is an allowed keyword, the validator should also reject an empty Reference: line (similar to Feature: / - Scenario:). Currently MissingNameValidation only checks FEATURE and SCENARIO, so Reference: with no value would pass validation. Add validation + a test case to ensure Reference: requires a non-empty value.
There was a problem hiding this comment.
Done in commit 260c458. MissingNameValidation now also checks Reference: — if the keyword is present but has no value after the colon, it throws the same validation error as Feature: and - Scenario:. Added missingReferenceValue() test to BjoernValidatorTest to cover this case.
Mehtrick
left a comment
There was a problem hiding this comment.
passe auch die README und ggf Copilot Instructions entsprechend an um den neuen Parameter
…tions to AsciiDoc test Co-authored-by: Mehtrick <4493019+Mehtrick@users.noreply.github.com>
Done in commit |
Co-authored-by: Mehtrick <4493019+Mehtrick@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…reTestClassBuilder.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Mehtrick <4493019+Mehtrick@users.noreply.github.com>
Adds a new optional
Referencefield at the root of.zgrspec files to associate tickets or external references with a spec. Supports plain text or markdown link syntax ([text](url)), which is automatically converted to appropriate hyperlinks in generated outputs.Spec format
Changes
BjoernZGRModell,Bjoern) — AddedReferencefield.BjoernexposesgetReferenceAsJavadoc()andgetReferenceAsAsciidoc()which convert markdown links to<a href>andlink:[]syntax respectively; plain text passes through unchanged. Link text and URLs are sanitized: HTML-escaped for Javadoc output, bracket-encoded for AsciiDoc URLs, and onlyhttp/httpsURL schemes are converted to hyperlinks (others fall back to plain text).BjoernFeatureTestClassBuilder) — Appends@see <reference>to the generated abstract class Javadoc when a reference is present. UsesaddJavadoc("$L", ...)literal to prevent JavaPoet from interpreting$characters in URLs as format specifiers.asciidoc.ftlh) — RendersReference: <link or text>below the feature title; omitted entirely when not set or blank (has_contentcheck).BjoernKeywords,MissingNameValidation) — AddedReference:as a recognised root-level keyword; aReference:line without a value is now rejected with a validation error (consistent withFeature:and- Scenario:).README.md,.github/copilot-instructions.md) — Updated spec format examples, generated Java/AsciiDoc output examples, and added description ofReferencefield behaviour (plain text and markdown link support).AsciiDocBuildTest,BjoernValidatorTest,BjoernParserTest) —testDocGenerationWithReferenceasserts the generated file exists and contains the expected feature title and AsciiDoc hyperlink;missingReferenceValueverifies that an emptyReference:line fails validation; new tests cover HTML-escaping, AsciiDoc URL passthrough, and non-http URL scheme fallback to plain text.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.