revert convert Object->String, causes NPE problems

This commit is contained in:
Michael Hoennig 2024-11-14 17:16:34 +01:00
parent e934726c4b
commit 6f702c82d5
4 changed files with 16 additions and 9 deletions

View File

@ -96,5 +96,5 @@ if [ ! -f .environment ]; then
fi
source .environment
alias scenario-reports-upload='./gradlew convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office'
alias scenario-reports-online='open https://hsngdev.hs-example.de/scenarios/office'
alias scenario-reports-upload='./gradlew scenarioTests convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm -f doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp build/doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office'
alias scenario-reports-open='open https://hsngdev.hs-example.de/scenarios/office'

View File

@ -233,7 +233,7 @@ dependencyCheck {
failBuildOnCVSS = 5
}
project.tasks.check.dependsOn(dependencyCheckAnalyze)
project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.md!
project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.txt!
println "OWASP Dependency Security Report: file:///${project.rootDir}/build/reports/dependency-check-report.html"
}
@ -268,7 +268,7 @@ jacocoTestReport {
])
}))
}
doFirst { // Why not doLast? See README.md!
doFirst { // Why not doLast? See README.txt!
println "HTML Jacoco Test Code Coverage Report: file://${reports.html.outputLocation.get()}/index.html"
}
}
@ -381,7 +381,7 @@ pitest {
timestampedReports = false
}
project.tasks.check.dependsOn(project.tasks.pitest)
project.tasks.pitest.doFirst { // Why not doLast? See README.md!
project.tasks.pitest.doFirst { // Why not doLast? See README.txt!
println "PiTest Mutation Report: file:///${project.rootDir}/build/reports/pitest/index.html"
}
@ -431,7 +431,7 @@ tasks.register('convertMarkdownToHtml') {
doLast {
// Gather all Markdown files in the current directory
fileTree(dir: '.', include: 'doc/scenarios/*.md').each { file ->
fileTree(dir: '.', include: 'build/doc/scenarios/*.md').each { file ->
// Corrected way to create the output file path
def outputFile = new File(file.parent, file.name.replaceAll(/\.md$/, '.html'))
@ -444,3 +444,4 @@ tasks.register('convertMarkdownToHtml') {
}
}
}
convertMarkdownToHtml.dependsOn scenarioTests

1
doc/scenarios/README.txt Normal file
View File

@ -0,0 +1 @@
move generated ScenarioReports to build-dir

View File

@ -19,7 +19,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class TestReport {
private final static File markdownLogFile = new File("doc/scenarios/.last-debug-log.md");
public static final File BUILD_DOC_SCENARIOS = new File("build/doc/scenarios");
private final static File markdownLogFile = new File(BUILD_DOC_SCENARIOS, ".last-debug-log.md");
public static final SimpleDateFormat MM_DD_YYYY_HH_MM_SS = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
private final Map<String, ?> aliases;
@ -28,6 +29,11 @@ public class TestReport {
private PrintWriter markdownReport; // records only the use-case under test, without its pre-requisites
private int silent; // do not print anything to test-report if >0
static {
assertThat(BUILD_DOC_SCENARIOS.isDirectory() || BUILD_DOC_SCENARIOS.mkdirs())
.as("mkdir " + BUILD_DOC_SCENARIOS).isTrue();
}
@SneakyThrows
public TestReport(final Map<String, ?> aliases) {
this.aliases = aliases;
@ -37,8 +43,7 @@ public class TestReport {
public void createTestLogMarkdownFile(final TestInfo testInfo) throws IOException {
final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow();
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue();
markdownReportFile = new File("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md");
markdownReportFile = new File(BUILD_DOC_SCENARIOS, testMethodOrder + "-" + testMethodName + ".md");
markdownReport = new PrintWriter(new FileWriter(markdownReportFile));
print("## Scenario #" + determineScenarioTitle(testInfo));
}