Decouple TXT Report file writing and formatting logic (2/6) 67/109367/3
authorFrancis Toth <francis.toth@yoppworks.com>
Thu, 18 Jun 2020 19:23:12 +0000 (15:23 -0400)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Sun, 21 Jun 2020 07:05:18 +0000 (07:05 +0000)
This commit aims to move the reportStartValidatorRun function's logic from ReportManager (deprecated) to ReportFile.

Signed-off-by: Francis Toth <francis.toth@yoppworks.com>
Change-Id: I93c2e8f98cdef598094647d734d0deec0f1941db
Issue-ID: SDC-2499

asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFile.java
asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java

index d6a5d12..967a6c6 100644 (file)
@@ -88,7 +88,7 @@ public class TopologyTemplateValidatorExecuter {
         TXTFile reportFile,
         String outputFilePath
     ) {
-        ReportManager.reportStartValidatorRun(getName(), vertices.size(), outputFilePath);
+        reportFile.reportStartValidatorRun(getName(), vertices.size());
         Set<String> failedTasks = new HashSet<>();
         Set<String> successTasks = new HashSet<>();
         boolean successAllVertices = true;
index 8b76766..936ec4b 100644 (file)
@@ -58,6 +58,13 @@ public class ReportFile {
             writer.writeln("-----------------------Vertex: " + vertex.getUniqueId() +
                 ", Task " + taskName + " Started-----------------------");
         }
+
+        public void reportStartValidatorRun(String validatorName, int componentsNum) {
+            writer.writeln("");
+            writer.writeln("------ValidatorExecuter " +
+                validatorName + " Validation Started, on " +
+                componentsNum + " components---------");
+        }
     }
 
     /**
index 6e8e2de..63e7ebe 100644 (file)
@@ -90,13 +90,6 @@ public class ReportManager {
         writeReportLineToFile(sb.toString(), outputFilePath);
     }
 
-    public static void reportStartValidatorRun(String validatorName, int componenentsNum, String outputFilePath) {
-        StrBuilder sb = new StrBuilder();
-        sb.appendln("------ValidatorExecuter " + validatorName + " Validation Started, on " + componenentsNum
-            + " components---------");
-        writeReportLineToFile(sb.toString(), outputFilePath);
-    }
-
     public static void reportEndOfToolRun(Report report, String outputFilePath) {
         StrBuilder sb = new StrBuilder();
         sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------");
index 53e5668..479421e 100644 (file)
@@ -176,15 +176,16 @@ public class ReportManagerTest {
     @Test
     public void testReportStartValidatorRun() {
         // when
-        ReportManager.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM, txtReportFilePath);
-
-        List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
+        List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
+            file.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM);
+            return ReportFileNioHelper.readFileAsList(txtReportFilePath);
+        });
 
         // then
-        assertNotNull(reportOutputFile);
-        assertEquals(EXPECTED_OUTPUT_FILE_HEADER, reportOutputFile.get(0));
+        assertNotNull(reportTxtFile);
+        assertEquals(EXPECTED_OUTPUT_FILE_HEADER, reportTxtFile.get(0));
         assertEquals("------ValidatorExecuter " + VALIDATOR_NAME + " Validation Started, on "
-            + COMPONENT_SUM + " components---------", reportOutputFile.get(2));
+            + COMPONENT_SUM + " components---------", reportTxtFile.get(2));
     }
 
     @Test