summaryrefslogtreecommitdiffstats
path: root/asdctool/src
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
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')
-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
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutorContract.java (renamed from asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java)72
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java50
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java64
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java36
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java44
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java50
19 files changed, 189 insertions, 286 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) {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java
index e6ae05f493..47952f8d5c 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java
@@ -25,7 +25,7 @@ import static org.mockito.Mockito.mock;
import java.util.ArrayList;
import java.util.LinkedList;
import org.junit.Test;
-import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecuter;
+import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecutor;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
@@ -43,7 +43,7 @@ public class ArtifactToolBLTest {
ArtifactToolBL testSubject = createTestSubject();
testSubject.validators = new LinkedList<>();
- testSubject.validators.add(new NodeToscaArtifactsValidatorExecuter(janusGraphDaoMock, toscaOperationFacade));
+ testSubject.validators.add(new NodeToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade));
// Initially no outputFilePath was passed to this function (hence it is set to null)
// TODO: Fix this null and see if the argument is used by this function
testSubject.validateAll(null);
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java
index 8c2dffcbc2..ddea391ab1 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java
@@ -46,8 +46,6 @@ public class ValidationToolBLTest {
testSubject.validators = new LinkedList<>();
testSubject.validators.add(new ServiceValidatorExecuter(janusGraphDaoMock));
Report report = Report.make();
- // Initially no outputFilePath was passed to this function (hence it is set to null)
- // TODO: Fix this null and see if the argument is used by this function
- testSubject.validateAll(report, makeTxtFile(makeConsoleWriter()), null);
+ testSubject.validateAll(report, makeTxtFile(makeConsoleWriter()));
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
index deadf3250d..1903f0f1e7 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
@@ -23,7 +23,7 @@ package org.openecomp.sdc.asdctool.impl.validator.config;
import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL;
import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
-import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecuter;
+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;
@@ -227,7 +227,7 @@ public class ValidationToolConfigurationTest {
@Test
public void testNodeToscaArtifactsValidatorValidator() {
ValidationToolConfiguration testSubject;
- NodeToscaArtifactsValidatorExecuter result;
+ NodeToscaArtifactsValidatorExecutor result;
JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutorContract.java
index 46fae4312d..8564bb8251 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutorContract.java
@@ -20,7 +20,14 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import org.junit.Test;
+import static org.mockito.Mockito.mock;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
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;
@@ -29,67 +36,40 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.testng.Assert;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.mockito.Mockito.mock;
+public interface ArtifactValidatorExecutorContract {
-public class ArtifactValidatorExecuterTest {
+ ArtifactValidatorExecutor createTestSubject(
+ JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade
+ );
- private ArtifactValidatorExecuter createTestSubject() {
+ @Test
+ default void testGetVerticesToValidate() {
JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade);
- return new ArtifactValidatorExecuter(janusGraphDaoMock, toscaOperationFacade);
- }
-
- @Test
- public void testGetName() throws Exception {
- ArtifactValidatorExecuter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test(expected = NullPointerException.class)
- public void testGetVerticesToValidate() throws Exception {
- ArtifactValidatorExecuter testSubject;
VertexTypeEnum type = null;
Map<GraphPropertyEnum, Object> hasProps = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.getVerticesToValidate(type, hasProps);
+ Assertions.assertThrows(NullPointerException.class, () ->
+ testSubject.getVerticesToValidate(type, hasProps)
+ );
}
@Test
- public void testSetName() throws Exception {
- ArtifactValidatorExecuter testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
+ default void testValidate() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade);
- @Test
- public void testValidate() {
- ArtifactValidatorExecuter testSubject;
- Map<String, List<Component>> vertices = new HashMap<>();
LinkedList<Component> linkedList = new LinkedList<Component>();
linkedList.add(new Resource());
+
+ Map<String, List<Component>> vertices = new HashMap<>();
vertices.put("stam", linkedList);
- boolean result;
- // default test
- testSubject = createTestSubject();
// Initially no outputFilePath was passed to this function (hence it is set to null)
// TODO: Fix this null and see if the argument is used by this function
- result = testSubject.validate(vertices, null);
- Assert.assertFalse(result);
+ Assert.assertFalse(testSubject.validate(vertices, null));
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java
new file mode 100644
index 0000000000..39a1bbef0c
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 Bell Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.executers;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+
+import static org.mockito.Mockito.mock;
+
+public abstract class IArtifactValidatorExecutorContract {
+
+ protected abstract IArtifactValidatorExecutor createTestSubject(
+ JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade
+ );
+
+ private IArtifactValidatorExecutor createTestSubject() {
+ return createTestSubject(mock(JanusGraphDao.class), mock(ToscaOperationFacade.class));
+ }
+
+ @Test
+ public void testExecuteValidations() {
+ Assertions.assertThrows(NullPointerException.class, () ->
+ // Initially no outputFilePath was passed to this function (hence it is set to null)
+ // TODO: Fix this null and see if the argument is used by this function
+ createTestSubject().executeValidations(null)
+ );
+ }
+}
+
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java
deleted file mode 100644
index c9c90b2aa4..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.executers;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-
-import static org.mockito.Mockito.mock;
-
-public class NodeToscaArtifactsValidatorExecuterTest {
-
- private NodeToscaArtifactsValidatorExecuter createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
-
- return new NodeToscaArtifactsValidatorExecuter(janusGraphDaoMock, toscaOperationFacade);
- }
-
- @Test(expected = NullPointerException.class)
- public void testExecuteValidations() {
- // Initially no outputFilePath was passed to this function (hence it is set to null)
- // TODO: Fix this null and see if the argument is used by this function
- createTestSubject().executeValidations(null);
- }
-
- @Test
- public void testGetName() throws Exception {
- NodeToscaArtifactsValidatorExecuter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test
- public void testSetName() throws Exception {
- NodeToscaArtifactsValidatorExecuter testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java
new file mode 100644
index 0000000000..3870a98d78
--- /dev/null
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 Bell Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.executers;
+
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
+
+public class NodeToscaArtifactsValidatorExecutorTest
+ extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract {
+
+ @Override
+ public NodeToscaArtifactsValidatorExecutor createTestSubject(
+ JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade
+ ) {
+ return new NodeToscaArtifactsValidatorExecutor(janusGraphDao, toscaOperationFacade);
+ }
+}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java
index 1e24867358..7998c52ea4 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java
@@ -20,45 +20,17 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import org.junit.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import static org.mockito.Mockito.mock;
+public class ServiceToscaArtifactsValidatorExecutorTest
+ extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract {
-public class ServiceToscaArtifactsValidatorExecutorTest {
-
- private ServiceToscaArtifactsValidatorExecutor createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
-
- return new ServiceToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade);
- }
-
- @Test(expected = NullPointerException.class)
- public void testExecuteValidations() {
- // Initially no outputFilePath was passed to this function (hence it is set to null)
- // TODO: Fix this null and see if the argument is used by this function
- createTestSubject().executeValidations(null);
- }
-
- @Test
- public void testGetName() throws Exception {
- ServiceToscaArtifactsValidatorExecutor testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test
- public void testSetName() throws Exception {
- ServiceToscaArtifactsValidatorExecutor testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
+ @Override
+ public ServiceToscaArtifactsValidatorExecutor createTestSubject(
+ JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade
+ ) {
+ return new ServiceToscaArtifactsValidatorExecutor(janusGraphDao, toscaOperationFacade);
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java
index 783b888dec..ae6dcc1623 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java
@@ -20,51 +20,17 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import static org.mockito.Mockito.mock;
+public class VFToscaArtifactValidatorExecutorTest
+ extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract {
-public class VFToscaArtifactValidatorExecutorTest {
-
- private VFToscaArtifactValidatorExecutor createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
-
- return new VFToscaArtifactValidatorExecutor(janusGraphDaoMock, toscaOperationFacade);
- }
-
- @Test
- public void testExecuteValidations() {
- VFToscaArtifactValidatorExecutor testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- // Initially no outputFilePath was passed to this function (hence it is set to null)
- // TODO: Fix this null and see if the argument is used by this function
- Assertions.assertThrows(NullPointerException.class, () -> testSubject.executeValidations(null));
- }
-
- @Test
- public void testGetName() throws Exception {
- VFToscaArtifactValidatorExecutor testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test
- public void testSetName() throws Exception {
- VFToscaArtifactValidatorExecutor testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
+ @Override
+ public VFToscaArtifactValidatorExecutor createTestSubject(
+ JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade
+ ) {
+ return new VFToscaArtifactValidatorExecutor(janusGraphDao, toscaOperationFacade);
}
}