From a4df7bfbef1e4a51c21ee323e6d69df490bea196 Mon Sep 17 00:00:00 2001 From: Francis Toth Date: Thu, 25 Jun 2020 07:45:19 -0400 Subject: Fix typo in package name and classes Signed-off-by: Francis Toth Change-Id: I55a6efeb4a0c2b4734dc3a091afbc6295599c74b Issue-ID: SDC-2499 --- .../asdctool/impl/validator/ArtifactToolBL.java | 2 +- .../asdctool/impl/validator/ValidationToolBL.java | 8 +- .../config/ValidationToolConfiguration.java | 24 ++-- .../executers/ArtifactValidatorExecutor.java | 160 --------------------- .../executers/IArtifactValidatorExecutor.java | 29 ---- .../NodeToscaArtifactsValidatorExecutor.java | 52 ------- .../ServiceToscaArtifactsValidatorExecutor.java | 55 ------- .../executers/ServiceValidatorExecuter.java | 51 ------- .../TopologyTemplateValidatorExecuter.java | 117 --------------- .../VFToscaArtifactValidatorExecutor.java | 54 ------- .../validator/executers/ValidatorExecuter.java | 30 ---- .../validator/executers/VfValidatorExecuter.java | 49 ------- .../executor/ArtifactValidatorExecutor.java | 160 +++++++++++++++++++++ .../executor/IArtifactValidatorExecutor.java | 29 ++++ .../NodeToscaArtifactsValidatorExecutor.java | 52 +++++++ .../ServiceToscaArtifactsValidatorExecutor.java | 55 +++++++ .../executor/ServiceValidatorExecutor.java | 51 +++++++ .../TopologyTemplateValidatorExecutor.java | 117 +++++++++++++++ .../executor/VFToscaArtifactValidatorExecutor.java | 54 +++++++ .../impl/validator/executor/ValidatorExecutor.java | 30 ++++ .../validator/executor/VfValidatorExecutor.java | 49 +++++++ .../impl/validator/utils/ElementTypeEnum.java | 4 +- .../impl/validator/ArtifactToolBLTest.java | 2 +- .../impl/validator/ValidationToolBLTest.java | 4 +- .../config/ValidationToolConfigurationTest.java | 14 +- .../ArtifactValidatorExecutorContract.java | 75 ---------- .../IArtifactValidatorExecutorContract.java | 50 ------- .../NodeToscaArtifactsValidatorExecutorTest.java | 36 ----- ...ServiceToscaArtifactsValidatorExecutorTest.java | 36 ----- .../executers/ServiceValidatorExecuterTest.java | 48 ------- .../TopologyTemplateValidatorExecuterTest.java | 65 --------- .../VFToscaArtifactValidatorExecutorTest.java | 36 ----- .../executers/VfValidatorExecuterTest.java | 53 ------- .../ArtifactValidatorExecutorContract.java | 75 ++++++++++ .../IArtifactValidatorExecutorContract.java | 50 +++++++ .../NodeToscaArtifactsValidatorExecutorTest.java | 36 +++++ ...ServiceToscaArtifactsValidatorExecutorTest.java | 36 +++++ .../executor/ServiceValidatorExecutorTest.java | 48 +++++++ .../TopologyTemplateValidatorExecutorTest.java | 65 +++++++++ .../VFToscaArtifactValidatorExecutorTest.java | 36 +++++ .../executor/VfValidatorExecutorTest.java | 53 +++++++ 41 files changed, 1025 insertions(+), 1025 deletions(-) delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutor.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutor.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutor.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java delete mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutor.java create mode 100644 asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutor.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutorContract.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutorContract.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutorContract.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutorTest.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutorTest.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorTest.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutorTest.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java (limited to 'asdctool/src') 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 75fde3de1e..d53cadf362 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBL.java @@ -20,7 +20,7 @@ package org.openecomp.sdc.asdctool.impl.validator; -import org.openecomp.sdc.asdctool.impl.validator.executers.IArtifactValidatorExecutor; +import org.openecomp.sdc.asdctool.impl.validator.executor.IArtifactValidatorExecutor; import org.openecomp.sdc.common.log.wrappers.Logger; import org.springframework.beans.factory.annotation.Autowired; 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 2fac030188..e9121f184c 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 @@ -20,7 +20,7 @@ package org.openecomp.sdc.asdctool.impl.validator; -import org.openecomp.sdc.asdctool.impl.validator.executers.ValidatorExecuter; +import org.openecomp.sdc.asdctool.impl.validator.executor.ValidatorExecutor; import org.openecomp.sdc.asdctool.impl.validator.report.Report; import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile; import org.openecomp.sdc.common.log.wrappers.Logger; @@ -34,18 +34,18 @@ public class ValidationToolBL { private static final Logger log = Logger.getLogger(ValidationToolBL.class); - protected List validators; + protected List validators; private boolean allValid = true; @Autowired public ValidationToolBL( - List validators) { + List validators) { this.validators = validators; } public boolean validateAll(Report report, ReportFile.TXTFile textFile) { - for (ValidatorExecuter validatorExec: validators) { + for (ValidatorExecutor validatorExec: validators) { log.debug("ValidatorExecuter "+validatorExec.getName()+" started"); if (!validatorExec.executeValidations(report, textFile)) { allValid = false; 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 81051a62b9..1c02ac685a 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfiguration.java @@ -23,13 +23,13 @@ package org.openecomp.sdc.asdctool.impl.validator.config; import org.openecomp.sdc.asdctool.impl.VrfObjectFixHandler; import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL; import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL; -import org.openecomp.sdc.asdctool.impl.validator.executers.IArtifactValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceToscaArtifactsValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter; -import org.openecomp.sdc.asdctool.impl.validator.executers.VFToscaArtifactValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executers.ValidatorExecuter; -import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter; +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.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 +78,8 @@ import java.util.List; public class ValidationToolConfiguration { @Bean - public ServiceValidatorExecuter basicServiceValidator(JanusGraphDao janusGraphDao) { - return new ServiceValidatorExecuter(janusGraphDao); + public ServiceValidatorExecutor basicServiceValidator(JanusGraphDao janusGraphDao) { + return new ServiceValidatorExecutor(janusGraphDao); } @Bean @@ -116,7 +116,7 @@ public class ValidationToolConfiguration { } @Bean - public ValidationToolBL validationToolBL(List validators) { + public ValidationToolBL validationToolBL(List validators) { return new ValidationToolBL(validators); } @@ -126,8 +126,8 @@ public class ValidationToolConfiguration { } @Bean - public VfValidatorExecuter basicVfValidator(List tasks, JanusGraphDao janusGraphDao) { - return new VfValidatorExecuter(tasks, janusGraphDao); + public VfValidatorExecutor basicVfValidator(List tasks, JanusGraphDao janusGraphDao) { + return new VfValidatorExecutor(tasks, janusGraphDao); } @Bean(name = "artifact-cassandra-dao") diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutor.java deleted file mode 100644 index 1a19f5d882..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutor.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import static java.nio.charset.StandardCharsets.UTF_8; - -import fj.data.Either; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; -import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; -import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.ComponentParametersView; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; -import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.common.log.wrappers.Logger; - -public abstract class ArtifactValidatorExecutor { - - private static final Logger log = Logger.getLogger(ArtifactValidatorExecutor.class); - - private final JanusGraphDao janusGraphDao; - private final ToscaOperationFacade toscaOperationFacade; - private final String name; - - public ArtifactValidatorExecutor( - JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade, - String name - ) { - this.janusGraphDao = janusGraphDao; - this.toscaOperationFacade = toscaOperationFacade; - this.name = name; - } - - public String getName() { - return name; - } - - public Map> getVerticesToValidate(VertexTypeEnum type, - Map hasProps) { - Map> result = new HashMap<>(); - Either, 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 componentsList = resultsEither.left().value(); - componentsList.forEach(vertex -> { - String ivariantUuid = (String) vertex.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID); - if (!result.containsKey(ivariantUuid)) { - List compList = new ArrayList<>(); - result.put(ivariantUuid, compList); - } - List compList = result.get(ivariantUuid); - - ComponentParametersView filter = new ComponentParametersView(true); - filter.setIgnoreArtifacts(false); - - Either 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> 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> collection = vertices.values(); - for (List compList : collection) { - Set artifactEsId = new HashSet<>(); - for (Component component : compList) { - Map toscaArtifacts = component.getToscaArtifacts(); - Optional 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 components) { - try { - // "service name, service id, state, version - for (Component component : components) { - String sb = component.getName() + "," + component.getUniqueId() + "," + component.getInvariantUUID() - + "," + component.getLifecycleState() + "," + component.getVersion() - + "\n"; - writer.write(sb); - } - } catch (IOException e) { - log.error("Failed to write module result to file ", e); - } - } - -} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutor.java deleted file mode 100644 index 19f7bf88c5..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutor.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -// TODO: Merge this interface with ArtifactValidatorExecutor -public interface IArtifactValidatorExecutor { - - boolean executeValidations(String outputFilePath); - - String getName(); -} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutor.java deleted file mode 100644 index 41f2c5516b..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutor.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class NodeToscaArtifactsValidatorExecutor - extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor { - - public NodeToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade) { - super(janusGraphDao, toscaOperationFacade, "RESOURCE_TOSCA_ARTIFACTS"); - } - - @Override - public boolean executeValidations(String outputFilePath) { - Map hasProps = new HashMap<>(); - hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); - hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); - - Map> vertices = getVerticesToValidate(VertexTypeEnum.NODE_TYPE, hasProps); - return validate(vertices, outputFilePath); - } -} 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 deleted file mode 100644 index e633aa0204..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutor.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@org.springframework.stereotype.Component -public class ServiceToscaArtifactsValidatorExecutor - extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor { - - @Autowired - public ServiceToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade) { - super(janusGraphDao, toscaOperationFacade, "SERVICE_TOSCA_ARTIFACTS"); - } - - @Override - public boolean executeValidations(String outputFilePath) { - Map hasProps = new HashMap<>(); - hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name()); - hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); - - Map> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); - return validate(vertices, outputFilePath); - } -} 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 deleted file mode 100644 index 5d209807b6..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuter.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.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 ServiceValidatorExecuter extends TopologyTemplateValidatorExecuter implements ValidatorExecuter { - - List tasks = new ArrayList<>(); - - @Autowired(required = false) - public ServiceValidatorExecuter(JanusGraphDao janusGraphDao) { - super(janusGraphDao); - setName("SERVICE_VALIDATOR"); - } - - @Override - public boolean executeValidations(Report report, TXTFile reportFile) { - List vertices = getVerticesToValidate(ComponentTypeEnum.SERVICE); - return validate(report, tasks, vertices, reportFile); - } -} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java deleted file mode 100644 index ddf9e7bce5..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuter.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import fj.data.Either; -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.openecomp.sdc.asdctool.impl.validator.report.Report; -import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile; -import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask; -import org.openecomp.sdc.asdctool.impl.validator.utils.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; -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; - -public class TopologyTemplateValidatorExecuter { - - private static final Logger log = Logger.getLogger(VfValidatorExecuter.class); - - protected JanusGraphDao janusGraphDao; - - protected String name; - - @Autowired - public TopologyTemplateValidatorExecuter(JanusGraphDao janusGraphDao) { - this.janusGraphDao = janusGraphDao; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - protected List getVerticesToValidate(ComponentTypeEnum type) { - Map 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, 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(); - } - - protected boolean validate( - Report report, - List tasks, - List vertices, - TXTFile reportFile - ) { - reportFile.reportStartValidatorRun(getName(), vertices.size()); - Set failedTasks = new HashSet<>(); - Set successTasks = new HashSet<>(); - boolean successAllVertices = true; - int vertexNum = 0; - int verticesSize = vertices.size(); - - for (GraphVertex vertex : vertices) { - vertexNum++; - boolean successAllTasks = true; - for (TopologyTemplateValidationTask task : tasks) { - reportFile.reportStartTaskRun(vertex, task.getTaskName()); - VertexResult result = task.validate(report, vertex, reportFile); - if (!result.getStatus()) { - failedTasks.add(task.getTaskName()); - successAllVertices = false; - successAllTasks = false; - } else if (successAllTasks && vertexNum == verticesSize) { - successTasks.add(task.getTaskName()); - } - reportFile.printValidationTaskStatus(vertex, task.getTaskName(), result.getStatus()); - report.addSuccess(vertex.getUniqueId(), task.getTaskName(), result); - } - String componentScanStatus = successAllTasks ? "success" : "failed"; - log.info("Topology Template " + vertex.getUniqueId() + " Validation finished with " + componentScanStatus); - } - reportFile.reportValidatorTypeSummary(getName(), failedTasks, successTasks); - 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 deleted file mode 100644 index ba05994984..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutor.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; -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.be.model.Component; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class VFToscaArtifactValidatorExecutor - extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor { - - public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao, ToscaOperationFacade toscaOperationFacade) { - super(janusGraphDao, toscaOperationFacade, "VF_TOSCA_ARTIFACTS"); - } - - @Override - public boolean executeValidations(String outputFilePath) { - Map 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> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); - return validate(vertices, outputFilePath); - - } -} 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 deleted file mode 100644 index 87449886d8..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/ValidatorExecuter.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.openecomp.sdc.asdctool.impl.validator.report.Report; -import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile; - -public interface ValidatorExecuter { - - boolean executeValidations(Report report, TXTFile textFile); - String getName(); -} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java deleted file mode 100644 index 40aa601224..0000000000 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuter.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.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 VfValidatorExecuter extends TopologyTemplateValidatorExecuter implements ValidatorExecuter { - - private final List tasks; - - @Autowired(required = false) - public VfValidatorExecuter(List tasks, JanusGraphDao janusGraphDao) { - super(janusGraphDao); - this.tasks = tasks; - setName("BASIC_VF_VALIDATOR"); - } - - @Override - public boolean executeValidations(Report report, TXTFile reportFile) { - List vertices = getVerticesToValidate(ComponentTypeEnum.RESOURCE); - return validate(report, tasks, vertices, reportFile); - } -} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutor.java new file mode 100644 index 0000000000..29f808fcbb --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutor.java @@ -0,0 +1,160 @@ +/*- + * ============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 static java.nio.charset.StandardCharsets.UTF_8; + +import fj.data.Either; +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; +import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentParametersView; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import org.openecomp.sdc.common.log.wrappers.Logger; + +public abstract class ArtifactValidatorExecutor { + + private static final Logger log = Logger.getLogger(ArtifactValidatorExecutor.class); + + private final JanusGraphDao janusGraphDao; + private final ToscaOperationFacade toscaOperationFacade; + private final String name; + + public ArtifactValidatorExecutor( + JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade, + String name + ) { + this.janusGraphDao = janusGraphDao; + this.toscaOperationFacade = toscaOperationFacade; + this.name = name; + } + + public String getName() { + return name; + } + + public Map> getVerticesToValidate(VertexTypeEnum type, + Map hasProps) { + Map> result = new HashMap<>(); + Either, 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 componentsList = resultsEither.left().value(); + componentsList.forEach(vertex -> { + String ivariantUuid = (String) vertex.getMetadataProperty(GraphPropertyEnum.INVARIANT_UUID); + if (!result.containsKey(ivariantUuid)) { + List compList = new ArrayList<>(); + result.put(ivariantUuid, compList); + } + List compList = result.get(ivariantUuid); + + ComponentParametersView filter = new ComponentParametersView(true); + filter.setIgnoreArtifacts(false); + + Either 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> 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> collection = vertices.values(); + for (List compList : collection) { + Set artifactEsId = new HashSet<>(); + for (Component component : compList) { + Map toscaArtifacts = component.getToscaArtifacts(); + Optional 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 components) { + try { + // "service name, service id, state, version + for (Component component : components) { + String sb = component.getName() + "," + component.getUniqueId() + "," + component.getInvariantUUID() + + "," + component.getLifecycleState() + "," + component.getVersion() + + "\n"; + writer.write(sb); + } + } catch (IOException e) { + log.error("Failed to write module result to file ", e); + } + } + +} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutor.java new file mode 100644 index 0000000000..fb905fe314 --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutor.java @@ -0,0 +1,29 @@ +/*- + * ============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; + +// TODO: Merge this interface with ArtifactValidatorExecutor +public interface IArtifactValidatorExecutor { + + boolean executeValidations(String outputFilePath); + + String getName(); +} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutor.java new file mode 100644 index 0000000000..791bafb00d --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutor.java @@ -0,0 +1,52 @@ +/*- + * ============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; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class NodeToscaArtifactsValidatorExecutor + extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor { + + public NodeToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade) { + super(janusGraphDao, toscaOperationFacade, "RESOURCE_TOSCA_ARTIFACTS"); + } + + @Override + public boolean executeValidations(String outputFilePath) { + Map hasProps = new HashMap<>(); + hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name()); + hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + + Map> vertices = getVerticesToValidate(VertexTypeEnum.NODE_TYPE, hasProps); + return validate(vertices, outputFilePath); + } +} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutor.java new file mode 100644 index 0000000000..c09bda508b --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutor.java @@ -0,0 +1,55 @@ +/*- + * ============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; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@org.springframework.stereotype.Component +public class ServiceToscaArtifactsValidatorExecutor + extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor { + + @Autowired + public ServiceToscaArtifactsValidatorExecutor(JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade) { + super(janusGraphDao, toscaOperationFacade, "SERVICE_TOSCA_ARTIFACTS"); + } + + @Override + public boolean executeValidations(String outputFilePath) { + Map hasProps = new HashMap<>(); + hasProps.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name()); + hasProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); + + Map> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); + return validate(vertices, outputFilePath); + } +} 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 new file mode 100644 index 0000000000..ff27b667d5 --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutor.java @@ -0,0 +1,51 @@ +/*- + * ============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 tasks = new ArrayList<>(); + + @Autowired(required = false) + public ServiceValidatorExecutor(JanusGraphDao janusGraphDao) { + super(janusGraphDao); + setName("SERVICE_VALIDATOR"); + } + + @Override + public boolean executeValidations(Report report, TXTFile reportFile) { + List 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 new file mode 100644 index 0000000000..9ba2f5ab46 --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutor.java @@ -0,0 +1,117 @@ +/*- + * ============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 fj.data.Either; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.openecomp.sdc.asdctool.impl.validator.report.Report; +import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile; +import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask; +import org.openecomp.sdc.asdctool.impl.validator.utils.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; +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; + +public class TopologyTemplateValidatorExecutor { + + private static final Logger log = Logger.getLogger(VfValidatorExecutor.class); + + protected JanusGraphDao janusGraphDao; + + protected String name; + + @Autowired + public TopologyTemplateValidatorExecutor(JanusGraphDao janusGraphDao) { + this.janusGraphDao = janusGraphDao; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + protected List getVerticesToValidate(ComponentTypeEnum type) { + Map 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, 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(); + } + + protected boolean validate( + Report report, + List tasks, + List vertices, + TXTFile reportFile + ) { + reportFile.reportStartValidatorRun(getName(), vertices.size()); + Set failedTasks = new HashSet<>(); + Set successTasks = new HashSet<>(); + boolean successAllVertices = true; + int vertexNum = 0; + int verticesSize = vertices.size(); + + for (GraphVertex vertex : vertices) { + vertexNum++; + boolean successAllTasks = true; + for (TopologyTemplateValidationTask task : tasks) { + reportFile.reportStartTaskRun(vertex, task.getTaskName()); + VertexResult result = task.validate(report, vertex, reportFile); + if (!result.getStatus()) { + failedTasks.add(task.getTaskName()); + successAllVertices = false; + successAllTasks = false; + } else if (successAllTasks && vertexNum == verticesSize) { + successTasks.add(task.getTaskName()); + } + reportFile.printValidationTaskStatus(vertex, task.getTaskName(), result.getStatus()); + report.addSuccess(vertex.getUniqueId(), task.getTaskName(), result); + } + String componentScanStatus = successAllTasks ? "success" : "failed"; + log.info("Topology Template " + vertex.getUniqueId() + " Validation finished with " + componentScanStatus); + } + reportFile.reportValidatorTypeSummary(getName(), failedTasks, successTasks); + return successAllVertices; + } +} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutor.java new file mode 100644 index 0000000000..237507a486 --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutor.java @@ -0,0 +1,54 @@ +/*- + * ============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; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +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.be.model.Component; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class VFToscaArtifactValidatorExecutor + extends ArtifactValidatorExecutor implements IArtifactValidatorExecutor { + + public VFToscaArtifactValidatorExecutor(JanusGraphDao janusGraphDao, ToscaOperationFacade toscaOperationFacade) { + super(janusGraphDao, toscaOperationFacade, "VF_TOSCA_ARTIFACTS"); + } + + @Override + public boolean executeValidations(String outputFilePath) { + Map 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> vertices = getVerticesToValidate(VertexTypeEnum.TOPOLOGY_TEMPLATE, hasProps); + return validate(vertices, outputFilePath); + + } +} diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutor.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutor.java new file mode 100644 index 0000000000..b01af0b353 --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutor.java @@ -0,0 +1,30 @@ +/*- + * ============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; + +public interface ValidatorExecutor { + + boolean executeValidations(Report report, TXTFile textFile); + String getName(); +} 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 new file mode 100644 index 0000000000..4729e63c16 --- /dev/null +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutor.java @@ -0,0 +1,49 @@ +/*- + * ============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 tasks; + + @Autowired(required = false) + public VfValidatorExecutor(List tasks, JanusGraphDao janusGraphDao) { + super(janusGraphDao); + this.tasks = tasks; + setName("BASIC_VF_VALIDATOR"); + } + + @Override + public boolean executeValidations(Report report, TXTFile reportFile) { + List 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 index 19dda6ad6a..3424641491 100644 --- 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 @@ -20,7 +20,7 @@ package org.openecomp.sdc.asdctool.impl.validator.utils; -import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter; +import org.openecomp.sdc.asdctool.impl.validator.executor.VfValidatorExecutor; import java.util.ArrayList; import java.util.List; @@ -30,7 +30,7 @@ import java.util.List; */ public enum ElementTypeEnum { - VF ("vf", VfValidatorExecuter.class); + VF ("vf", VfValidatorExecutor.class); //SERVICE("service", ServiceValidatorExecuter.class) private String elementType; 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 47952f8d5c..138629b113 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java @@ -25,7 +25,7 @@ import static org.mockito.Mockito.mock; import java.util.ArrayList; import java.util.LinkedList; import org.junit.Test; -import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecutor; +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; 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 ddea391ab1..74a252c5aa 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 @@ -21,7 +21,7 @@ package org.openecomp.sdc.asdctool.impl.validator; import org.junit.Test; -import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter; +import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceValidatorExecutor; import org.openecomp.sdc.asdctool.impl.validator.report.Report; import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; @@ -44,7 +44,7 @@ public class ValidationToolBLTest { JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); ValidationToolBL testSubject = createTestSubject(); testSubject.validators = new LinkedList<>(); - testSubject.validators.add(new ServiceValidatorExecuter(janusGraphDaoMock)); + testSubject.validators.add(new ServiceValidatorExecutor(janusGraphDaoMock)); Report report = Report.make(); 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 1903f0f1e7..47798f6777 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java @@ -23,11 +23,11 @@ package org.openecomp.sdc.asdctool.impl.validator.config; import org.junit.Test; import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL; import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL; -import org.openecomp.sdc.asdctool.impl.validator.executers.NodeToscaArtifactsValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceToscaArtifactsValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executers.ServiceValidatorExecuter; -import org.openecomp.sdc.asdctool.impl.validator.executers.VFToscaArtifactValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executers.VfValidatorExecuter; +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; @@ -57,7 +57,7 @@ public class ValidationToolConfigurationTest { @Test public void testBasicServiceValidator() { ValidationToolConfiguration testSubject; - ServiceValidatorExecuter result; + ServiceValidatorExecutor result; JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); // default test @@ -111,7 +111,7 @@ public class ValidationToolConfigurationTest { @Test public void testBasicVfValidator() { ValidationToolConfiguration testSubject; - VfValidatorExecuter result; + VfValidatorExecutor result; JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); // default test diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutorContract.java deleted file mode 100644 index 8564bb8251..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ArtifactValidatorExecutorContract.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import static org.mockito.Mockito.mock; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; -import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; -import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; -import org.testng.Assert; - -public interface ArtifactValidatorExecutorContract { - - ArtifactValidatorExecutor createTestSubject( - JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade - ); - - @Test - default void testGetVerticesToValidate() { - JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class); - final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade); - - VertexTypeEnum type = null; - Map hasProps = null; - Assertions.assertThrows(NullPointerException.class, () -> - testSubject.getVerticesToValidate(type, hasProps) - ); - } - - @Test - default void testValidate() { - JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class); - final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade); - - LinkedList linkedList = new LinkedList(); - linkedList.add(new Resource()); - - Map> vertices = new HashMap<>(); - vertices.put("stam", linkedList); - - // 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 - Assert.assertFalse(testSubject.validate(vertices, null)); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java deleted file mode 100644 index 39a1bbef0c..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/IArtifactValidatorExecutorContract.java +++ /dev/null @@ -1,50 +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.executers; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; - -import static org.mockito.Mockito.mock; - -public abstract class IArtifactValidatorExecutorContract { - - protected abstract IArtifactValidatorExecutor createTestSubject( - JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade - ); - - private IArtifactValidatorExecutor createTestSubject() { - return createTestSubject(mock(JanusGraphDao.class), mock(ToscaOperationFacade.class)); - } - - @Test - public void testExecuteValidations() { - Assertions.assertThrows(NullPointerException.class, () -> - // Initially no outputFilePath was passed to this function (hence it is set to null) - // TODO: Fix this null and see if the argument is used by this function - createTestSubject().executeValidations(null) - ); - } -} - diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java deleted file mode 100644 index 3870a98d78..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/NodeToscaArtifactsValidatorExecutorTest.java +++ /dev/null @@ -1,36 +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.executers; - -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; - -public class NodeToscaArtifactsValidatorExecutorTest - extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract { - - @Override - public NodeToscaArtifactsValidatorExecutor createTestSubject( - JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade - ) { - return new NodeToscaArtifactsValidatorExecutor(janusGraphDao, toscaOperationFacade); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java deleted file mode 100644 index 7998c52ea4..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceToscaArtifactsValidatorExecutorTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; - -public class ServiceToscaArtifactsValidatorExecutorTest - extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract { - - @Override - public ServiceToscaArtifactsValidatorExecutor createTestSubject( - JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade - ) { - return new ServiceToscaArtifactsValidatorExecutor(janusGraphDao, toscaOperationFacade); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java deleted file mode 100644 index 41fb048757..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.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.executers; - -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; - -import org.junit.Test; -import org.openecomp.sdc.asdctool.impl.validator.report.Report; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; - -public class ServiceValidatorExecuterTest { - - 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() { - Report report = Report.make(); - createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter())); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java deleted file mode 100644 index d74aaa49a2..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/TopologyTemplateValidatorExecuterTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; - -import static org.mockito.Mockito.mock; - -public class TopologyTemplateValidatorExecuterTest { - - private TopologyTemplateValidatorExecuter createTestSubject() { - JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - return new TopologyTemplateValidatorExecuter(janusGraphDaoMock); - } - - @Test - public void testSetName() { - TopologyTemplateValidatorExecuter testSubject; - String name = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setName(name); - } - - @Test - public void testGetName() { - TopologyTemplateValidatorExecuter testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getName(); - } - - @Test - public void testGetVerticesToValidate() { - TopologyTemplateValidatorExecuter testSubject; - - // default test - testSubject = createTestSubject(); - Assertions.assertThrows(NullPointerException.class, () -> testSubject.getVerticesToValidate(ComponentTypeEnum.PRODUCT)); - } -} 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 deleted file mode 100644 index ae6dcc1623..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VFToscaArtifactValidatorExecutorTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; - -public class VFToscaArtifactValidatorExecutorTest - extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract { - - @Override - public VFToscaArtifactValidatorExecutor createTestSubject( - JanusGraphDao janusGraphDao, - ToscaOperationFacade toscaOperationFacade - ) { - return new VFToscaArtifactValidatorExecutor(janusGraphDao, toscaOperationFacade); - } -} 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 deleted file mode 100644 index aa388f68b7..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executers; - -import 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; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.openecomp.sdc.asdctool.impl.validator.report.Report; -import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; - -public class VfValidatorExecuterTest { - - private VfValidatorExecuter createTestSubject() { - List validationTasks = new ArrayList<>(); - JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - - return new VfValidatorExecuter(validationTasks, janusGraphDaoMock); - } - - @Test - public void testGetName() { - createTestSubject().getName(); - } - - @Test(expected = NullPointerException.class) - public void testExecuteValidations() { - Report report = Report.make(); - createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter())); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutorContract.java new file mode 100644 index 0000000000..3a325fcb09 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ArtifactValidatorExecutorContract.java @@ -0,0 +1,75 @@ +/*- + * ============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 static org.mockito.Mockito.mock; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; +import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; +import org.testng.Assert; + +public interface ArtifactValidatorExecutorContract { + + ArtifactValidatorExecutor createTestSubject( + JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade + ); + + @Test + default void testGetVerticesToValidate() { + JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); + ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class); + final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade); + + VertexTypeEnum type = null; + Map hasProps = null; + Assertions.assertThrows(NullPointerException.class, () -> + testSubject.getVerticesToValidate(type, hasProps) + ); + } + + @Test + default void testValidate() { + JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); + ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class); + final ArtifactValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock, toscaOperationFacade); + + LinkedList linkedList = new LinkedList(); + linkedList.add(new Resource()); + + Map> vertices = new HashMap<>(); + vertices.put("stam", linkedList); + + // 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 + Assert.assertFalse(testSubject.validate(vertices, null)); + } +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutorContract.java new file mode 100644 index 0000000000..35c6ac1173 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/IArtifactValidatorExecutorContract.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020 Bell Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.asdctool.impl.validator.executor; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; + +import static org.mockito.Mockito.mock; + +public abstract class IArtifactValidatorExecutorContract { + + protected abstract IArtifactValidatorExecutor createTestSubject( + JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade + ); + + private IArtifactValidatorExecutor createTestSubject() { + return createTestSubject(mock(JanusGraphDao.class), mock(ToscaOperationFacade.class)); + } + + @Test + public void testExecuteValidations() { + Assertions.assertThrows(NullPointerException.class, () -> + // Initially no outputFilePath was passed to this function (hence it is set to null) + // TODO: Fix this null and see if the argument is used by this function + createTestSubject().executeValidations(null) + ); + } +} + diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutorTest.java new file mode 100644 index 0000000000..b189b27d97 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/NodeToscaArtifactsValidatorExecutorTest.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020 Bell Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.asdctool.impl.validator.executor; + +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; + +public class NodeToscaArtifactsValidatorExecutorTest + extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract { + + @Override + public NodeToscaArtifactsValidatorExecutor createTestSubject( + JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade + ) { + return new NodeToscaArtifactsValidatorExecutor(janusGraphDao, toscaOperationFacade); + } +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutorTest.java new file mode 100644 index 0000000000..ef35d45e63 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceToscaArtifactsValidatorExecutorTest.java @@ -0,0 +1,36 @@ +/*- + * ============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; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; + +public class ServiceToscaArtifactsValidatorExecutorTest + extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract { + + @Override + public ServiceToscaArtifactsValidatorExecutor createTestSubject( + JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade + ) { + return new ServiceToscaArtifactsValidatorExecutor(janusGraphDao, toscaOperationFacade); + } +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java new file mode 100644 index 0000000000..bc0eb25da2 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java @@ -0,0 +1,48 @@ +/*- + * ============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 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; + +import org.junit.Test; +import org.openecomp.sdc.asdctool.impl.validator.report.Report; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; + +public class ServiceValidatorExecutorTest { + + private ServiceValidatorExecutor createTestSubject() { + JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); + return new ServiceValidatorExecutor(janusGraphDaoMock); + } + + @Test + public void testGetName() { + createTestSubject().getName(); + } + + @Test(expected = NullPointerException.class) + public void testExecuteValidations() { + Report report = Report.make(); + createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter())); + } +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorTest.java new file mode 100644 index 0000000000..57e99c3865 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorTest.java @@ -0,0 +1,65 @@ +/*- + * ============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.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; + +import static org.mockito.Mockito.mock; + +public class TopologyTemplateValidatorExecutorTest { + + private TopologyTemplateValidatorExecutor createTestSubject() { + JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); + return new TopologyTemplateValidatorExecutor(janusGraphDaoMock); + } + + @Test + public void testSetName() { + TopologyTemplateValidatorExecutor testSubject; + String name = ""; + + // default test + testSubject = createTestSubject(); + testSubject.setName(name); + } + + @Test + public void testGetName() { + TopologyTemplateValidatorExecutor testSubject; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getName(); + } + + @Test + public void testGetVerticesToValidate() { + TopologyTemplateValidatorExecutor testSubject; + + // default test + testSubject = createTestSubject(); + Assertions.assertThrows(NullPointerException.class, () -> testSubject.getVerticesToValidate(ComponentTypeEnum.PRODUCT)); + } +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutorTest.java new file mode 100644 index 0000000000..3beec33e50 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VFToscaArtifactValidatorExecutorTest.java @@ -0,0 +1,36 @@ +/*- + * ============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; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; + +public class VFToscaArtifactValidatorExecutorTest + extends IArtifactValidatorExecutorContract implements ArtifactValidatorExecutorContract { + + @Override + public VFToscaArtifactValidatorExecutor createTestSubject( + JanusGraphDao janusGraphDao, + ToscaOperationFacade toscaOperationFacade + ) { + return new VFToscaArtifactValidatorExecutor(janusGraphDao, toscaOperationFacade); + } +} 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 new file mode 100644 index 0000000000..c40f660d45 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java @@ -0,0 +1,53 @@ +/*- + * ============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 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; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.openecomp.sdc.asdctool.impl.validator.report.Report; +import org.openecomp.sdc.asdctool.impl.validator.tasks.VfValidationTask; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; + +public class VfValidatorExecutorTest { + + private VfValidatorExecutor createTestSubject() { + List validationTasks = new ArrayList<>(); + JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); + + return new VfValidatorExecutor(validationTasks, janusGraphDaoMock); + } + + @Test + public void testGetName() { + createTestSubject().getName(); + } + + @Test(expected = NullPointerException.class) + public void testExecuteValidations() { + Report report = Report.make(); + createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter())); + } +} -- cgit 1.2.3-korg