aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/java
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-06-18 16:06:01 -0400
committerFrancis Toth <francis.toth@yoppworks.com>2020-06-23 13:25:10 +0000
commitbdbfc2e460ccb561c3e174260b2908b974996d4f (patch)
treec2e74390cc979dd63b17c01f36d396b76e0e2834 /asdctool/src/main/java
parent8c6ad373281722ce410a1108c67de5f1adf350ea (diff)
Decouple TXT Report file writing and formatting logic (6/6)
This commit moves the writeReportLineToFile from ReportManager to ReportFile, deletes ReportManager (as it's not longer used), and finalizes the decoupling between the writing and the formatting logic of the TXT Report file. Signed-off-by: Francis Toth <francis.toth@yoppworks.com> Change-Id: Ia5cce71535ea808e6e24807ed62ae9b262eab6ad Issue-ID: SDC-2499
Diffstat (limited to 'asdctool/src/main/java')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java19
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFile.java18
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java3
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java41
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java5
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java5
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/module/json/ModuleJsonTask.java36
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java71
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java1
13 files changed, 74 insertions, 137 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java
index 61b3640d7d..6659f6e82c 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java
@@ -47,7 +47,7 @@ public class ValidationToolBL {
public boolean validateAll(Report report, ReportFile.TXTFile textFile, String outputFilePath) {
for (ValidatorExecuter validatorExec: validators) {
log.debug("ValidatorExecuter "+validatorExec.getName()+" started");
- if (!validatorExec.executeValidations(report, textFile, outputFilePath)) {
+ if (!validatorExec.executeValidations(report, textFile)) {
allValid = false;
log.debug("ValidatorExecuter "+validatorExec.getName()+" finished with warnings");
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java
index af9cb3634c..5d209807b6 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java
@@ -44,8 +44,8 @@ public class ServiceValidatorExecuter extends TopologyTemplateValidatorExecuter
}
@Override
- public boolean executeValidations(Report report, TXTFile reportFile, String outputFilePath) {
+ public boolean executeValidations(Report report, TXTFile reportFile) {
List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.SERVICE);
- return validate(report, tasks, vertices, reportFile, outputFilePath);
+ return validate(report, tasks, vertices, reportFile);
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
index 52c8cb5f96..ddf9e7bce5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java
@@ -21,10 +21,15 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile;
import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask;
-import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -36,13 +41,6 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
public class TopologyTemplateValidatorExecuter {
private static final Logger log = Logger.getLogger(VfValidatorExecuter.class);
@@ -85,8 +83,7 @@ public class TopologyTemplateValidatorExecuter {
Report report,
List<? extends TopologyTemplateValidationTask> tasks,
List<GraphVertex> vertices,
- TXTFile reportFile,
- String outputFilePath
+ TXTFile reportFile
) {
reportFile.reportStartValidatorRun(getName(), vertices.size());
Set<String> failedTasks = new HashSet<>();
@@ -100,7 +97,7 @@ public class TopologyTemplateValidatorExecuter {
boolean successAllTasks = true;
for (TopologyTemplateValidationTask task : tasks) {
reportFile.reportStartTaskRun(vertex, task.getTaskName());
- VertexResult result = task.validate(report, vertex, outputFilePath);
+ VertexResult result = task.validate(report, vertex, reportFile);
if (!result.getStatus()) {
failedTasks.add(task.getTaskName());
successAllVertices = false;
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java
index 88b7c0c64a..87449886d8 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java
@@ -25,6 +25,6 @@ import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile;
public interface ValidatorExecuter {
- boolean executeValidations(Report report, TXTFile textFile, String outputFilePath);
+ boolean executeValidations(Report report, TXTFile textFile);
String getName();
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java
index 3484bbf8dc..4786e129d6 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java
@@ -42,8 +42,8 @@ public class VfValidatorExecuter extends TopologyTemplateValidatorExecuter imple
}
@Override
- public boolean executeValidations(Report report, TXTFile reportFile, String outputFilePath) {
+ public boolean executeValidations(Report report, TXTFile reportFile) {
List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.RESOURCE);
- return validate(report, tasks, vertices, reportFile, outputFilePath);
+ return validate(report, tasks, vertices, reportFile);
}
}
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 b483964a6e..e706d8a8bb 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
@@ -29,11 +29,6 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
*/
public class ReportFile {
- // TODO: Delete this function once all the report file business logic has been moved to ReportFile
- static public TXTFile makeAppendableTxtFile(ReportFileWriter<FileType.TXT> writer) {
- return new TXTFile(writer);
- }
-
static public TXTFile makeTxtFile(ReportFileWriter<FileType.TXT> writer) {
writer.writeln("-----------------------Validation Tool Results:-------------------------");
return new TXTFile(writer);
@@ -82,7 +77,7 @@ public class ReportFile {
);
}
- public void reportValidatorTypeSummary(
+ public void reportValidatorTypeSummary(
String validatorName,
Set<String> failedTasksNames,
Set<String> successTasksNames
@@ -99,17 +94,22 @@ public class ReportFile {
public void reportEndOfToolRun(Report report) {
StrBuilder sb = new StrBuilder();
sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------");
- report.forEachFailure((taskName, failedVertices) -> {
+ report.forEachFailure((taskName, failedVertices) ->
sb.append("Task: ")
.append(taskName)
.appendNewLine()
.append("FailedVertices: ")
.append(String.valueOf(failedVertices))
- .appendNewLine();
- });
+ .appendNewLine());
+
writer.writeln("");
writer.write(sb.toString());
}
+
+ public void writeReportLineToFile(String message) {
+ writer.writeln("");
+ writer.write(message);
+ }
}
/**
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java
index f50e552970..99470c6aee 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/TopologyTemplateValidationTask.java
@@ -21,11 +21,12 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
+import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
public interface TopologyTemplateValidationTask {
- VertexResult validate(Report report, GraphVertex vertex, String outputFilePath);
+ VertexResult validate(Report report, GraphVertex vertex, ReportFile.TXTFile reportFile);
String getTaskName();
String getTaskResultStatus();
void setTaskResultStatus(String status);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
index 428b6606a6..bf3d267ab9 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
@@ -22,8 +22,13 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
-import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
+import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -37,22 +42,13 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Created by chaya on 7/6/2017.
- */
public class ArtifactValidationUtils {
private static final Logger logger = Logger.getLogger(ArtifactValidationUtils.class);
- private ArtifactCassandraDao artifactCassandraDao;
+ private final ArtifactCassandraDao artifactCassandraDao;
- private TopologyTemplateOperation topologyTemplateOperation;
+ private final TopologyTemplateOperation topologyTemplateOperation;
@Autowired
public ArtifactValidationUtils(ArtifactCassandraDao artifactCassandraDao,
@@ -61,14 +57,19 @@ public class ArtifactValidationUtils {
this.topologyTemplateOperation = topologyTemplateOperation;
}
- public ArtifactsVertexResult validateArtifactsAreInCassandra(Report report, GraphVertex vertex, String taskName,
- List<ArtifactDataDefinition> artifacts, String outputFilePath) {
+ public ArtifactsVertexResult validateArtifactsAreInCassandra(
+ Report report,
+ GraphVertex vertex,
+ String taskName,
+ List<ArtifactDataDefinition> artifacts,
+ ReportFile.TXTFile reportFile
+ ) {
ArtifactsVertexResult result = new ArtifactsVertexResult(true);
for (ArtifactDataDefinition artifact : artifacts) {
boolean isArtifactExist = isArtifactInCassandra(artifact.getEsId());
String status = isArtifactExist ? "Artifact " + artifact.getEsId() + " is in Cassandra" :
"Artifact " + artifact.getEsId() + " doesn't exist in Cassandra";
- ReportManager.writeReportLineToFile(status, outputFilePath);
+ reportFile.writeReportLineToFile(status);
if (!isArtifactExist) {
report.addFailure(taskName, vertex.getUniqueId());
result.setStatus(false);
@@ -99,8 +100,12 @@ public class ArtifactValidationUtils {
return artifacts;
}
- public ArtifactsVertexResult validateTopologyTemplateArtifacts(Report report, GraphVertex vertex, String taskName,
- String outputFilePath) {
+ public ArtifactsVertexResult validateTopologyTemplateArtifacts(
+ Report report,
+ GraphVertex vertex,
+ String taskName,
+ ReportFile.TXTFile reportFile
+ ) {
ArtifactsVertexResult result = new ArtifactsVertexResult();
ComponentParametersView paramView = new ComponentParametersView();
paramView.disableAll();
@@ -135,6 +140,6 @@ public class ArtifactValidationUtils {
allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition())));
}
- return validateArtifactsAreInCassandra(report, vertex, taskName, allArtifacts, outputFilePath);
+ return validateArtifactsAreInCassandra(report, vertex, taskName, allArtifacts, reportFile);
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java
index e3f547485a..a5d518510e 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
+import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile;
import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +38,7 @@ public class ServiceArtifactValidationTask extends ServiceValidationTask {
}
@Override
- public ArtifactsVertexResult validate(Report report, GraphVertex vertex, String outputFilePath) {
- return artifactValidationUtils.validateTopologyTemplateArtifacts(report, vertex, getTaskName(), outputFilePath);
+ public ArtifactsVertexResult validate(Report report, GraphVertex vertex, ReportFile.TXTFile reportFile) {
+ return artifactValidationUtils.validateTopologyTemplateArtifacts(report, vertex, getTaskName(), reportFile);
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java
index f48088304f..26495fa4e3 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
+import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile;
import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -41,7 +42,7 @@ public class VfArtifactValidationTask extends VfValidationTask {
}
@Override
- public VertexResult validate(Report report, GraphVertex vertex, String outputFilePath) {
- return artifactValidationUtils.validateTopologyTemplateArtifacts(report, vertex, getTaskName(), outputFilePath);
+ public VertexResult validate(Report report, GraphVertex vertex, ReportFile.TXTFile reportFile) {
+ return artifactValidationUtils.validateTopologyTemplateArtifacts(report, vertex, getTaskName(), reportFile);
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/module/json/ModuleJsonTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/module/json/ModuleJsonTask.java
index 58c2ef031b..62404e1e43 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/module/json/ModuleJsonTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/module/json/ModuleJsonTask.java
@@ -29,8 +29,8 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
+import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile;
import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask;
-import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
@@ -47,7 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
public class ModuleJsonTask extends ServiceValidationTask {
- private TopologyTemplateOperation topologyTemplateOperation;
+ private final TopologyTemplateOperation topologyTemplateOperation;
@Autowired
public ModuleJsonTask(TopologyTemplateOperation topologyTemplateOperation) {
@@ -56,7 +56,7 @@ public class ModuleJsonTask extends ServiceValidationTask {
}
@Override
- public VertexResult validate(Report report, GraphVertex vertex, String outputFilePath) {
+ public VertexResult validate(Report report, GraphVertex vertex, ReportFile.TXTFile reportFile) {
if (!isAfterSubmitForTesting(vertex)) {
return new VertexResult(true);
}
@@ -80,35 +80,39 @@ public class ModuleJsonTask extends ServiceValidationTask {
MapGroupsDataDefinition groups = pair.getValue();
if (groups != null && !groups.getMapToscaDataDefinition().isEmpty()) {
return new VertexResult(
- findCoordinateModuleJson(report, pair, instDeploymentArtifacts, vertex, outputFilePath));
+ findCoordinateModuleJson(report, pair, instDeploymentArtifacts, vertex, reportFile));
}
}
return new VertexResult(true);
}
- private boolean findCoordinateModuleJson(Report report, Map.Entry<String, MapGroupsDataDefinition> pair,
- Map<String, MapArtifactDataDefinition> instDeploymentArtifacts,
- GraphVertex vertex, String outputFilePath) {
+ private boolean findCoordinateModuleJson(
+ Report report,
+ Map.Entry<String, MapGroupsDataDefinition> pair,
+ Map<String, MapArtifactDataDefinition> instDeploymentArtifacts,
+ GraphVertex vertex,
+ ReportFile.TXTFile reportFile
+ ) {
String groupKey = pair.getKey();
String[] split = groupKey.split("\\.");
String instanceName = split[split.length - 1];
MapArtifactDataDefinition deploymentsArtifacts = instDeploymentArtifacts.get(groupKey);
if (deploymentsArtifacts != null && !deploymentsArtifacts.getMapToscaDataDefinition().isEmpty()) {
List<ArtifactDataDefinition> moduleJsonArtifacts = deploymentsArtifacts.getMapToscaDataDefinition().values()
- .stream().filter(artifact -> {
- String artifactName = artifact.getArtifactName();
- return (artifactName.startsWith(instanceName) && artifactName.endsWith("modules.json"));
- }).collect(Collectors.toList());
- if (!moduleJsonArtifacts.isEmpty()) {
- String status = "Instance " + instanceName + " has a corresponding modules.json file: "
- + moduleJsonArtifacts.get(0)
+ .stream().filter(artifact -> {
+ String artifactName = artifact.getArtifactName();
+ return artifactName.startsWith(instanceName) && artifactName.endsWith("modules.json");
+ }).collect(Collectors.toList());
+ if (moduleJsonArtifacts.size() > 0) {
+ String status =
+ "Instance " + instanceName + " has a corresponding modules.json file: " + moduleJsonArtifacts.get(0)
.getArtifactName();
- ReportManager.writeReportLineToFile(status, outputFilePath);
+ reportFile.writeReportLineToFile(status);
return true;
}
}
String status = "Instance " + instanceName + " doesn't have a corresponding modules.json file";
- ReportManager.writeReportLineToFile(status, outputFilePath);
+ reportFile.writeReportLineToFile(status);
report.addFailure(getTaskName(), vertex.getUniqueId());
return false;
}
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
deleted file mode 100644
index 9b09e67c39..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.validator.utils;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
-import java.util.Set;
-import org.apache.commons.lang.text.StrBuilder;
-import org.openecomp.sdc.asdctool.impl.validator.report.Report;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReportManager {
-
- private static final Logger log = LoggerFactory.getLogger(ReportManager.class);
-
- public static ReportManager make(String txtReportFilePath) {
- return new ReportManager(txtReportFilePath);
- }
-
- private ReportManager(String txtReportFilePath) {
- try {
- initReportFile(txtReportFilePath);
- } catch (IOException e) {
- log.info("Init file failed - {}", e.getClass().getSimpleName(), e);
- }
- }
-
- private void initReportFile(String txtReportFilePath) throws IOException {
- Path path = Paths.get(txtReportFilePath);
- // TODO: Remove this once all the report file business logic has been moved to ReportFile
- if(Files.notExists(path)) {
- StrBuilder sb = new StrBuilder();
- sb.appendln("-----------------------Validation Tool Results:-------------------------");
- Files.write(path, sb.toString().getBytes());
- }
- }
-
- public static void writeReportLineToFile(String message, String outputFilePath) {
- try {
- Files.write(Paths.get(outputFilePath), new StrBuilder().appendNewLine().toString().getBytes(),
- StandardOpenOption.APPEND);
- Files.write(Paths.get(outputFilePath), message.getBytes(), StandardOpenOption.APPEND);
- } catch (IOException e) {
- log.info("write to file failed - {}", e.getClass().getSimpleName(), e);
- }
- }
-}
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 3bffa0b5e2..22d93b1407 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
@@ -31,7 +31,6 @@ import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile;
import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.CSVFile;
import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile;
import org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriter;
-import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;