Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public BjoernClassesToBuild build(Bjoern bjoern) {

private void addJavaDoc(Bjoern bjoern, Builder featureClassBuilder) {
StringBuilder javadoc = new StringBuilder(bjoern.getFeature());
if (StringUtils.isNotBlank(bjoern.getVersion())) {
javadoc.append("\n@version ").append(bjoern.getVersion());
}
if (StringUtils.isNotBlank(bjoern.getReference())) {
javadoc.append("\n@see ").append(bjoern.getReferenceAsJavadoc());
}
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/de/mehtrick/bjoern/parser/modell/Bjoern.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ public class Bjoern {
private static final Pattern MARKDOWN_LINK_PATTERN = Pattern.compile("\\[([^\\]]+)\\]\\(([^)]+)\\)");

private String feature;
private String version;
private String reference;
private BjoernBackground background;
private List<BjoernScenario> scenarios;
private String filePath;

public Bjoern(BjoernZGRModell yamlModell, String path) {
setFeature(yamlModell.getFeature());
setVersion(yamlModell.getVersion());
setReference(yamlModell.getReference());
setScenarios(yamlModell.getScenarios().stream().map(BjoernScenario::new).collect(Collectors.toList()));
setFilePath(path);
Expand All @@ -40,6 +42,14 @@ public void setFeature(String feature) {
this.feature = feature;
}

public String getVersion() {
return this.version;
}

public void setVersion(String version) {
this.version = version;
}

public String getReference() {
return this.reference;
}
Expand Down Expand Up @@ -126,6 +136,6 @@ public void setFilePath(String filePath) {


public String toString() {
return "Bjoern(feature=" + this.getFeature() + ", reference=" + this.getReference() + ", background=" + this.getBackground() + ", scenarios=" + this.getScenarios() + ", filePath=" + this.getFilePath() + ")";
return "Bjoern(feature=" + this.getFeature() + ", version=" + this.getVersion() + ", reference=" + this.getReference() + ", background=" + this.getBackground() + ", scenarios=" + this.getScenarios() + ", filePath=" + this.getFilePath() + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "Feature", "Reference", "Scenarios" })
@JsonPropertyOrder({ "Feature", "Version", "Reference", "Scenarios" })
public class BjoernZGRModell implements Serializable {

@JsonProperty("Feature")
private String feature;

@JsonProperty("Version")
private String version;

@JsonProperty("Reference")
private String reference;

Expand All @@ -41,6 +44,16 @@ public void setFeature(String feature) {
this.feature = feature;
}

@JsonProperty("Version")
public String getVersion() {
return version;
}

@JsonProperty("Version")
public void setVersion(String version) {
this.version = version;
}

@JsonProperty("Reference")
public String getReference() {
return reference;
Expand Down Expand Up @@ -72,6 +85,6 @@ public void setBackground(BjoernZGRBackground background) {
}

public String toString() {
return "BjoernZGRModell(feature=" + this.getFeature() + ", reference=" + this.getReference() + ", background=" + this.getBackground() + ", bjoernZGRScenarios=" + this.bjoernZGRScenarios + ")";
return "BjoernZGRModell(feature=" + this.getFeature() + ", version=" + this.getVersion() + ", reference=" + this.getReference() + ", background=" + this.getBackground() + ", bjoernZGRScenarios=" + this.bjoernZGRScenarios + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public enum BjoernKeywords {

GIVEN("Given:"), WHEN("When:"), THEN("Then:"), BACKGROUND("Background:"), FEATURE("Feature:"), REFERENCE("Reference:"), SCENARIO("- Scenario:"), SCENARIOS("Scenarios:"), STATEMENT("-");
GIVEN("Given:"), WHEN("When:"), THEN("Then:"), BACKGROUND("Background:"), FEATURE("Feature:"), VERSION("Version:"), REFERENCE("Reference:"), SCENARIO("- Scenario:"), SCENARIOS("Scenarios:"), STATEMENT("-");

public String keyword;

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/asciidoc.ftlh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
= ${feature}
:toc:

<#if version??>
Version: ${version}

</#if>
<#if referenceAsAsciidoc?? && referenceAsAsciidoc?has_content>
Reference: ${referenceAsAsciidoc}

Expand Down
11 changes: 11 additions & 0 deletions src/test/java/de/mehtrick/bjoern/asciidoc/AsciiDocBuildTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ public void testDocGeneration() throws IOException, BjoernMissingPropertyExcepti
BjoernDocApplication.main(new String[]{"path=src/test/resources/bjoern.zgr", "docdir=src/gen/resources"});
}

@Test
@DisplayName("Test Doc Generation with Version")
public void testDocGenerationWithVersion() throws IOException, BjoernMissingPropertyException, NotSupportedJunitVersionException {
BjoernDocApplication.main(new String[]{"path=src/test/resources/version.zgr", "docdir=src/gen/resources"});
File generatedFile = new File("src/gen/resources/version.adoc");
assertThat(generatedFile).exists();
String content = new String(Files.readAllBytes(generatedFile.toPath()), StandardCharsets.UTF_8);
assertThat(content).contains("= Test mit Version");
assertThat(content).contains("Version: 1.0.0");
}

@Test
@DisplayName("Test Doc Generation with Reference")
public void testDocGenerationWithReference() throws IOException, BjoernMissingPropertyException, NotSupportedJunitVersionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,16 @@ void testJavadocWithReference() {
Assertions.assertThat(mappedFeature.javadoc.toString()).contains("<a href=\"https://example.com/TICKET-123\">TICKET-123</a>");
}

@Test
void testJavadocWithVersion() {
//given
bjoern = getBjoern("src/test/resources/version.zgr");
//when
TypeSpec mappedFeature = new BjoernFeatureTestClassBuilder(bjoernCodeGeneratorConfig).build(bjoern).getFeatureClass();
//then
Assertions.assertThat(mappedFeature.javadoc.toString()).contains("Test mit Version");
Assertions.assertThat(mappedFeature.javadoc.toString()).contains("@version");
Assertions.assertThat(mappedFeature.javadoc.toString()).contains("1.0.0");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public void testInvalidKeyword() {
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:,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!");
).withMessageContaining("ValidationError at line 1: The line starts with an invalid Keyword. Found \" WrongKeyword \". Allowed Keywords are: Given:,When:,Then:,Background:,Feature:,Version:,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:,Version:,Reference:,- Scenario:,Scenarios:,-. This check is case-sensitive!");
}

@Test
Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/version.zgr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Test mit Version
Version: "1.0.0"
Scenarios:
- Scenario: Einfaches Szenario
Given:
- Ein Benutzer
When:
- Benutzer tut etwas
Then:
- Ergebnis ist korrekt
Loading