aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-04-19 20:55:37 -0400
committerOjas Dubey <Ojas.Dubey@amdocs.com>2020-05-12 04:59:28 +0000
commit7717944e41ecbb9447a56d870821b6d494e7ebe3 (patch)
tree79feba0fd633acabb306332bdcce7fe87aad9ddb
parent88af509e836976b545e071cfe562bf70258c6c70 (diff)
Remove outputFullFilePath from ValidationConfigManager
This commit aims to extract the outputFullFilePath field from ValidationConfigManager in order to improve testability. This commit contains multiple minor modifications resulting from bubbling up the outputFullFilePath static field to where it is actually set. Most of the modifications result from changing the signature of the functions which formerly relied on ValidationConfigManager.getOutputFullFilePath. Change-Id: I0a28e527cabe606de8af62b8dcbc4b4e70db98ed Signed-off-by: Francis Toth <francis.toth@yoppworks.com> Issue-ID: SDC-2499
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java54
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java23
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuter.java221
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecuter.java11
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuter.java57
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java53
-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.java31
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java57
-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/tasks/TopologyTemplateValidationTask.java2
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java21
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTask.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTask.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java46
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManager.java43
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java4
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ValidationTool.java6
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java49
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java34
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java38
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecuterTest.java92
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecuterTest.java61
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java61
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java44
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java64
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java42
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java26
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java38
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java37
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java19
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java10
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java36
35 files changed, 629 insertions, 673 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 2b63193a1e..ebd548202b 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
@@ -7,9 +7,9 @@
* 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.
@@ -27,31 +27,29 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
public class ArtifactToolBL {
-
- private static Logger log = Logger.getLogger(ValidationToolBL.class.getName());
-
- protected List<IArtifactValidatorExecuter> validators;
-
- private boolean allValid = true;
-
- @Autowired
- public ArtifactToolBL(
- List<IArtifactValidatorExecuter> validators) {
- this.validators = validators;
- }
-
- public boolean validateAll() {
- for (IArtifactValidatorExecuter validatorExec: validators) {
- log.debug("ValidatorExecuter "+validatorExec.getName()+" started");
- if (!validatorExec.executeValidations()) {
- allValid = false;
- log.debug("ValidatorExecuter "+validatorExec.getName()+" finished with warnings");
- }
- else {
- log.debug("ValidatorExecuter "+validatorExec.getName()+" finished successfully");
- }
- }
- return allValid;
- }
+ private static Logger log = Logger.getLogger(ValidationToolBL.class.getName());
+
+ protected List<IArtifactValidatorExecuter> validators;
+
+ private boolean allValid = true;
+
+ @Autowired
+ public ArtifactToolBL(
+ List<IArtifactValidatorExecuter> validators) {
+ this.validators = validators;
+ }
+
+ public boolean validateAll(String outputFilePath) {
+ for (IArtifactValidatorExecuter validatorExec : validators) {
+ log.debug("ValidatorExecuter " + validatorExec.getName() + " started");
+ if (!validatorExec.executeValidations(outputFilePath)) {
+ allValid = false;
+ log.debug("ValidatorExecuter " + validatorExec.getName() + " finished with warnings");
+ } else {
+ log.debug("ValidatorExecuter " + validatorExec.getName() + " finished successfully");
+ }
+ }
+ return allValid;
+ }
}
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 ae25c3106e..c73e4d4c03 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
@@ -45,10 +45,10 @@ public class ValidationToolBL {
this.validators = validators;
}
- public boolean validateAll() {
+ public boolean validateAll(String outputFilePath) {
for (ValidatorExecuter validatorExec: validators) {
log.debug("ValidatorExecuter "+validatorExec.getName()+" started");
- if (!validatorExec.executeValidations()) {
+ if (!validatorExec.executeValidations(outputFilePath)) {
allValid = false;
log.debug("ValidatorExecuter "+validatorExec.getName()+" finished with warnings");
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
index 3c09a54735..6178fe3f60 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
@@ -26,32 +26,21 @@ package org.openecomp.sdc.asdctool.impl.validator.config;
import java.util.function.Supplier;
-public class ValidationConfigManager {
+public final class ValidationConfigManager {
+ private static final String REPORT_OUTPUT_FILE_NAME = "/reportOutput.txt";
private static final String CSV_FILE_PREFIX = "/csvSummary_";
private static final String CSV_EXT = ".csv";
public static final String DEFAULT_CSV_PATH = "summary.csv";
- private static String outputFullFilePath;
- private static String outputFilePath;
-
private ValidationConfigManager() {
}
- public static String csvReportFilePath(String outputPath, Supplier<Long> getTime) {
- return outputPath + CSV_FILE_PREFIX + getTime.get() + CSV_EXT;
- }
-
- public static String getOutputFullFilePath() {
- return outputFullFilePath;
+ public static String txtReportFilePath(String outputPath) {
+ return outputPath + REPORT_OUTPUT_FILE_NAME;
}
- public static String getOutputFilePath() {
- return outputFilePath;
- }
-
- public static void setOutputFullFilePath(String outputPath) {
- ValidationConfigManager.outputFilePath = outputPath;
- ValidationConfigManager.outputFullFilePath = outputPath + "/reportOutput.txt";
+ public static String csvReportFilePath(String outputPath, Supplier<Long> getTime) {
+ return outputPath + CSV_FILE_PREFIX + getTime.get() + CSV_EXT;
}
}
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/ArtifactValidatorExecuter.java
index a5e7d7873b..9007d8ce05 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/ArtifactValidatorExecuter.java
@@ -7,9 +7,9 @@
* 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.
@@ -49,111 +49,116 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-public class ArtifactValidatorExecuter{
-
- protected JanusGraphDao janusGraphDao;
- protected ToscaOperationFacade toscaOperationFacade;
-
- public ArtifactValidatorExecuter(JanusGraphDao janusGraphDao,
- ToscaOperationFacade toscaOperationFacade) {
- 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;
- }
-
- public String getName() {
- return name;
- }
-
-
-
- public Map<String, List<Component>> getVerticesToValidate(VertexTypeEnum type, Map<GraphPropertyEnum, Object> hasProps){
- Map<String, List<Component>> result = new HashMap<>();
- Either<List<GraphVertex>, JanusGraphOperationStatus> resultsEither = janusGraphDao
- .getByCriteria(type, hasProps);
- if (resultsEither.isRight()) {
- log.error("getVerticesToValidate failed "+ resultsEither.right().value());
- return result;
- }
- System.out.println("getVerticesToValidate: "+resultsEither.left().value().size()+" vertices to scan");
- List<GraphVertex> componentsList = resultsEither.left().value();
- componentsList.forEach(vertex -> {
- String ivariantUuid = (String)vertex.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID);
- if(!result.containsKey(ivariantUuid)){
- List<Component> compList = new ArrayList<Component>();
- result.put(ivariantUuid, compList);
- }
- List<Component> compList = result.get(ivariantUuid);
-
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreArtifacts(false);
-
- Either<Component, StorageOperationStatus> toscaElement = toscaOperationFacade.getToscaElement(vertex.getUniqueId(), filter);
- if (toscaElement.isRight()) {
- log.error("getVerticesToValidate: failed to find element"+ vertex.getUniqueId()+" staus is" + toscaElement.right().value());
- }else{
- compList.add(toscaElement.left().value());
- }
-
- });
-
- return result;
- }
-
- public boolean validate( Map<String, List<Component>> vertices) {
- boolean result = true;
- long time = System.currentTimeMillis();
- String fileName = ValidationConfigManager.getOutputFilePath() + this.getName() + "_"+ time + ".csv";
- 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 ){
- Set<String> artifactEsId = new HashSet<>();
- for(Component component: compList ){
- Map<String, ArtifactDefinition> toscaArtifacts = component.getToscaArtifacts();
- Optional<ArtifactDefinition> op = toscaArtifacts.values().
- stream().filter(a -> artifactEsId.contains(a.getEsId())).findAny();
- if(op.isPresent()){
- result = false;
- writeModuleResultToFile(writer, compList);
- writer.flush();
- break;
- }else{
- artifactEsId.addAll(toscaArtifacts.values().stream().map(ArtifactDefinition::getEsId).collect(Collectors.toList())) ;
- }
- }
-
- }
-
- } catch (Exception e) {
- log.error("Failed to fetch vf resources ", e);
- return false;
- } finally {
- janusGraphDao.commit();
- }
- return result;
- }
-
- private void writeModuleResultToFile(Writer writer, List<Component> components) {
- 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());
- }
- } catch (IOException e) {
- log.error("Failed to write module result to file ", e);
- }
- }
+public class ArtifactValidatorExecuter {
+
+ protected JanusGraphDao janusGraphDao;
+ protected ToscaOperationFacade toscaOperationFacade;
+
+ public ArtifactValidatorExecuter(JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade) {
+ 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;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+
+ public Map<String, List<Component>> getVerticesToValidate(VertexTypeEnum type,
+ Map<GraphPropertyEnum, Object> hasProps) {
+ Map<String, List<Component>> result = new HashMap<>();
+ Either<List<GraphVertex>, JanusGraphOperationStatus> resultsEither = janusGraphDao
+ .getByCriteria(type, hasProps);
+ if (resultsEither.isRight()) {
+ log.error("getVerticesToValidate failed " + resultsEither.right().value());
+ return result;
+ }
+ System.out.println("getVerticesToValidate: " + resultsEither.left().value().size() + " vertices to scan");
+ List<GraphVertex> componentsList = resultsEither.left().value();
+ componentsList.forEach(vertex -> {
+ String ivariantUuid = (String) vertex.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID);
+ if (!result.containsKey(ivariantUuid)) {
+ List<Component> compList = new ArrayList<Component>();
+ result.put(ivariantUuid, compList);
+ }
+ List<Component> compList = result.get(ivariantUuid);
+
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreArtifacts(false);
+
+ Either<Component, StorageOperationStatus> toscaElement = toscaOperationFacade
+ .getToscaElement(vertex.getUniqueId(), filter);
+ if (toscaElement.isRight()) {
+ log.error(
+ "getVerticesToValidate: failed to find element" + vertex.getUniqueId() + " staus is" + toscaElement
+ .right().value());
+ } else {
+ compList.add(toscaElement.left().value());
+ }
+
+ });
+
+ return result;
+ }
+
+ public boolean validate(Map<String, List<Component>> vertices, String outputFilePath) {
+ 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"))) {
+ writer.write("name, UUID, invariantUUID, state, version\n");
+ Collection<List<Component>> collection = vertices.values();
+ for (List<Component> compList : collection) {
+ Set<String> artifactEsId = new HashSet<>();
+ for (Component component : compList) {
+ Map<String, ArtifactDefinition> toscaArtifacts = component.getToscaArtifacts();
+ Optional<ArtifactDefinition> op = toscaArtifacts.values().
+ stream().filter(a -> artifactEsId.contains(a.getEsId())).findAny();
+ if (op.isPresent()) {
+ result = false;
+ writeModuleResultToFile(writer, compList);
+ writer.flush();
+ break;
+ } else {
+ artifactEsId.addAll(toscaArtifacts.values().stream().map(ArtifactDefinition::getEsId)
+ .collect(Collectors.toList()));
+ }
+ }
+
+ }
+
+ } catch (Exception e) {
+ log.error("Failed to fetch vf resources ", e);
+ return false;
+ } finally {
+ janusGraphDao.commit();
+ }
+ return result;
+ }
+
+ private void writeModuleResultToFile(Writer writer, List<Component> components) {
+ 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());
+ }
+ } 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/IArtifactValidatorExecuter.java
index a0d700c67d..1b3c0375e7 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/IArtifactValidatorExecuter.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,9 +21,8 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
public interface IArtifactValidatorExecuter {
- boolean executeValidations();
+
+ boolean executeValidations(String outputFilePath);
+
String getName();
-
-
-
}
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/NodeToscaArtifactsValidatorExecuter.java
index 9fa92200ac..6a52e07dd2 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/NodeToscaArtifactsValidatorExecuter.java
@@ -7,9 +7,9 @@
* 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.
@@ -32,34 +32,33 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class NodeToscaArtifactsValidatorExecuter extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{
- protected String name;
-
- public NodeToscaArtifactsValidatorExecuter(JanusGraphDao janusGraphDao,
- ToscaOperationFacade toscaOperationFacade) {
- super(janusGraphDao, toscaOperationFacade);
- setName("RESOURCE_TOSCA_ARTIFACTS");
- }
- @Override
- public boolean executeValidations() {
-
- Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
- hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
- hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
-
- Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.NODE_TYPE, hasProps);
- return validate(vertices);
-
- }
+public class NodeToscaArtifactsValidatorExecuter extends ArtifactValidatorExecuter implements
+ IArtifactValidatorExecuter {
- @Override
- public String getName() {
- return name;
- }
-
+ protected String name;
- public void setName(String name) {
- this.name = name;
- }
+ public NodeToscaArtifactsValidatorExecuter(JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade) {
+ super(janusGraphDao, toscaOperationFacade);
+ setName("RESOURCE_TOSCA_ARTIFACTS");
+ }
+ @Override
+ public boolean executeValidations(String outputFilePath) {
+ Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
+ hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
+ hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+
+ 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 aad803e672..21a8065dff 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
@@ -7,9 +7,9 @@
* 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.
@@ -34,33 +34,32 @@ import java.util.List;
import java.util.Map;
@org.springframework.stereotype.Component
-public class ServiceToscaArtifactsValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{
-
- @Autowired
- public ServiceToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao,
- ToscaOperationFacade toscaOperationFacade) {
- super(janusGraphDao, toscaOperationFacade);
- setName("SERVICE_TOSCA_ARTIFACTS");
- }
+public class ServiceToscaArtifactsValidatorExecutor extends ArtifactValidatorExecuter implements
+ IArtifactValidatorExecuter {
- @Override
- public boolean executeValidations() {
- Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
- hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
- hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
-
- Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps);
- return validate(vertices);
- }
+ @Autowired
+ public ServiceToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade) {
+ super(janusGraphDao, toscaOperationFacade);
+ setName("SERVICE_TOSCA_ARTIFACTS");
+ }
- @Override
- public String getName() {
- return name;
- }
-
+ @Override
+ public boolean executeValidations(String outputFilePath) {
+ Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
+ hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
+ hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
- public void setName(String name) {
- this.name = name;
- }
+ 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/ServiceValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java
index a52fb370d5..6d580d0bb4 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
@@ -45,9 +45,9 @@ public class ServiceValidatorExecuter extends TopologyTemplateValidatorExecuter
}
@Override
- public boolean executeValidations() {
+ public boolean executeValidations(String outputFilePath) {
List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.SERVICE);
- return validate(tasks, vertices);
+ return validate(tasks, vertices, outputFilePath);
}
@Override
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 ca027cb3ed..b7195dec09 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
@@ -7,9 +7,9 @@
* 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.
@@ -68,34 +68,35 @@ public class TopologyTemplateValidatorExecuter {
protected List<GraphVertex> getVerticesToValidate(ComponentTypeEnum type) {
Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class);
props.put(GraphPropertyEnum.COMPONENT_TYPE, type.name());
- if(type.equals(ComponentTypeEnum.RESOURCE)) {
+ if (type.equals(ComponentTypeEnum.RESOURCE)) {
props.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF);
}
Either<List<GraphVertex>, JanusGraphOperationStatus> results = janusGraphDao
.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, props);
if (results.isRight()) {
- log.error("getVerticesToValidate failed "+ results.right().value());
+ log.error("getVerticesToValidate failed " + results.right().value());
return new ArrayList<>();
}
- log.info("getVerticesToValidate: "+results.left().value().size()+" vertices to scan");
+ log.info("getVerticesToValidate: " + results.left().value().size() + " vertices to scan");
return results.left().value();
}
- protected boolean validate(List<? extends TopologyTemplateValidationTask> tasks, List<GraphVertex> vertices) {
- ReportManager.reportStartValidatorRun(getName(), vertices.size());
+ protected boolean validate(List<? extends TopologyTemplateValidationTask> tasks, List<GraphVertex> vertices,
+ String outputFilePath) {
+ ReportManager.reportStartValidatorRun(getName(), vertices.size(), outputFilePath);
Set<String> failedTasks = new HashSet<>();
Set<String> successTasks = new HashSet<>();
boolean successAllVertices = true;
int vertexNum = 0;
int verticesSize = vertices.size();
- for (GraphVertex vertex: vertices) {
+ for (GraphVertex vertex : vertices) {
vertexNum++;
boolean successAllTasks = true;
- for (TopologyTemplateValidationTask task: tasks) {
- ReportManager.reportStartTaskRun(vertex, task.getTaskName());
- VertexResult result = task.validate(vertex);
+ for (TopologyTemplateValidationTask task : tasks) {
+ ReportManager.reportStartTaskRun(vertex, task.getTaskName(), outputFilePath);
+ VertexResult result = task.validate(vertex, outputFilePath);
if (!result.getStatus()) {
failedTasks.add(task.getTaskName());
successAllVertices = false;
@@ -103,13 +104,13 @@ public class TopologyTemplateValidatorExecuter {
} else if (successAllTasks && vertexNum == verticesSize) {
successTasks.add(task.getTaskName());
}
- ReportManager.printValidationTaskStatus(vertex, task.getTaskName(), result.getStatus());
+ ReportManager.printValidationTaskStatus(vertex, task.getTaskName(), result.getStatus(), outputFilePath);
ReportManager.reportTaskEnd(vertex.getUniqueId(), task.getTaskName(), result);
}
- String componentScanStatus = successAllTasks? "success" : "failed";
- log.info("Topology Template "+vertex.getUniqueId()+" Validation finished with "+componentScanStatus);
+ String componentScanStatus = successAllTasks ? "success" : "failed";
+ log.info("Topology Template " + vertex.getUniqueId() + " Validation finished with " + componentScanStatus);
}
- ReportManager.reportValidatorTypeSummary(getName(), failedTasks, successTasks);
+ ReportManager.reportValidatorTypeSummary(getName(), failedTasks, successTasks, outputFilePath);
return successAllVertices;
}
}
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 f1c9af681c..b5347a2579 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
@@ -7,9 +7,9 @@
* 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.
@@ -33,35 +33,32 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class VFToscaArtifactValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter{
-
- public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao,
- ToscaOperationFacade toscaOperationFacade) {
- super(janusGraphDao, toscaOperationFacade);
- setName("VF_TOSCA_ARTIFACTS");
- }
- @Override
- public boolean executeValidations() {
-
- Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
- hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
- hasProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF);
- hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
-
- Map<String, List<Component>> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps);
- return validate( vertices);
-
- }
+public class VFToscaArtifactValidatorExecutor extends ArtifactValidatorExecuter implements IArtifactValidatorExecuter {
- @Override
- public String getName() {
- return name;
- }
-
+ public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao,
+ ToscaOperationFacade toscaOperationFacade) {
+ super(janusGraphDao, toscaOperationFacade);
+ setName("VF_TOSCA_ARTIFACTS");
+ }
- public void setName(String name) {
- this.name = name;
- }
-
+ @Override
+ public boolean executeValidations(String outputFilePath) {
+ Map<GraphPropertyEnum, Object> hasProps = new HashMap<>();
+ hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
+ hasProps.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF);
+ hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ 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/ValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java
index 3164b6c625..db41cb57a8 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 @@ package org.openecomp.sdc.asdctool.impl.validator.executers;
*/
public interface ValidatorExecuter {
- boolean executeValidations();
+ boolean executeValidations(String outputFilePath);
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 181495ad44..dc4ebabf5c 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
@@ -43,9 +43,9 @@ public class VfValidatorExecuter extends TopologyTemplateValidatorExecuter imple
}
@Override
- public boolean executeValidations() {
+ public boolean executeValidations(String outputFilePath) {
List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.RESOURCE);
- return validate(tasks, vertices);
+ return validate(tasks, vertices, outputFilePath);
}
@Override
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 ee05d586f9..576848dcdc 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
@@ -27,7 +27,7 @@ import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
* Created by chaya on 7/5/2017.
*/
public interface TopologyTemplateValidationTask {
- VertexResult validate(GraphVertex vertex);
+ VertexResult validate(GraphVertex vertex, String outputFilePath);
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 11c80eae70..6da79cf681 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
@@ -60,13 +60,14 @@ public class ArtifactValidationUtils {
this.topologyTemplateOperation = topologyTemplateOperation;
}
- public ArtifactsVertexResult validateArtifactsAreInCassandra(GraphVertex vertex, String taskName, List<ArtifactDataDefinition> artifacts) {
+ public ArtifactsVertexResult validateArtifactsAreInCassandra(GraphVertex vertex, String taskName,
+ List<ArtifactDataDefinition> artifacts, String outputFilePath) {
ArtifactsVertexResult result = new ArtifactsVertexResult(true);
- for(ArtifactDataDefinition artifact:artifacts) {
+ 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);
+ "Artifact " + artifact.getEsId() + " doesn't exist in Cassandra";
+ ReportManager.writeReportLineToFile(status, outputFilePath);
if (!isArtifactExist) {
ReportManager.addFailedVertex(taskName, vertex.getUniqueId());
result.setStatus(false);
@@ -97,13 +98,15 @@ public class ArtifactValidationUtils {
return artifacts;
}
- public ArtifactsVertexResult validateTopologyTemplateArtifacts(GraphVertex vertex, String taskName) {
+ public ArtifactsVertexResult validateTopologyTemplateArtifacts(GraphVertex vertex, String taskName,
+ String outputFilePath) {
ArtifactsVertexResult result = new ArtifactsVertexResult();
ComponentParametersView paramView = new ComponentParametersView();
paramView.disableAll();
paramView.setIgnoreArtifacts(false);
paramView.setIgnoreComponentInstances(false);
- Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation.getToscaElement(vertex.getUniqueId(), paramView);
+ Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation
+ .getToscaElement(vertex.getUniqueId(), paramView);
if (toscaElementEither.isRight()) {
result.setStatus(false);
return result;
@@ -123,14 +126,14 @@ public class ArtifactValidationUtils {
if (instanceArtifacts != null) {
instanceArtifacts.forEach((key, artifactMap) ->
- allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition())));
+ allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition())));
}
if (instanceDeploymentArtifacts != null) {
instanceDeploymentArtifacts.forEach((key, artifactMap) ->
- allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition())));
+ allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition())));
}
- return validateArtifactsAreInCassandra(vertex, taskName, allArtifacts);
+ return validateArtifactsAreInCassandra(vertex, taskName, allArtifacts, outputFilePath);
}
}
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 3b47a81c40..7caaa3cfa4 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
@@ -39,7 +39,7 @@ public class ServiceArtifactValidationTask extends ServiceValidationTask {
}
@Override
- public ArtifactsVertexResult validate(GraphVertex vertex) {
- return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName());
+ public ArtifactsVertexResult validate(GraphVertex vertex, String outputFilePath) {
+ return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName(), outputFilePath);
}
}
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 c445521f53..eb65b0c04c 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
@@ -40,7 +40,7 @@ public class VfArtifactValidationTask extends VfValidationTask {
}
@Override
- public VertexResult validate(GraphVertex vertex) {
- return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName());
+ public VertexResult validate(GraphVertex vertex, String outputFilePath) {
+ return artifactValidationUtils.validateTopologyTemplateArtifacts(vertex, getTaskName(), outputFilePath);
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
index d45c896799..47f00dc421 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTask.java
@@ -7,9 +7,9 @@
* 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.
@@ -59,7 +59,7 @@ public class ModuleJsonTask extends ServiceValidationTask {
}
@Override
- public VertexResult validate(GraphVertex vertex) {
+ public VertexResult validate(GraphVertex vertex, String outputFilePath) {
if (!isAfterSubmitForTesting(vertex)) {
return new VertexResult(true);
}
@@ -69,7 +69,8 @@ public class ModuleJsonTask extends ServiceValidationTask {
paramView.setIgnoreArtifacts(false);
paramView.setIgnoreGroups(false);
paramView.setIgnoreComponentInstances(false);
- Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation.getToscaElement(vertex.getUniqueId(), paramView);
+ Either<ToscaElement, StorageOperationStatus> toscaElementEither = topologyTemplateOperation
+ .getToscaElement(vertex.getUniqueId(), paramView);
if (toscaElementEither.isRight()) {
return new VertexResult(false);
}
@@ -77,42 +78,47 @@ public class ModuleJsonTask extends ServiceValidationTask {
Map<String, MapGroupsDataDefinition> instGroups = element.getInstGroups();
Map<String, MapArtifactDataDefinition> instDeploymentArtifacts = element.getInstDeploymentArtifacts();
- for (Map.Entry<String, MapGroupsDataDefinition> pair : Optional.ofNullable(instGroups).orElse(Collections.emptyMap()).entrySet()) {
+ for (Map.Entry<String, MapGroupsDataDefinition> pair : Optional.ofNullable(instGroups)
+ .orElse(Collections.emptyMap()).entrySet()) {
MapGroupsDataDefinition groups = pair.getValue();
if (groups != null && !groups.getMapToscaDataDefinition().isEmpty()) {
- return new VertexResult(findCoordinateModuleJson(pair, instDeploymentArtifacts, vertex));
+ return new VertexResult(findCoordinateModuleJson(pair, instDeploymentArtifacts, vertex, outputFilePath));
}
return new VertexResult(true);
}
return new VertexResult(true);
}
- private boolean findCoordinateModuleJson(Map.Entry<String, MapGroupsDataDefinition> pair, Map<String, MapArtifactDataDefinition> instDeploymentArtifacts, GraphVertex vertex) {
+ private boolean findCoordinateModuleJson(Map.Entry<String, MapGroupsDataDefinition> pair,
+ Map<String, MapArtifactDataDefinition> instDeploymentArtifacts, GraphVertex vertex, String outputFilePath) {
String groupKey = pair.getKey();
String[] split = groupKey.split("\\.");
- String instanceName = split[split.length-1];
+ 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();
- if (artifactName.startsWith(instanceName) && artifactName.endsWith("modules.json")) {
- return true;
- }
- return false;
- }).collect(Collectors.toList());
+ List<ArtifactDataDefinition> moduleJsonArtifacts = deploymentsArtifacts.getMapToscaDataDefinition().values()
+ .stream().filter(artifact -> {
+ String artifactName = artifact.getArtifactName();
+ if (artifactName.startsWith(instanceName) && artifactName.endsWith("modules.json")) {
+ return true;
+ }
+ return false;
+ }).collect(Collectors.toList());
if (moduleJsonArtifacts.size() > 0) {
- String status = "Instance "+instanceName+" has a corresponding modules.json file: "+moduleJsonArtifacts.get(0).getArtifactName();
- ReportManager.writeReportLineToFile(status);
+ String status =
+ "Instance " + instanceName + " has a corresponding modules.json file: " + moduleJsonArtifacts.get(0)
+ .getArtifactName();
+ ReportManager.writeReportLineToFile(status, outputFilePath);
return true;
}
}
- String status = "Instance "+instanceName+" doesn't have a corresponding modules.json file";
- ReportManager.writeReportLineToFile(status);
+ String status = "Instance " + instanceName + " doesn't have a corresponding modules.json file";
+ ReportManager.writeReportLineToFile(status, outputFilePath);
ReportManager.addFailedVertex(getTaskName(), vertex.getUniqueId());
return false;
}
- private boolean isAfterSubmitForTesting(GraphVertex vertex){
+ private boolean isAfterSubmitForTesting(GraphVertex vertex) {
List allowedStates = new ArrayList<>(Arrays.asList(LifecycleStateEnum.CERTIFIED.name()));
return allowedStates.contains(vertex.getMetadataProperty(GraphPropertyEnum.STATE));
}
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 feef9eaf01..78910df439 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
@@ -22,7 +22,6 @@
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,28 +39,27 @@ import java.util.Set;
public class ReportManager {
private static Logger log = LoggerFactory.getLogger(ReportManager.class);
- private static String reportOutputFilePath;
+
private static final Map<String, Set<String>> failedVerticesPerTask = new HashMap<>();
private static final Map<String, Map<String, VertexResult>> resultsPerVertex = new HashMap<>();
- public static ReportManager make(String csvReportFilePath) {
- return new ReportManager(csvReportFilePath);
+ public static ReportManager make(String csvReportFilePath, String txtReportFilePath) {
+ return new ReportManager(csvReportFilePath, txtReportFilePath);
}
- private ReportManager(String csvReportFilePath) {
+ private ReportManager(String csvReportFilePath, String txtReportFilePath) {
try {
initCsvFile(csvReportFilePath);
- initReportFile();
+ initReportFile(txtReportFilePath);
} catch (IOException e) {
log.info("Init file failed - {}", e.getClass().getSimpleName(), e);
}
}
- private void initReportFile() throws IOException {
- reportOutputFilePath = ValidationConfigManager.getOutputFullFilePath();
+ private void initReportFile(String txtReportFilePath) throws IOException {
StrBuilder sb = new StrBuilder();
sb.appendln("-----------------------Validation Tool Results:-------------------------");
- Files.write(Paths.get(reportOutputFilePath), sb.toString().getBytes());
+ Files.write(Paths.get(txtReportFilePath), sb.toString().getBytes());
}
private void initCsvFile(String csvReportFilePath) throws IOException {
@@ -87,51 +85,52 @@ public class ReportManager {
failedVerticesPerTask.put(taskName, failedVertices);
}
- public static void printValidationTaskStatus(GraphVertex vertexScanned, String taskName, boolean success) {
+ public static void printValidationTaskStatus(GraphVertex vertexScanned, String taskName, boolean success,
+ String outputFilePath) {
String successStatus = success ? "success" : "failed";
String line =
"-----------------------Vertex: " + vertexScanned.getUniqueId() + ", Task " + taskName + " " + successStatus
+ "-----------------------";
StrBuilder sb = new StrBuilder();
sb.appendln(line);
- writeReportLineToFile(line);
+ writeReportLineToFile(line, outputFilePath);
}
- public static void writeReportLineToFile(String message) {
+ public static void writeReportLineToFile(String message, String outputFilePath) {
try {
- Files.write(Paths.get(reportOutputFilePath), new StrBuilder().appendNewLine().toString().getBytes(),
+ Files.write(Paths.get(outputFilePath), new StrBuilder().appendNewLine().toString().getBytes(),
StandardOpenOption.APPEND);
- Files.write(Paths.get(reportOutputFilePath), message.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);
}
}
public static void reportValidatorTypeSummary(String validatorName, Set<String> failedTasksNames,
- Set<String> successTasksNames) {
+ Set<String> successTasksNames, String outputFilePath) {
StrBuilder sb = new StrBuilder();
sb.appendln(
"-----------------------ValidatorExecuter " + validatorName + " Validation Summary-----------------------");
sb.appendln("Failed tasks: " + failedTasksNames);
sb.appendln("Success tasks: " + successTasksNames);
- writeReportLineToFile(sb.toString());
+ writeReportLineToFile(sb.toString(), outputFilePath);
}
- public static void reportStartValidatorRun(String validatorName, int componenentsNum) {
+ public static void reportStartValidatorRun(String validatorName, int componenentsNum, String outputFilePath) {
StrBuilder sb = new StrBuilder();
sb.appendln("------ValidatorExecuter " + validatorName + " Validation Started, on " + componenentsNum
+ " components---------");
- writeReportLineToFile(sb.toString());
+ writeReportLineToFile(sb.toString(), outputFilePath);
}
- public static void reportStartTaskRun(GraphVertex vertex, String taskName) {
+ public static void reportStartTaskRun(GraphVertex vertex, String taskName, String outputFilePath) {
StrBuilder sb = new StrBuilder();
sb.appendln("-----------------------Vertex: " + vertex.getUniqueId() + ", Task " + taskName
+ " Started-----------------------");
- writeReportLineToFile(sb.toString());
+ writeReportLineToFile(sb.toString(), outputFilePath);
}
- public static void reportEndOfToolRun(String csvReportFilePath) {
+ public static void reportEndOfToolRun(String csvReportFilePath, String outputFilePath) {
StrBuilder sb = new StrBuilder();
sb.appendln("-----------------------------------Validator Tool Summary-----------------------------------");
failedVerticesPerTask.forEach((taskName, failedVertices) -> {
@@ -140,7 +139,7 @@ public class ReportManager {
sb.append("FailedVertices: " + failedVertices);
sb.appendNewLine();
});
- writeReportLineToFile(sb.toString());
+ writeReportLineToFile(sb.toString(), outputFilePath);
printAllResults(csvReportFilePath);
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java
index 063f3f6a29..0978f4ebd7 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/ArtifactValidatorTool.java
@@ -31,14 +31,14 @@ public class ArtifactValidatorTool {
public static void main(String[] args) {
String outputPath = args[0];
- ValidationConfigManager.setOutputFullFilePath(outputPath);
+ String txtReportFilePath = ValidationConfigManager.txtReportFilePath(outputPath);
String appConfigDir = args[1];
AnnotationConfigApplicationContext context = initContext(appConfigDir);
ArtifactToolBL validationToolBL = context.getBean(ArtifactToolBL.class);
System.out.println("Start ArtifactValidation Tool");
- Boolean result = validationToolBL.validateAll();
+ Boolean result = validationToolBL.validateAll(txtReportFilePath);
if (result) {
System.out.println("ArtifactValidation finished successfully");
System.exit(0);
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 23b9c18d3f..d98a26b7ed 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
@@ -41,7 +41,7 @@ public class ValidationTool {
public static void main(String[] args) {
String outputPath = args[0];
- ValidationConfigManager.setOutputFullFilePath(outputPath);
+ String txtReportFilePath = ValidationConfigManager.txtReportFilePath(outputPath);
String csvReportFilePath = ValidationConfigManager.csvReportFilePath(outputPath, System::currentTimeMillis);
String appConfigDir = args[1];
@@ -49,8 +49,8 @@ public class ValidationTool {
ValidationToolBL validationToolBL = context.getBean(ValidationToolBL.class);
log.info("Start Validation Tool");
- boolean result = validationToolBL.validateAll();
- ReportManager.reportEndOfToolRun(csvReportFilePath);
+ boolean result = validationToolBL.validateAll(txtReportFilePath);
+ ReportManager.reportEndOfToolRun(csvReportFilePath, txtReportFilePath);
if (result) {
log.info("Validation finished successfully");
System.exit(0);
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 ee41d626b2..e6ae05f493 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
@@ -7,9 +7,9 @@
* 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,35 +20,32 @@
package org.openecomp.sdc.asdctool.impl.validator;
+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.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-import java.util.ArrayList;
-import java.util.LinkedList;
-
-import static org.mockito.Mockito.mock;
-
public class ArtifactToolBLTest {
- private ArtifactToolBL createTestSubject() {
- return new ArtifactToolBL(new ArrayList<>());
- }
-
- //Generated test
- @Test(expected=NullPointerException.class)
- public void testValidateAll() throws Exception {
- ArtifactToolBL testSubject;
- boolean result;
-
- // default test
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
-
- testSubject = createTestSubject();
- testSubject.validators = new LinkedList();
- testSubject.validators.add(new NodeToscaArtifactsValidatorExecuter(janusGraphDaoMock,toscaOperationFacade));
- result = testSubject.validateAll();
- }
+ private ArtifactToolBL createTestSubject() {
+ return new ArtifactToolBL(new ArrayList<>());
+ }
+
+ //Generated test
+ @Test(expected = NullPointerException.class)
+ public void testValidateAll() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+
+ ArtifactToolBL testSubject = createTestSubject();
+ testSubject.validators = new LinkedList<>();
+ testSubject.validators.add(new NodeToscaArtifactsValidatorExecuter(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 f7f8307638..b412d7bc92 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
@@ -7,9 +7,9 @@
* 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.
@@ -31,20 +31,18 @@ import static org.mockito.Mockito.mock;
public class ValidationToolBLTest {
- private ValidationToolBL createTestSubject() {
- return new ValidationToolBL(new ArrayList<>());
- }
-
- @Test(expected=NullPointerException.class)
- public void testValidateAll() throws Exception {
- ValidationToolBL testSubject;
- boolean result;
-
- // default test
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- testSubject = createTestSubject();
- testSubject.validators = new LinkedList<>();
- testSubject.validators.add(new ServiceValidatorExecuter(janusGraphDaoMock));
- result = testSubject.validateAll();
- }
+ private ValidationToolBL createTestSubject() {
+ return new ValidationToolBL(new ArrayList<>());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testValidateAll() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ ValidationToolBL testSubject = createTestSubject();
+ testSubject.validators = new LinkedList<>();
+ testSubject.validators.add(new ServiceValidatorExecuter(janusGraphDaoMock));
+ // 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/config/ValidationConfigManagerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java
index 570e5b21df..b763520318 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java
@@ -7,9 +7,9 @@
* 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,9 +20,11 @@
package org.openecomp.sdc.asdctool.impl.validator.config;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager.csvReportFilePath;
+import static org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager.txtReportFilePath;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,13 +32,17 @@ import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import java.util.Properties;
-
@RunWith(PowerMockRunner.class)
@PrepareForTest({ReportManager.class})
public class ValidationConfigManagerTest {
@Test
+ public void testTxtReportFilePath() {
+ String randomOutput = System.currentTimeMillis() + "";
+ assertThat(txtReportFilePath(randomOutput), equalTo(randomOutput + "/reportOutput.txt"));
+ }
+
+ @Test
public void testCsvReportFilePath() {
String randomOutput = System.currentTimeMillis() + "";
long millis = System.currentTimeMillis();
@@ -44,28 +50,4 @@ public class ValidationConfigManagerTest {
csvReportFilePath(randomOutput, () -> millis),
is(randomOutput + "/csvSummary_" + millis + ".csv"));
}
-
- @Test
- public void testGetOutputFilePath() {
- String result;
-
- // default test
- result = ValidationConfigManager.getOutputFilePath();
- }
-
- @Test
- public void testGetOutputFullFilePath() throws Exception {
- String result;
-
- // default test
- result = ValidationConfigManager.getOutputFullFilePath();
- }
-
- @Test
- public void testSetOutputFullFilePath() throws Exception {
- String outputPath = "";
-
- // default test
- ValidationConfigManager.setOutputFullFilePath(outputPath);
- }
}
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/ArtifactValidatorExecuterTest.java
index 176a0ca79c..46fae4312d 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/ArtifactValidatorExecuterTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -38,56 +38,58 @@ import static org.mockito.Mockito.mock;
public class ArtifactValidatorExecuterTest {
- private ArtifactValidatorExecuter createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ private ArtifactValidatorExecuter createTestSubject() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
- return new ArtifactValidatorExecuter(janusGraphDaoMock, toscaOperationFacade);
- }
+ return new ArtifactValidatorExecuter(janusGraphDaoMock, toscaOperationFacade);
+ }
- @Test
- public void testGetName() throws Exception {
- ArtifactValidatorExecuter testSubject;
- String result;
+ @Test
+ public void testGetName() throws Exception {
+ ArtifactValidatorExecuter testSubject;
+ String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
+ // 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;
+ @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);
- }
+ // default test
+ testSubject = createTestSubject();
+ testSubject.getVerticesToValidate(type, hasProps);
+ }
- @Test
- public void testSetName() throws Exception {
- ArtifactValidatorExecuter testSubject;
- String name = "";
+ @Test
+ public void testSetName() throws Exception {
+ ArtifactValidatorExecuter testSubject;
+ String name = "";
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setName(name);
+ }
- @Test
- public void testValidate() {
- ArtifactValidatorExecuter testSubject;
- Map<String, List<Component>> vertices = new HashMap<>();
- LinkedList<Component> linkedList = new LinkedList<Component>();
- linkedList.add(new Resource());
- vertices.put("stam", linkedList);
- boolean result;
+ @Test
+ public void testValidate() {
+ ArtifactValidatorExecuter testSubject;
+ Map<String, List<Component>> vertices = new HashMap<>();
+ LinkedList<Component> linkedList = new LinkedList<Component>();
+ linkedList.add(new Resource());
+ vertices.put("stam", linkedList);
+ boolean result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.validate(vertices);
- Assert.assertFalse(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);
+ }
}
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
index e84b89af71..c9c90b2aa4 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -28,40 +28,37 @@ import static org.mockito.Mockito.mock;
public class NodeToscaArtifactsValidatorExecuterTest {
- private NodeToscaArtifactsValidatorExecuter createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ 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() throws Exception {
- NodeToscaArtifactsValidatorExecuter testSubject;
- boolean result;
+ return new NodeToscaArtifactsValidatorExecuter(janusGraphDaoMock, toscaOperationFacade);
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.executeValidations();
- }
+ @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;
+ @Test
+ public void testGetName() throws Exception {
+ NodeToscaArtifactsValidatorExecuter testSubject;
+ String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getName();
+ }
- @Test
- public void testSetName() throws Exception {
- NodeToscaArtifactsValidatorExecuter testSubject;
- String name = "";
+ @Test
+ public void testSetName() throws Exception {
+ NodeToscaArtifactsValidatorExecuter testSubject;
+ String name = "";
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setName(name);
+ }
}
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 51f1cc63da..1e24867358 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
@@ -7,9 +7,9 @@
* 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.
@@ -28,40 +28,37 @@ import static org.mockito.Mockito.mock;
public class ServiceToscaArtifactsValidatorExecutorTest {
- private ServiceToscaArtifactsValidatorExecutor createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ private ServiceToscaArtifactsValidatorExecutor createTestSubject() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
- return new ServiceToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade);
- }
+ return new ServiceToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade);
+ }
- @Test(expected = NullPointerException.class)
- public void testExecuteValidations() throws Exception {
- ServiceToscaArtifactsValidatorExecutor testSubject;
- boolean result;
+ @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);
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.executeValidations();
- }
+ @Test
+ public void testGetName() throws Exception {
+ ServiceToscaArtifactsValidatorExecutor testSubject;
+ String result;
- @Test
- public void testGetName() throws Exception {
- ServiceToscaArtifactsValidatorExecutor testSubject;
- String result;
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getName();
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
+ @Test
+ public void testSetName() throws Exception {
+ ServiceToscaArtifactsValidatorExecutor testSubject;
+ String name = "";
- @Test
- public void testSetName() throws Exception {
- ServiceToscaArtifactsValidatorExecutor testSubject;
- String name = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setName(name);
+ }
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
index 16e36369e6..a1728d8a94 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,28 +27,20 @@ import static org.mockito.Mockito.mock;
public class ServiceValidatorExecuterTest {
- private ServiceValidatorExecuter createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- return new ServiceValidatorExecuter(janusGraphDaoMock);
- }
-
- @Test
- public void testGetName() {
- ServiceValidatorExecuter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test(expected=NullPointerException.class)
- public void testExecuteValidations() throws Exception {
- ServiceValidatorExecuter testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.executeValidations();
- }
+ private ServiceValidatorExecuter createTestSubject() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ return new ServiceValidatorExecuter(janusGraphDaoMock);
+ }
+
+ @Test
+ public void testGetName() {
+ createTestSubject().getName();
+ }
+
+ @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);
+ }
}
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 c8edb7d05a..783b888dec 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
@@ -7,9 +7,9 @@
* 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.
@@ -29,40 +29,42 @@ import static org.mockito.Mockito.mock;
public class VFToscaArtifactValidatorExecutorTest {
- private VFToscaArtifactValidatorExecutor createTestSubject() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+ private VFToscaArtifactValidatorExecutor createTestSubject() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
- return new VFToscaArtifactValidatorExecutor(janusGraphDaoMock, toscaOperationFacade);
- }
+ return new VFToscaArtifactValidatorExecutor(janusGraphDaoMock, toscaOperationFacade);
+ }
- @Test
- public void testExecuteValidations() {
- VFToscaArtifactValidatorExecutor testSubject;
- boolean result;
+ @Test
+ public void testExecuteValidations() {
+ VFToscaArtifactValidatorExecutor testSubject;
+ boolean result;
- // default test
- testSubject = createTestSubject();
- Assertions.assertThrows(NullPointerException.class, () -> testSubject.executeValidations());
- }
+ // 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;
+ @Test
+ public void testGetName() throws Exception {
+ VFToscaArtifactValidatorExecutor testSubject;
+ String result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getName();
+ }
- @Test
- public void testSetName() throws Exception {
- VFToscaArtifactValidatorExecutor testSubject;
- String name = "";
+ @Test
+ public void testSetName() throws Exception {
+ VFToscaArtifactValidatorExecutor testSubject;
+ String name = "";
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
- }
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setName(name);
+ }
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
index 457c9b0d19..c9bc5debd6 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -31,30 +31,22 @@ import static org.mockito.Mockito.mock;
public class VfValidatorExecuterTest {
- private VfValidatorExecuter createTestSubject() {
- List<VfValidationTask> validationTasks = new ArrayList<>();
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ private VfValidatorExecuter createTestSubject() {
+ List<VfValidationTask> validationTasks = new ArrayList<>();
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- return new VfValidatorExecuter(validationTasks, janusGraphDaoMock);
- }
+ return new VfValidatorExecuter(validationTasks, janusGraphDaoMock);
+ }
- @Test
- public void testGetName() {
- VfValidatorExecuter testSubject;
- String result;
+ @Test
+ public void testGetName() {
+ createTestSubject().getName();
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test(expected=NullPointerException.class)
- public void testExecuteValidations() throws Exception {
- VfValidatorExecuter testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.executeValidations();
- }
+ @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);
+ }
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
index 1af4a13472..99733a7bd3 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
@@ -50,7 +50,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import java.util.stream.IntStream;
import static org.junit.Assert.assertEquals;
@@ -93,13 +92,10 @@ public class ArtifactValidationUtilsTest {
private final static String resourcePath = new File("src/test/resources").getAbsolutePath();
private final static String csvReportFilePath = ValidationConfigManager.DEFAULT_CSV_PATH;
+ private final static String txtReportFilePath = ValidationConfigManager.txtReportFilePath(resourcePath);
public void initReportManager() {
- String resourcePath = new File(Objects
- .requireNonNull(ArtifactValidationUtilsTest.class.getClassLoader().getResource(""))
- .getFile()).getAbsolutePath();
- ValidationConfigManager.setOutputFullFilePath(resourcePath);
- ReportManager.make(csvReportFilePath);
+ ReportManager.make(csvReportFilePath, txtReportFilePath);
}
@Before
@@ -118,7 +114,7 @@ public class ArtifactValidationUtilsTest {
@After
public void clean() {
- ReportManagerHelper.cleanReports(csvReportFilePath);
+ ReportManagerHelper.cleanReports(csvReportFilePath, txtReportFilePath);
}
@Test
@@ -129,9 +125,9 @@ public class ArtifactValidationUtilsTest {
// when
ArtifactsVertexResult result =
- testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts);
+ testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertTrue(result.getStatus());
@@ -148,10 +144,10 @@ public class ArtifactValidationUtilsTest {
// when
ArtifactsVertexResult result =
- testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts);
- ReportManager.reportEndOfToolRun(csvReportFilePath);
+ testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts, txtReportFilePath);
+ ReportManager.reportEndOfToolRun(csvReportFilePath, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertFalse(result.getStatus());
@@ -225,9 +221,9 @@ public class ArtifactValidationUtilsTest {
// when
ArtifactsVertexResult result =
- testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME);
+ testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertTrue(result.getStatus());
@@ -245,7 +241,7 @@ public class ArtifactValidationUtilsTest {
// when
ArtifactsVertexResult result =
- testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME);
+ testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME, txtReportFilePath);
// then
assertFalse(result.getStatus());
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
index 0aab99237b..cf28d74803 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,26 +21,28 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
import org.junit.Test;
+import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
public class ServiceArtifactValidationTaskTest {
- private ServiceArtifactValidationTask createTestSubject() {
- ArtifactValidationUtils artifactValidationUtilsMock = mock(ArtifactValidationUtils.class);
- return new ServiceArtifactValidationTask(artifactValidationUtilsMock);
- }
-
- @Test
- public void testValidate() throws Exception {
- ServiceArtifactValidationTask testSubject;
- GraphVertex vertex = null;
- ArtifactsVertexResult result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.validate(vertex);
- }
-
+ private ServiceArtifactValidationTask createTestSubject() {
+ ArtifactValidationUtils artifactValidationUtilsMock = mock(ArtifactValidationUtils.class);
+ return new ServiceArtifactValidationTask(artifactValidationUtilsMock);
+ }
+
+ @Test
+ public void testValidate() {
+ GraphVertex vertex = null;
+ ServiceArtifactValidationTask 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
+ VertexResult actual = testSubject.validate(vertex, null);
+ assertThat(actual, is(nullValue()));
+ }
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
index 0dba9569ac..5302f4f23e 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -24,24 +24,25 @@ import org.junit.Test;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
public class VfArtifactValidationTaskTest {
- private VfArtifactValidationTask createTestSubject() {
- ArtifactValidationUtils artifactValidationUtilsMock = mock(ArtifactValidationUtils.class);
- return new VfArtifactValidationTask(artifactValidationUtilsMock);
- }
-
- @Test
- public void testValidate() throws Exception {
- VfArtifactValidationTask testSubject;
- GraphVertex vertex = null;
- VertexResult result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.validate(vertex);
- }
-
+ private VfArtifactValidationTask createTestSubject() {
+ ArtifactValidationUtils artifactValidationUtilsMock = mock(ArtifactValidationUtils.class);
+ return new VfArtifactValidationTask(artifactValidationUtilsMock);
+ }
+
+ @Test
+ public void testValidate() {
+ GraphVertex vertex = null;
+ VfArtifactValidationTask 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
+ VertexResult actual = testSubject.validate(vertex, null);
+ assertThat(actual, is(nullValue()));
+ }
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
index 33ebd09159..9a9f20bcc7 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,6 +27,7 @@ import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+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;
import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
@@ -41,6 +42,8 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOper
import java.util.HashMap;
import java.util.Map;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -80,11 +83,17 @@ public class ModuleJsonTaskTest {
TopologyTemplate topologyTemplate = new TopologyTemplate();
topologyTemplate.setInstGroups(instGroups);
topologyTemplate.setInstDeploymentArtifacts(instDeploymentArtifacts);
- when(topologyTemplateOperation.getToscaElement(ArgumentMatchers.eq(vertex.getUniqueId()), ArgumentMatchers.any(ComponentParametersView.class))).thenReturn(Either.left(topologyTemplate));
+ when(topologyTemplateOperation.getToscaElement(ArgumentMatchers.eq(vertex.getUniqueId()),
+ ArgumentMatchers.any(ComponentParametersView.class))).thenReturn(Either.left(topologyTemplate));
+
+ // 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
try {
- test.validate(vertex);
+ VertexResult actual = test.validate(vertex, null);
+ assertThat(actual.getStatus(), is(true));
} catch (Exception e) {
-
+ // TODO: Fix this test, as currently, any exception is ignored
+ // This will be addressed in another change
}
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
index 011039d591..938b2c2202 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
-import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
@@ -34,17 +32,17 @@ public class ReportManagerHelper {
private ReportManagerHelper() {
}
- public static List<String> getReportOutputFileAsList() {
- return readFileAsList(ValidationConfigManager.getOutputFullFilePath());
+ public static List<String> getReportOutputFileAsList(String txtReportFilePath) {
+ return readFileAsList(txtReportFilePath);
}
public static List<String> getReportCsvFileAsList(String csvReportFilePath) {
return readFileAsList(csvReportFilePath);
}
- public static void cleanReports(String csvReportFilePath) {
+ public static void cleanReports(String csvReportFilePath, String txtReportFilePath) {
cleanFile(csvReportFilePath);
- cleanFile(ValidationConfigManager.getOutputFullFilePath());
+ cleanFile(txtReportFilePath);
}
private static List<String> readFileAsList(String filePath) {
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
index 22aaf6e539..6be7f472aa 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
@@ -77,25 +77,20 @@ public class ReportManagerTest {
private final static String resourcePath = new File("src/test/resources").getAbsolutePath();
private final static String csvReportFilePath = ValidationConfigManager
.csvReportFilePath(resourcePath, System::currentTimeMillis);
-
+ private final static String txtReportFilePath = ValidationConfigManager.txtReportFilePath(resourcePath);
@Mock
GraphVertex vertexScanned;
@Before
public void setup() {
- String resourcePath = new File(Objects
- .requireNonNull(ReportManagerTest.class.getClassLoader().getResource("")).getFile())
- .getAbsolutePath();
- ValidationConfigManager.setOutputFullFilePath(resourcePath);
- ReportManager.make(csvReportFilePath);
-
+ ReportManager.make(csvReportFilePath, txtReportFilePath);
successResult.setStatus(true);
}
@After
public void clean() {
- ReportManagerHelper.cleanReports(csvReportFilePath);
+ ReportManagerHelper.cleanReports(csvReportFilePath, txtReportFilePath);
}
@Test
@@ -118,9 +113,9 @@ public class ReportManagerTest {
public void testAddFailedVertex() {
// when
ReportManager.addFailedVertex(TASK_1_NAME, VERTEX_1_ID);
- ReportManager.reportEndOfToolRun(csvReportFilePath);
+ ReportManager.reportEndOfToolRun(csvReportFilePath, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertNotNull(reportOutputFile);
@@ -137,9 +132,9 @@ public class ReportManagerTest {
when(vertexScanned.getUniqueId()).thenReturn(UNIQUE_ID);
// when
- ReportManager.printValidationTaskStatus(vertexScanned, TASK_1_NAME, false);
+ ReportManager.printValidationTaskStatus(vertexScanned, TASK_1_NAME, false, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertNotNull(reportOutputFile);
@@ -152,9 +147,9 @@ public class ReportManagerTest {
@Test
public void testWriteReportLineToFile() {
// when
- ReportManager.writeReportLineToFile(DUMMY_MESSAGE);
+ ReportManager.writeReportLineToFile(DUMMY_MESSAGE, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertNotNull(reportOutputFile);
@@ -166,9 +161,10 @@ public class ReportManagerTest {
@Test
public void testReportValidatorTypeSummary() {
// when
- ReportManager.reportValidatorTypeSummary(VALIDATOR_NAME, failedTasksNames, successTasksNames);
+ ReportManager
+ .reportValidatorTypeSummary(VALIDATOR_NAME, failedTasksNames, successTasksNames, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertNotNull(reportOutputFile);
@@ -185,9 +181,9 @@ public class ReportManagerTest {
@Test
public void testReportStartValidatorRun() {
// when
- ReportManager.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM);
+ ReportManager.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertNotNull(reportOutputFile);
@@ -202,9 +198,9 @@ public class ReportManagerTest {
when(vertexScanned.getUniqueId()).thenReturn(UNIQUE_ID);
// when
- ReportManager.reportStartTaskRun(vertexScanned, TASK_1_NAME);
+ ReportManager.reportStartTaskRun(vertexScanned, TASK_1_NAME, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertNotNull(reportOutputFile);