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 @@ -284,6 +284,7 @@ static String buildHtml(JsonNode root) {
String template = loadTemplate();

return template
.replace("{{REPORT_CSS}}", loadResource("report/report.css"))
.replace("{{RUN_SUMMARY}}", metadata[0])
.replace("{{METADATA}}", metadata[1])
.replace("{{PASSED}}", String.valueOf(passedTests))
Expand Down Expand Up @@ -1020,15 +1021,19 @@ private static String safeStr(JsonNode node, String field) {
}

private static String loadTemplate() {
return loadResource("report-template.html");
}

private static String loadResource(String name) {
try (InputStream is = HtmlReportGenerator.class
.getClassLoader()
.getResourceAsStream("report-template.html")) {
.getResourceAsStream(name)) {
if (is == null) {
throw new IllegalStateException("report-template.html not found in classpath");
throw new IllegalStateException(name + " not found in classpath");
}
return new String(is.readAllBytes(), StandardCharsets.UTF_8);
} catch (java.io.IOException e) {
throw new IllegalStateException("Failed to load report-template.html", e);
throw new IllegalStateException("Failed to load " + name, e);
}
}
}
Loading