aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/main
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2019-07-03 08:27:48 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-07-22 12:12:22 +0000
commit4d8364e7ac25838c0aeabcd89af2e447c30d9426 (patch)
tree485b2c041fbe6116f44521c3c76d85550233cfe4 /asdctool/src/main
parentcf1372cca6cab85810dfcc7309983ba362e99a29 (diff)
Improved test for ReportManger, ArtifactValidationUtils and Sonar fixes.
Add new ReportManagerHelper to read files with reports. Fixed log.info to print the types of exception in the messages. Removed redundant new lines in the report files. Issue-ID: SDC-2327 Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com> Change-Id: If0135f01a05b0936dad681d16e846a6c6560cc80
Diffstat (limited to 'asdctool/src/main')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java49
1 files changed, 23 insertions, 26 deletions
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 64e3ba0ddb..2be8f921fa 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
@@ -3,13 +3,14 @@
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,15 +21,16 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
-import org.apache.commons.lang.text.StrBuilder;
-import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.*;
+
+import org.apache.commons.lang.text.StrBuilder;
+import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,7 +50,7 @@ public class ReportManager {
initCsvFile();
initReportFile();
} catch (IOException e) {
- log.info("Init file failed - {}" , e);
+ log.info("Init file failed - {}", e.getClass().getSimpleName(), e);
}
}
@@ -62,7 +64,7 @@ public class ReportManager {
private void initCsvFile() throws IOException {
csvReportFilePath = ValidationConfigManager.getCsvReportFilePath();
StrBuilder sb = new StrBuilder();
- sb.append("Vertex ID,"+"Task Name,"+"Success,"+"Result Details"+","+"Result Description");
+ sb.append("Vertex ID,Task Name,Success,Result Details,Result Description");
sb.appendNewLine();
Files.write(Paths.get(csvReportFilePath), sb.toString().getBytes());
}
@@ -87,9 +89,7 @@ public class ReportManager {
String successStatus = success ? "success" : "failed";
String line = "-----------------------Vertex: "+vertexScanned.getUniqueId()+", Task " + taskName + " " +successStatus+"-----------------------";
StrBuilder sb = new StrBuilder();
- writeReportLineToFile(sb.appendNewLine().toString());
sb.appendln(line);
- sb.appendNewLine();
writeReportLineToFile(line);
}
@@ -98,13 +98,12 @@ public class ReportManager {
Files.write(Paths.get(reportOutputFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND);
Files.write(Paths.get(reportOutputFilePath), message.getBytes(), StandardOpenOption.APPEND);
} catch (IOException e) {
- log.info("write to file failed - {}" , e);
+ log.info("write to file failed - {}", e.getClass().getSimpleName(), e);
}
}
public static void reportValidatorTypeSummary(String validatorName, Set<String> failedTasksNames, Set<String> successTasksNames){
StrBuilder sb = new StrBuilder();
- sb.appendNewLine().appendNewLine();
sb.appendln("-----------------------ValidatorExecuter " + validatorName + " Validation Summary-----------------------");
sb.appendln("Failed tasks: "+ failedTasksNames);
sb.appendln("Success tasks: "+ successTasksNames);
@@ -113,21 +112,18 @@ public class ReportManager {
public static void reportStartValidatorRun(String validatorName, int componenentsNum) {
StrBuilder sb = new StrBuilder();
- sb.appendNewLine().appendNewLine();
sb.appendln("------ValidatorExecuter " + validatorName + " Validation Started, on "+componenentsNum+" components---------");
writeReportLineToFile(sb.toString());
}
public static void reportStartTaskRun(GraphVertex vertex, String taskName){
StrBuilder sb = new StrBuilder();
- sb.appendNewLine().appendNewLine();
sb.appendln("-----------------------Vertex: "+vertex.getUniqueId()+", Task " + taskName + " Started-----------------------");
writeReportLineToFile(sb.toString());
}
public static void reportEndOfToolRun() {
StrBuilder sb = new StrBuilder();
- sb.appendNewLine().appendNewLine();
sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------");
failedVerticesPerTask.forEach((taskName, failedVertices) -> {
sb.append("Task: " + taskName);
@@ -140,16 +136,17 @@ public class ReportManager {
}
public static void printAllResults() {
- resultsPerVertex.forEach((vertex, tasksResults)->{
- tasksResults.forEach((task, result) -> {
- try {
- String resultLine = vertex +","+task+","+result.getStatus()+","+result.getResult();
- Files.write(Paths.get(csvReportFilePath), resultLine.getBytes(), StandardOpenOption.APPEND);
- Files.write(Paths.get(csvReportFilePath), new StrBuilder().appendNewLine().toString().getBytes(), StandardOpenOption.APPEND);
- } catch (IOException e) {
- log.info("write to file failed - {}" , e);
- }
- });
- });
+ resultsPerVertex.forEach((vertex, tasksResults) -> tasksResults.forEach((task, result) -> {
+ try {
+ String resultLine = vertex + "," + task + "," + result.getStatus() + "," + result.getResult();
+ Files.write(Paths.get(csvReportFilePath), resultLine.getBytes(),
+ StandardOpenOption.APPEND);
+ Files.write(Paths.get(csvReportFilePath),
+ new StrBuilder().appendNewLine().toString().getBytes(),
+ StandardOpenOption.APPEND);
+ } catch (IOException e) {
+ log.info("write to file failed - {}", e.getClass().getSimpleName(), e);
+ }
+ }));
}
}