aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool
diff options
context:
space:
mode:
Diffstat (limited to 'asdctool')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java10
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBL.java8
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java11
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutor.java50
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutor.java100
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutor.java48
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java79
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java32
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java32
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java18
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java32
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java40
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorTest.java (renamed from asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorContract.java)27
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java33
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java97
15 files changed, 133 insertions, 484 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 d53cadf362..92af43e3e8 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
@@ -28,19 +28,17 @@ import java.util.List;
public class ArtifactToolBL {
- private static final Logger log = Logger.getLogger(ValidationToolBL.class.getName());
+ private static final Logger log = Logger.getLogger(ArtifactToolBL.class);
- protected List<IArtifactValidatorExecutor> validators;
-
- private boolean allValid = true;
+ private final List<IArtifactValidatorExecutor> validators;
@Autowired
- public ArtifactToolBL(
- List<IArtifactValidatorExecutor> validators) {
+ public ArtifactToolBL(List<IArtifactValidatorExecutor> validators) {
this.validators = validators;
}
public boolean validateAll(String outputFilePath) {
+ boolean allValid = true;
for (IArtifactValidatorExecutor validatorExec : validators) {
log.debug("ValidatorExecuter " + validatorExec.getName() + " started");
if (!validatorExec.executeValidations(outputFilePath)) {
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 e9121f184c..8f9202fcb2 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
@@ -34,17 +34,15 @@ public class ValidationToolBL {
private static final Logger log = Logger.getLogger(ValidationToolBL.class);
- protected List<ValidatorExecutor> validators;
-
- private boolean allValid = true;
+ private final List<ValidatorExecutor> validators;
@Autowired
- public ValidationToolBL(
- List<ValidatorExecutor> validators) {
+ public ValidationToolBL(List<ValidatorExecutor> validators) {
this.validators = validators;
}
public boolean validateAll(Report report, ReportFile.TXTFile textFile) {
+ boolean allValid = true;
for (ValidatorExecutor validatorExec: validators) {
log.debug("ValidatorExecuter "+validatorExec.getName()+" started");
if (!validatorExec.executeValidations(report, textFile)) {
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
index 1c02ac685a..5fbed89ac1 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java
@@ -26,10 +26,9 @@ import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
import org.openecomp.sdc.asdctool.impl.validator.executor.IArtifactValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executor.NodeToscaArtifactsValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceToscaArtifactsValidatorExecutor;
-import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceValidatorExecutor;
+import org.openecomp.sdc.asdctool.impl.validator.executor.TopologyTemplateValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executor.VFToscaArtifactValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executor.ValidatorExecutor;
-import org.openecomp.sdc.asdctool.impl.validator.executor.VfValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidationUtils;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask;
@@ -78,8 +77,8 @@ import java.util.List;
public class ValidationToolConfiguration {
@Bean
- public ServiceValidatorExecutor basicServiceValidator(JanusGraphDao janusGraphDao) {
- return new ServiceValidatorExecutor(janusGraphDao);
+ public ValidatorExecutor basicServiceValidator(JanusGraphDao janusGraphDao) {
+ return TopologyTemplateValidatorExecutor.serviceValidatorExecutor(janusGraphDao);
}
@Bean
@@ -126,8 +125,8 @@ public class ValidationToolConfiguration {
}
@Bean
- public VfValidatorExecutor basicVfValidator(List<VfValidationTask> tasks, JanusGraphDao janusGraphDao) {
- return new VfValidatorExecutor(tasks, janusGraphDao);
+ public ValidatorExecutor basicVfValidator(List<VfValidationTask> tasks, JanusGraphDao janusGraphDao) {
+ return TopologyTemplateValidatorExecutor.vfValidatorExecutor(tasks, janusGraphDao);
}
@Bean(name = "artifact-cassandra-dao")
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutor.java
deleted file mode 100644
index 27bcd1f60d..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.validator.executor;
-
-import org.openecomp.sdc.asdctool.impl.validator.report.Report;
-import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile;
-import org.openecomp.sdc.asdctool.impl.validator.tasks.ServiceValidationTask;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class ServiceValidatorExecutor extends TopologyTemplateValidatorExecutor implements ValidatorExecutor {
-
- List<ServiceValidationTask> tasks = new ArrayList<>();
-
- @Autowired(required = false)
- public ServiceValidatorExecutor(JanusGraphDao janusGraphDao) {
- super(janusGraphDao, "SERVICE_VALIDATOR");
- }
-
- @Override
- public boolean executeValidations(Report report, TXTFile reportFile) {
- List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.SERVICE);
- return validate(report, tasks, vertices, reportFile);
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutor.java
index 95a9fce9af..36feb3b607 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutor.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutor.java
@@ -20,19 +20,12 @@
package org.openecomp.sdc.asdctool.impl.validator.executor;
-import fj.data.Either;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import lombok.Getter;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile;
import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask;
+import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -40,45 +33,56 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
-public class TopologyTemplateValidatorExecutor {
+public class TopologyTemplateValidatorExecutor implements ValidatorExecutor {
- private static final Logger log = Logger.getLogger(VfValidatorExecutor.class);
+ private static final Logger log = Logger.getLogger(TopologyTemplateValidatorExecutor.class);
private final JanusGraphDao janusGraphDao;
+ private final ComponentTypeEnum componentType;
+ private final List<? extends TopologyTemplateValidationTask> tasks;
@Getter
private final String name;
- public TopologyTemplateValidatorExecutor(JanusGraphDao janusGraphDao, String name) {
- this.janusGraphDao = janusGraphDao;
- this.name = name;
+ @Autowired(required = false)
+ public static ValidatorExecutor serviceValidatorExecutor(JanusGraphDao janusGraphDao) {
+ return new TopologyTemplateValidatorExecutor(
+ janusGraphDao, "SERVICE_VALIDATOR", ComponentTypeEnum.SERVICE, new ArrayList<>()
+ );
}
- 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)) {
- 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());
- return new ArrayList<>();
- }
- log.info("getVerticesToValidate: " + results.left().value().size() + " vertices to scan");
- return results.left().value();
+ @Autowired(required = false)
+ public static ValidatorExecutor vfValidatorExecutor(List<VfValidationTask> tasks, JanusGraphDao janusGraphDao) {
+ return new TopologyTemplateValidatorExecutor(
+ janusGraphDao, "BASIC_VF_VALIDATOR", ComponentTypeEnum.RESOURCE, tasks
+ );
}
- protected boolean validate(
- Report report,
- List<? extends TopologyTemplateValidationTask> tasks,
- List<GraphVertex> vertices,
- TXTFile reportFile
+ private TopologyTemplateValidatorExecutor(
+ JanusGraphDao janusGraphDao,
+ String name,
+ ComponentTypeEnum componentType,
+ List<? extends TopologyTemplateValidationTask> tasks
) {
- reportFile.reportStartValidatorRun(getName(), vertices.size());
+ this.janusGraphDao = janusGraphDao;
+ this.name = name;
+ this.componentType = componentType;
+ this.tasks = tasks;
+ }
+
+ @Override
+ public boolean executeValidations(Report report, TXTFile reportFile) {
+ List<GraphVertex> vertices = getVerticesToValidate();
+ reportFile.reportStartValidatorRun(name, vertices.size());
Set<String> failedTasks = new HashSet<>();
Set<String> successTasks = new HashSet<>();
boolean successAllVertices = true;
@@ -102,9 +106,33 @@ public class TopologyTemplateValidatorExecutor {
report.addSuccess(vertex.getUniqueId(), task.getTaskName(), result);
}
String componentScanStatus = successAllTasks ? "success" : "failed";
- log.info("Topology Template " + vertex.getUniqueId() + " Validation finished with " + componentScanStatus);
+ log.info("Topology Template {} Validation finished with {}", vertex.getUniqueId(), componentScanStatus);
}
- reportFile.reportValidatorTypeSummary(getName(), failedTasks, successTasks);
+ reportFile.reportValidatorTypeSummary(name, failedTasks, successTasks);
return successAllVertices;
}
+
+ private List<GraphVertex> getVerticesToValidate() {
+ return janusGraphDao
+ .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, buildProps())
+ .either(
+ vs -> {
+ log.info("getVerticesToValidate: {} vertices to scan", vs.size());
+ return vs;
+ },
+ sos -> {
+ log.error("getVerticesToValidate failed {}", sos);
+ return new ArrayList<>();
+ }
+ );
+ }
+
+ private Map<GraphPropertyEnum, Object> buildProps() {
+ Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class);
+ props.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
+ if (componentType.equals(ComponentTypeEnum.RESOURCE)) {
+ props.put(GraphPropertyEnum.RESOURCE_TYPE, ResourceTypeEnum.VF);
+ }
+ return props;
+ }
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutor.java
deleted file mode 100644
index f8aaf5480d..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.validator.executor;
-
-import org.openecomp.sdc.asdctool.impl.validator.report.Report;
-import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile;
-import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.List;
-
-public class VfValidatorExecutor extends TopologyTemplateValidatorExecutor implements ValidatorExecutor {
-
- private final List<VfValidationTask> tasks;
-
- @Autowired(required = false)
- public VfValidatorExecutor(List<VfValidationTask> tasks, JanusGraphDao janusGraphDao) {
- super(janusGraphDao, "BASIC_VF_VALIDATOR");
- this.tasks = tasks;
- }
-
- @Override
- public boolean executeValidations(Report report, TXTFile reportFile) {
- List<GraphVertex> vertices = getVerticesToValidate(ComponentTypeEnum.RESOURCE);
- return validate(report, tasks, vertices, reportFile);
- }
-}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java
deleted file mode 100644
index 3424641491..0000000000
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnum.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.validator.utils;
-
-import org.openecomp.sdc.asdctool.impl.validator.executor.VfValidatorExecutor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by chaya on 7/4/2017.
- */
-public enum ElementTypeEnum {
-
- VF ("vf", VfValidatorExecutor.class);
- //SERVICE("service", ServiceValidatorExecuter.class)
-
- private String elementType;
- private Class clazz;
-
- ElementTypeEnum(String elementType, Class clazz) {
- this. elementType = elementType;
- this.clazz = clazz;
- }
-
- public static ElementTypeEnum getByType(String elementType){
- for(ElementTypeEnum currType :ElementTypeEnum.values()){
- if(currType.getElementType().equals(elementType)){
- return currType;
- }
- }
- return null;
- }
-
- public static List<String> getAllTypes() {
-
- List<String> arrayList = new ArrayList<String>();
-
- for (ElementTypeEnum graphType : ElementTypeEnum.values()) {
- arrayList.add(graphType.getElementType());
- }
- return arrayList;
- }
-
-
- public String getElementType() {
- return elementType;
- }
-
- public void setElementType(String elementType) {
- this.elementType = elementType;
- }
-
- public Class getClazz() {
- return clazz;
- }
-
- public void setClazz(Class clazz) {
- this.clazz = clazz;
- }
-}
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 138629b113..393f678af3 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
@@ -20,32 +20,34 @@
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.junit.jupiter.api.Test;
+import org.openecomp.sdc.asdctool.impl.validator.executor.IArtifactValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executor.NodeToscaArtifactsValidatorExecutor;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
-public class ArtifactToolBLTest {
+import java.util.ArrayList;
+import java.util.List;
- private ArtifactToolBL createTestSubject() {
- return new ArtifactToolBL(new ArrayList<>());
- }
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
- //Generated test
- @Test(expected = NullPointerException.class)
+public class ArtifactToolBLTest {
+
+ @Test
public void testValidateAll() {
JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
- ArtifactToolBL testSubject = createTestSubject();
- testSubject.validators = new LinkedList<>();
- testSubject.validators.add(new NodeToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade));
+ List<IArtifactValidatorExecutor> validators = new ArrayList<>();
+ validators.add(new NodeToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade));
+ ArtifactToolBL testSubject = new ArtifactToolBL(validators);
+
// 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);
+ assertThrows(
+ NullPointerException.class,
+ () -> 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 74a252c5aa..b62be60594 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
@@ -20,32 +20,34 @@
package org.openecomp.sdc.asdctool.impl.validator;
-import org.junit.Test;
-import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceValidatorExecutor;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.asdctool.impl.validator.executor.TopologyTemplateValidatorExecutor;
+import org.openecomp.sdc.asdctool.impl.validator.executor.ValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile;
-import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory.makeConsoleWriter;
-
import java.util.ArrayList;
-import java.util.LinkedList;
+import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
+import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile;
+import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory.makeConsoleWriter;
public class ValidationToolBLTest {
- private ValidationToolBL createTestSubject() {
- return new ValidationToolBL(new ArrayList<>());
- }
-
- @Test(expected = NullPointerException.class)
+ @Test
public void testValidateAll() {
JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- ValidationToolBL testSubject = createTestSubject();
- testSubject.validators = new LinkedList<>();
- testSubject.validators.add(new ServiceValidatorExecutor(janusGraphDaoMock));
+
+ List<ValidatorExecutor> validators = new ArrayList<>();
+ validators.add(TopologyTemplateValidatorExecutor.serviceValidatorExecutor(janusGraphDaoMock));
+ ValidationToolBL testSubject = new ValidationToolBL(validators);
+
Report report = Report.make();
- testSubject.validateAll(report, makeTxtFile(makeConsoleWriter()));
+ assertThrows(
+ NullPointerException.class,
+ () -> testSubject.validateAll(report, makeTxtFile(makeConsoleWriter()))
+ );
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
index 47798f6777..9efd4c4893 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java
@@ -25,9 +25,7 @@ import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL;
import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL;
import org.openecomp.sdc.asdctool.impl.validator.executor.NodeToscaArtifactsValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceToscaArtifactsValidatorExecutor;
-import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.executor.VFToscaArtifactValidatorExecutor;
-import org.openecomp.sdc.asdctool.impl.validator.executor.VfValidatorExecutor;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidationUtils;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask;
import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.VfArtifactValidationTask;
@@ -56,13 +54,9 @@ public class ValidationToolConfigurationTest {
@Test
public void testBasicServiceValidator() {
- ValidationToolConfiguration testSubject;
- ServiceValidatorExecutor result;
+ ValidationToolConfiguration testSubject = createTestSubject();
JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.basicServiceValidator(janusGraphDaoMock);
+ testSubject.basicServiceValidator(janusGraphDaoMock);
}
@Test
@@ -110,13 +104,9 @@ public class ValidationToolConfigurationTest {
@Test
public void testBasicVfValidator() {
- ValidationToolConfiguration testSubject;
- VfValidatorExecutor result;
+ ValidationToolConfiguration testSubject = createTestSubject();
JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.basicVfValidator(new ArrayList<>(), janusGraphDaoMock);
+ testSubject.basicVfValidator(new ArrayList<>(), janusGraphDaoMock);
}
@Test
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java
deleted file mode 100644
index 4888f42e8b..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.validator.executor;
-
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-
-public class ServiceValidatorExecutorTest
- implements ValidatorExecutorContract, TopologyTemplateValidatorExecutorContract {
-
- @Override
- public ServiceValidatorExecutor createTestSubject(JanusGraphDao dao) {
- return new ServiceValidatorExecutor(dao);
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java
deleted file mode 100644
index 881782695f..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2020 Bell Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.asdctool.impl.validator.executor;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-import static org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum.PRODUCT;
-
-import org.junit.jupiter.api.Test;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-
-public interface TopologyTemplateValidatorExecutorContract {
-
- TopologyTemplateValidatorExecutor createTestSubject(JanusGraphDao dao);
-
- @Test
- default void testGetVerticesToValidate() {
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
- TopologyTemplateValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock);
- assertThrows(NullPointerException.class,
- () -> testSubject.getVerticesToValidate(PRODUCT));
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorTest.java
index de1f04923a..faab454a79 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorContract.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorTest.java
@@ -19,25 +19,36 @@
*/
package org.openecomp.sdc.asdctool.impl.validator.executor;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+
+import java.util.ArrayList;
+import java.util.function.Function;
+
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
+import static org.openecomp.sdc.asdctool.impl.validator.executor.TopologyTemplateValidatorExecutor.vfValidatorExecutor;
import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile;
import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory.makeConsoleWriter;
-import org.junit.jupiter.api.Test;
-import org.openecomp.sdc.asdctool.impl.validator.report.Report;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-
-public interface ValidatorExecutorContract {
+public final class ValidatorExecutorTest {
- ValidatorExecutor createTestSubject(JanusGraphDao dao);
+ @Test
+ public void executeValidationsWithServiceValidator() {
+ testExecuteValidations(TopologyTemplateValidatorExecutor::serviceValidatorExecutor);
+ }
@Test
- default void testExecuteValidations() {
+ public void executeValidationsWithVFValidator() {
+ testExecuteValidations(dao -> vfValidatorExecutor(new ArrayList<>(), dao));
+ }
+
+ private void testExecuteValidations(Function<JanusGraphDao, ValidatorExecutor> factory) {
Report report = Report.make();
JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
assertThrows(NullPointerException.class, () ->
- createTestSubject(janusGraphDaoMock).executeValidations(report, makeTxtFile(makeConsoleWriter()))
+ factory.apply(janusGraphDaoMock).executeValidations(report, makeTxtFile(makeConsoleWriter()))
);
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java
deleted file mode 100644
index 85bf4bc719..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.validator.executor;
-
-import java.util.ArrayList;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-
-public class VfValidatorExecutorTest
- implements ValidatorExecutorContract, TopologyTemplateValidatorExecutorContract {
-
- @Override
- public VfValidatorExecutor createTestSubject(JanusGraphDao dao) {
- return new VfValidatorExecutor(new ArrayList<>(), dao);
- }
-}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java
deleted file mode 100644
index 317932d9d9..0000000000
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.asdctool.impl.validator.utils;
-
-import org.junit.Test;
-
-import java.util.List;
-
-
-public class ElementTypeEnumTest {
-
- private ElementTypeEnum createTestSubject() {
- return ElementTypeEnum.VF;
- }
-
-
- @Test
- public void testGetByType() {
- String elementType = "";
- ElementTypeEnum result;
-
- // default test
- result = ElementTypeEnum.getByType(elementType);
- result = ElementTypeEnum.getByType(ElementTypeEnum.VF.getElementType());
- }
-
-
- @Test
- public void testGetAllTypes() {
- List<String> result;
-
- // default test
- result = ElementTypeEnum.getAllTypes();
- }
-
-
- @Test
- public void testGetElementType() {
- ElementTypeEnum testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getElementType();
- }
-
-
- @Test
- public void testSetElementType() {
- ElementTypeEnum testSubject;
- String elementType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setElementType(elementType);
- }
-
-
- @Test
- public void testGetClazz() {
- ElementTypeEnum testSubject;
- Class result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getClazz();
- }
-
-
- @Test
- public void testSetClazz() {
- ElementTypeEnum testSubject;
- Class clazz = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setClazz(clazz);
- }
-}