From 8c6ad373281722ce410a1108c67de5f1adf350ea Mon Sep 17 00:00:00 2001 From: Francis Toth Date: Thu, 18 Jun 2020 15:46:31 -0400 Subject: Decouple TXT Report file writing and formatting logic (5/6) This commit aims to move the reportEndOfToolRun function from ReportManager (deprecated) to ReportFile. Signed-off-by: Francis Toth Change-Id: I17731864c34ed9a70b1b1e91b89bad835dc72449 Issue-ID: SDC-2499 --- .../sdc/asdctool/impl/validator/report/ReportFile.java | 15 +++++++++++++++ .../sdc/asdctool/impl/validator/utils/ReportManager.java | 12 ------------ .../org/openecomp/sdc/asdctool/main/ValidationTool.java | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'asdctool/src/main/java/org') diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFile.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFile.java index b22edb6cee..b483964a6e 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFile.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFile.java @@ -95,6 +95,21 @@ public class ReportFile { writer.writeln(""); writer.write(sb.toString()); } + + public void reportEndOfToolRun(Report report) { + StrBuilder sb = new StrBuilder(); + sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------"); + report.forEachFailure((taskName, failedVertices) -> { + sb.append("Task: ") + .append(taskName) + .appendNewLine() + .append("FailedVertices: ") + .append(String.valueOf(failedVertices)) + .appendNewLine(); + }); + writer.writeln(""); + writer.write(sb.toString()); + } } /** diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java index a733eec38b..9b09e67c39 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java @@ -68,16 +68,4 @@ public class ReportManager { log.info("write to file failed - {}", e.getClass().getSimpleName(), e); } } - - public static void reportEndOfToolRun(Report report, String outputFilePath) { - StrBuilder sb = new StrBuilder(); - sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------"); - report.forEachFailure((taskName, failedVertices) -> { - sb.append("Task: " + taskName); - sb.appendNewLine(); - sb.append("FailedVertices: " + failedVertices); - sb.appendNewLine(); - }); - writeReportLineToFile(sb.toString(), outputFilePath); - } } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java index d84f0a5d69..3bffa0b5e2 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java @@ -59,7 +59,7 @@ public class ValidationTool { log.info("Start Validation Tool"); Report report = Report.make(); boolean result = validationToolBL.validateAll(report, textFile, txtReportFilePath); - ReportManager.reportEndOfToolRun(report, txtReportFilePath); + textFile.reportEndOfToolRun(report); csvFile.printAllResults(report); if (result) { log.info("Validation finished successfully"); -- cgit 1.2.3-korg