From 20903a7051c3ee2e938cd02e408021ea34e78d0c Mon Sep 17 00:00:00 2001 From: Francis Toth Date: Tue, 7 Jul 2020 09:10:33 -0400 Subject: Clean ValidatorExecutor hierarchy Signed-off-by: Francis Toth Change-Id: I9d919b1d57eac1d25c8b3874366c2cb9e906923a Issue-ID: SDC-2499 --- .../impl/validator/ArtifactToolBLTest.java | 32 +++---- .../impl/validator/ValidationToolBLTest.java | 32 +++---- .../config/ValidationToolConfigurationTest.java | 18 +--- .../executor/ServiceValidatorExecutorTest.java | 32 ------- .../TopologyTemplateValidatorExecutorContract.java | 40 --------- .../executor/ValidatorExecutorContract.java | 43 ---------- .../validator/executor/ValidatorExecutorTest.java | 54 ++++++++++++ .../executor/VfValidatorExecutorTest.java | 33 -------- .../impl/validator/utils/ElementTypeEnumTest.java | 97 ---------------------- 9 files changed, 92 insertions(+), 289 deletions(-) delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorContract.java create mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java delete mode 100644 asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java (limited to 'asdctool/src/test/java') diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java index 138629b113..393f678af3 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ArtifactToolBLTest.java @@ -20,32 +20,34 @@ package org.openecomp.sdc.asdctool.impl.validator; -import static org.mockito.Mockito.mock; - -import java.util.ArrayList; -import java.util.LinkedList; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.asdctool.impl.validator.executor.IArtifactValidatorExecutor; import org.openecomp.sdc.asdctool.impl.validator.executor.NodeToscaArtifactsValidatorExecutor; import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; -public class ArtifactToolBLTest { +import java.util.ArrayList; +import java.util.List; - private ArtifactToolBL createTestSubject() { - return new ArtifactToolBL(new ArrayList<>()); - } +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; - //Generated test - @Test(expected = NullPointerException.class) +public class ArtifactToolBLTest { + + @Test public void testValidateAll() { JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class); - ArtifactToolBL testSubject = createTestSubject(); - testSubject.validators = new LinkedList<>(); - testSubject.validators.add(new NodeToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade)); + List validators = new ArrayList<>(); + validators.add(new NodeToscaArtifactsValidatorExecutor(janusGraphDaoMock, toscaOperationFacade)); + ArtifactToolBL testSubject = new ArtifactToolBL(validators); + // Initially no outputFilePath was passed to this function (hence it is set to null) // TODO: Fix this null and see if the argument is used by this function - testSubject.validateAll(null); + assertThrows( + NullPointerException.class, + () -> testSubject.validateAll(null) + ); } } diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java index 74a252c5aa..b62be60594 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java @@ -20,32 +20,34 @@ package org.openecomp.sdc.asdctool.impl.validator; -import org.junit.Test; -import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceValidatorExecutor; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.asdctool.impl.validator.executor.TopologyTemplateValidatorExecutor; +import org.openecomp.sdc.asdctool.impl.validator.executor.ValidatorExecutor; import org.openecomp.sdc.asdctool.impl.validator.report.Report; import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; -import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile; -import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory.makeConsoleWriter; - import java.util.ArrayList; -import java.util.LinkedList; +import java.util.List; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; +import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile; +import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory.makeConsoleWriter; public class ValidationToolBLTest { - private ValidationToolBL createTestSubject() { - return new ValidationToolBL(new ArrayList<>()); - } - - @Test(expected = NullPointerException.class) + @Test public void testValidateAll() { JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - ValidationToolBL testSubject = createTestSubject(); - testSubject.validators = new LinkedList<>(); - testSubject.validators.add(new ServiceValidatorExecutor(janusGraphDaoMock)); + + List validators = new ArrayList<>(); + validators.add(TopologyTemplateValidatorExecutor.serviceValidatorExecutor(janusGraphDaoMock)); + ValidationToolBL testSubject = new ValidationToolBL(validators); + Report report = Report.make(); - testSubject.validateAll(report, makeTxtFile(makeConsoleWriter())); + assertThrows( + NullPointerException.class, + () -> testSubject.validateAll(report, makeTxtFile(makeConsoleWriter())) + ); } } diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java index 47798f6777..9efd4c4893 100644 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationToolConfigurationTest.java @@ -25,9 +25,7 @@ import org.openecomp.sdc.asdctool.impl.validator.ArtifactToolBL; import org.openecomp.sdc.asdctool.impl.validator.ValidationToolBL; import org.openecomp.sdc.asdctool.impl.validator.executor.NodeToscaArtifactsValidatorExecutor; import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceToscaArtifactsValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executor.ServiceValidatorExecutor; import org.openecomp.sdc.asdctool.impl.validator.executor.VFToscaArtifactValidatorExecutor; -import org.openecomp.sdc.asdctool.impl.validator.executor.VfValidatorExecutor; import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ArtifactValidationUtils; import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.ServiceArtifactValidationTask; import org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts.VfArtifactValidationTask; @@ -56,13 +54,9 @@ public class ValidationToolConfigurationTest { @Test public void testBasicServiceValidator() { - ValidationToolConfiguration testSubject; - ServiceValidatorExecutor result; + ValidationToolConfiguration testSubject = createTestSubject(); JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - - // default test - testSubject = createTestSubject(); - result = testSubject.basicServiceValidator(janusGraphDaoMock); + testSubject.basicServiceValidator(janusGraphDaoMock); } @Test @@ -110,13 +104,9 @@ public class ValidationToolConfigurationTest { @Test public void testBasicVfValidator() { - ValidationToolConfiguration testSubject; - VfValidatorExecutor result; + ValidationToolConfiguration testSubject = createTestSubject(); JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - - // default test - testSubject = createTestSubject(); - result = testSubject.basicVfValidator(new ArrayList<>(), janusGraphDaoMock); + testSubject.basicVfValidator(new ArrayList<>(), janusGraphDaoMock); } @Test diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java deleted file mode 100644 index 4888f42e8b..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ServiceValidatorExecutorTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executor; - -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; - -public class ServiceValidatorExecutorTest - implements ValidatorExecutorContract, TopologyTemplateValidatorExecutorContract { - - @Override - public ServiceValidatorExecutor createTestSubject(JanusGraphDao dao) { - return new ServiceValidatorExecutor(dao); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java deleted file mode 100644 index 881782695f..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/TopologyTemplateValidatorExecutorContract.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2020 Bell Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.sdc.asdctool.impl.validator.executor; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; -import static org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum.PRODUCT; - -import org.junit.jupiter.api.Test; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; - -public interface TopologyTemplateValidatorExecutorContract { - - TopologyTemplateValidatorExecutor createTestSubject(JanusGraphDao dao); - - @Test - default void testGetVerticesToValidate() { - JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - TopologyTemplateValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock); - assertThrows(NullPointerException.class, - () -> testSubject.getVerticesToValidate(PRODUCT)); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorContract.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorContract.java deleted file mode 100644 index de1f04923a..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorContract.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2020 Bell Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.sdc.asdctool.impl.validator.executor; - -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; -import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile; -import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory.makeConsoleWriter; - -import org.junit.jupiter.api.Test; -import org.openecomp.sdc.asdctool.impl.validator.report.Report; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; - -public interface ValidatorExecutorContract { - - ValidatorExecutor createTestSubject(JanusGraphDao dao); - - @Test - default void testExecuteValidations() { - Report report = Report.make(); - JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); - assertThrows(NullPointerException.class, () -> - createTestSubject(janusGraphDaoMock).executeValidations(report, makeTxtFile(makeConsoleWriter())) - ); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorTest.java new file mode 100644 index 0000000000..faab454a79 --- /dev/null +++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/ValidatorExecutorTest.java @@ -0,0 +1,54 @@ +/*- + * ============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.Test; +import org.openecomp.sdc.asdctool.impl.validator.report.Report; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; + +import java.util.ArrayList; +import java.util.function.Function; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; +import static org.openecomp.sdc.asdctool.impl.validator.executor.TopologyTemplateValidatorExecutor.vfValidatorExecutor; +import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile; +import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory.makeConsoleWriter; + +public final class ValidatorExecutorTest { + + @Test + public void executeValidationsWithServiceValidator() { + testExecuteValidations(TopologyTemplateValidatorExecutor::serviceValidatorExecutor); + } + + @Test + public void executeValidationsWithVFValidator() { + testExecuteValidations(dao -> vfValidatorExecutor(new ArrayList<>(), dao)); + } + + private void testExecuteValidations(Function factory) { + Report report = Report.make(); + JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class); + assertThrows(NullPointerException.class, () -> + factory.apply(janusGraphDaoMock).executeValidations(report, makeTxtFile(makeConsoleWriter())) + ); + } +} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java deleted file mode 100644 index 85bf4bc719..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executor/VfValidatorExecutorTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.executor; - -import java.util.ArrayList; -import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; - -public class VfValidatorExecutorTest - implements ValidatorExecutorContract, TopologyTemplateValidatorExecutorContract { - - @Override - public VfValidatorExecutor createTestSubject(JanusGraphDao dao) { - return new VfValidatorExecutor(new ArrayList<>(), dao); - } -} diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java deleted file mode 100644 index 317932d9d9..0000000000 --- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ElementTypeEnumTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.asdctool.impl.validator.utils; - -import org.junit.Test; - -import java.util.List; - - -public class ElementTypeEnumTest { - - private ElementTypeEnum createTestSubject() { - return ElementTypeEnum.VF; - } - - - @Test - public void testGetByType() { - String elementType = ""; - ElementTypeEnum result; - - // default test - result = ElementTypeEnum.getByType(elementType); - result = ElementTypeEnum.getByType(ElementTypeEnum.VF.getElementType()); - } - - - @Test - public void testGetAllTypes() { - List result; - - // default test - result = ElementTypeEnum.getAllTypes(); - } - - - @Test - public void testGetElementType() { - ElementTypeEnum testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getElementType(); - } - - - @Test - public void testSetElementType() { - ElementTypeEnum testSubject; - String elementType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setElementType(elementType); - } - - - @Test - public void testGetClazz() { - ElementTypeEnum testSubject; - Class result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getClazz(); - } - - - @Test - public void testSetClazz() { - ElementTypeEnum testSubject; - Class clazz = null; - - // default test - testSubject = createTestSubject(); - testSubject.setClazz(clazz); - } -} -- cgit 1.2.3-korg