summaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/java
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-06-24 09:28:06 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-06-25 05:11:28 +0000
commite9cb7eb287f88938b0a2f6d2cd0743e6ac2867f8 (patch)
tree51f6bdf7779d83687f2f90b08c612d1f1d5a1e76 /asdctool/src/main/java
parent6bd3d3a85c4e14174070b8c0de81714a0155255a (diff)
Cleaned up ArtifactValidatorExecuter and IArtifactValidatorExecutor
This commit intends to clean the tests related to ArtifactValidatorExecuter and IArtifactValidatorExecutor by introducing the concept of test contract. Some renaming have to be done to fix the typo in Executer (it should be named Executor), hence the number of changes. Signed-off-by: Francis Toth <francis.toth@yoppworks.com> Change-Id: I5cd4512c425ae01f4f1118c9d61e6fce3df94f1d Issue-ID: SDC-2499
Diffstat (limited to 'asdctool/src/main/java')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java10
-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/config/ValidationToolConfiguration.java10
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutor.java (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java)64
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutor.java (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java)3
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutor.java (renamed from asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java)20
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java16
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java18
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java2
10 files changed, 56 insertions, 91 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java
index ebd548202b..75fde3de1e 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java
@@ -20,7 +20,7 @@
package org.openecomp.sdc.asdctool.impl.validator;
-import org.openecomp.sdc.asdctool.impl.validator.executers.IArtifactValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.IArtifactValidatorExecutor;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,20 +28,20 @@ import java.util.List;
public class ArtifactToolBL {
- private static Logger log = Logger.getLogger(ValidationToolBL.class.getName());
+ private static final Logger log = Logger.getLogger(ValidationToolBL.class.getName());
- protected List<IArtifactValidatorExecuter> validators;
+ protected List<IArtifactValidatorExecutor> validators;
private boolean allValid = true;
@Autowired
public ArtifactToolBL(
- List<IArtifactValidatorExecuter> validators) {
+ List<IArtifactValidatorExecutor> validators) {
this.validators = validators;
}
public boolean validateAll(String outputFilePath) {
- for (IArtifactValidatorExecuter validatorExec : validators) {
+ for (IArtifactValidatorExecutor validatorExec : validators) {
log.debug("ValidatorExecuter " + validatorExec.getName() + " started");
if (!validatorExec.executeValidations(outputFilePath)) {
allValid = false;
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 6659f6e82c..2fac030188 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
@@ -44,7 +44,7 @@ public class ValidationToolBL {
this.validators = validators;
}
- public boolean validateAll(Report report, ReportFile.TXTFile textFile, String outputFilePath) {
+ public boolean validateAll(Report report, ReportFile.TXTFile textFile) {
for (ValidatorExecuter validatorExec: validators) {
log.debug("ValidatorExecuter "+validatorExec.getName()+" started");
if (!validatorExec.executeValidations(report, textFile)) {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
index b13009fecc..81051a62b9 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
@@ -23,8 +23,8 @@ package org.openecomp.sdc.asdctool.impl.validator.config;
import org.openecomp.sdc.asdctool.impl.VrfObjectFixHandler;
import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL;
import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
-import org.openecomp.sdc.asdctool.impl.validator.executers.IArtifactValidatorExecuter;
-import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.IArtifactValidatorExecutor;
+import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceToscaArtifactsValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter;
import org.openecomp.sdc.asdctool.impl.validator.executers.VFToscaArtifactValidatorExecutor;
@@ -83,9 +83,9 @@ public class ValidationToolConfiguration {
}
@Bean
- public NodeToscaArtifactsValidatorExecuter NodeToscaArtifactsValidatorValidator(JanusGraphDao janusGraphDao,
+ public NodeToscaArtifactsValidatorExecutor NodeToscaArtifactsValidatorValidator(JanusGraphDao janusGraphDao,
ToscaOperationFacade toscaOperationFacade) {
- return new NodeToscaArtifactsValidatorExecuter(janusGraphDao, toscaOperationFacade);
+ return new NodeToscaArtifactsValidatorExecutor(janusGraphDao, toscaOperationFacade);
}
@Bean
@@ -121,7 +121,7 @@ public class ValidationToolConfiguration {
}
@Bean
- public ArtifactToolBL artifactToolBL(List<IArtifactValidatorExecuter> validators) {
+ public ArtifactToolBL artifactToolBL(List<IArtifactValidatorExecutor> validators) {
return new ArtifactToolBL(validators);
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutor.java
index 9007d8ce05..1a19f5d882 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutor.java
@@ -20,20 +20,9 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import fj.data.Either;
-import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.common.log.wrappers.Logger;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import fj.data.Either;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -48,23 +37,33 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.common.log.wrappers.Logger;
-public class ArtifactValidatorExecuter {
+public abstract class ArtifactValidatorExecutor {
- protected JanusGraphDao janusGraphDao;
- protected ToscaOperationFacade toscaOperationFacade;
+ private static final Logger log = Logger.getLogger(ArtifactValidatorExecutor.class);
- public ArtifactValidatorExecuter(JanusGraphDao janusGraphDao,
- ToscaOperationFacade toscaOperationFacade) {
+ private final JanusGraphDao janusGraphDao;
+ private final ToscaOperationFacade toscaOperationFacade;
+ private final String name;
+
+ public ArtifactValidatorExecutor(
+ JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade,
+ String name
+ ) {
this.janusGraphDao = janusGraphDao;
this.toscaOperationFacade = toscaOperationFacade;
- }
-
- private static Logger log = Logger.getLogger(ArtifactValidatorExecuter.class.getName());
-
- protected String name;
-
- public void setName(String name) {
this.name = name;
}
@@ -72,7 +71,6 @@ public class ArtifactValidatorExecuter {
return name;
}
-
public Map<String, List<Component>> getVerticesToValidate(VertexTypeEnum type,
Map<GraphPropertyEnum, Object> hasProps) {
Map<String, List<Component>> result = new HashMap<>();
@@ -87,7 +85,7 @@ public class ArtifactValidatorExecuter {
componentsList.forEach(vertex -> {
String ivariantUuid = (String) vertex.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID);
if (!result.containsKey(ivariantUuid)) {
- List<Component> compList = new ArrayList<Component>();
+ List<Component> compList = new ArrayList<>();
result.put(ivariantUuid, compList);
}
List<Component> compList = result.get(ivariantUuid);
@@ -114,7 +112,7 @@ public class ArtifactValidatorExecuter {
boolean result = true;
long time = System.currentTimeMillis();
String fileName = outputFilePath + this.getName() + "_" + time + ".csv";
- try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), "utf-8"))) {
+ try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), UTF_8))) {
writer.write("name, UUID, invariantUUID, state, version\n");
Collection<List<Component>> collection = vertices.values();
for (List<Component> compList : collection) {
@@ -149,12 +147,10 @@ public class ArtifactValidatorExecuter {
try {
// "service name, service id, state, version
for (Component component : components) {
- StringBuffer sb = new StringBuffer(component.getName());
- sb.append(",").append(component.getUniqueId()).append(",").append(component.getInvariantUUID())
- .append(",").append(component.getLifecycleState()).append(",").append(component.getVersion());
-
- sb.append("\n");
- writer.write(sb.toString());
+ String sb = component.getName() + "," + component.getUniqueId() + "," + component.getInvariantUUID()
+ + "," + component.getLifecycleState() + "," + component.getVersion()
+ + "\n";
+ writer.write(sb);
}
} catch (IOException e) {
log.error("Failed to write module result to file ", e);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutor.java
index 1b3c0375e7..19f7bf88c5 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutor.java
@@ -20,7 +20,8 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-public interface IArtifactValidatorExecuter {
+// TODO: Merge this interface with ArtifactValidatorExecutor
+public interface IArtifactValidatorExecutor {
boolean executeValidations(String outputFilePath);
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutor.java
index 6a52e07dd2..41f2c5516b 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutor.java
@@ -32,15 +32,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class NodeToscaArtifactsValidatorExecuter extends ArtifactValidatorExecuter implements
- IArtifactValidatorExecuter {
+public class NodeToscaArtifactsValidatorExecutor
+ extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor {
- protected String name;
-
- public NodeToscaArtifactsValidatorExecuter(JanusGraphDao janusGraphDao,
+ public NodeToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao,
ToscaOperationFacade toscaOperationFacade) {
- super(janusGraphDao, toscaOperationFacade);
- setName("RESOURCE_TOSCA_ARTIFACTS");
+ super(janusGraphDao, toscaOperationFacade, "RESOURCE_TOSCA_ARTIFACTS");
}
@Override
@@ -52,13 +49,4 @@ public class NodeToscaArtifactsValidatorExecuter extends ArtifactValidatorExecut
Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.NODE_TYPE, hasProps);
return validate(vertices, outputFilePath);
}
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java
index 21a8065dff..e633aa0204 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java
@@ -34,14 +34,13 @@ import java.util.List;
import java.util.Map;
@org.springframework.stereotype.Component
-public class ServiceToscaArtifactsValidatorExecutor extends ArtifactValidatorExecuter implements
- IArtifactValidatorExecuter {
+public class ServiceToscaArtifactsValidatorExecutor
+ extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor {
@Autowired
public ServiceToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao,
ToscaOperationFacade toscaOperationFacade) {
- super(janusGraphDao, toscaOperationFacade);
- setName("SERVICE_TOSCA_ARTIFACTS");
+ super(janusGraphDao, toscaOperationFacade, "SERVICE_TOSCA_ARTIFACTS");
}
@Override
@@ -53,13 +52,4 @@ public class ServiceToscaArtifactsValidatorExecutor extends ArtifactValidatorExe
Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps);
return validate(vertices, outputFilePath);
}
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java
index b5347a2579..ba05994984 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java
@@ -33,12 +33,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class VFToscaArtifactValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter {
+public class VFToscaArtifactValidatorExecutor
+ extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor {
- public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao,
- ToscaOperationFacade toscaOperationFacade) {
- super(janusGraphDao, toscaOperationFacade);
- setName("VF_TOSCA_ARTIFACTS");
+ public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao, ToscaOperationFacade toscaOperationFacade) {
+ super(janusGraphDao, toscaOperationFacade, "VF_TOSCA_ARTIFACTS");
}
@Override
@@ -52,13 +51,4 @@ public class VFToscaArtifactValidatorExecutor extends ArtifactValidatorExecuter
return validate(vertices, outputFilePath);
}
-
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
}
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 4786e129d6..40aa601224 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
@@ -32,7 +32,7 @@ import java.util.List;
public class VfValidatorExecuter extends TopologyTemplateValidatorExecuter implements ValidatorExecuter {
- private List<VfValidationTask> tasks;
+ private final List<VfValidationTask> tasks;
@Autowired(required = false)
public VfValidatorExecuter(List<VfValidationTask> tasks, JanusGraphDao janusGraphDao) {
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 22d93b1407..e5cd6f8c14 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
@@ -57,7 +57,7 @@ public class ValidationTool {
log.info("Start Validation Tool");
Report report = Report.make();
- boolean result = validationToolBL.validateAll(report, textFile, txtReportFilePath);
+ boolean result = validationToolBL.validateAll(report, textFile);
textFile.reportEndOfToolRun(report);
csvFile.printAllResults(report);
if (result) {