@Autowired(required = false)
public ServiceValidatorExecutor(JanusGraphDao janusGraphDao) {
- super(janusGraphDao);
- setName("SERVICE_VALIDATOR");
+ super(janusGraphDao, "SERVICE_VALIDATOR");
}
@Override
import java.util.List;
import java.util.Map;
import java.util.Set;
+import lombok.Getter;
import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.TXTFile;
import org.openecomp.sdc.asdctool.impl.validator.tasks.TopologyTemplateValidationTask;
import org.openecomp.sdc.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;
+ private final JanusGraphDao janusGraphDao;
- protected String name;
+ @Getter
+ private final String name;
- @Autowired
- public TopologyTemplateValidatorExecutor(JanusGraphDao janusGraphDao) {
+ public TopologyTemplateValidatorExecutor(JanusGraphDao janusGraphDao, String name) {
this.janusGraphDao = janusGraphDao;
- }
-
- public void setName(String name) {
this.name = name;
}
- public String getName() {
- return name;
- }
-
protected List<GraphVertex> getVerticesToValidate(ComponentTypeEnum type) {
Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class);
props.put(GraphPropertyEnum.COMPONENT_TYPE, type.name());
@Autowired(required = false)
public VfValidatorExecutor(List<VfValidationTask> tasks, JanusGraphDao janusGraphDao) {
- super(janusGraphDao);
+ super(janusGraphDao, "BASIC_VF_VALIDATOR");
this.tasks = tasks;
- setName("BASIC_VF_VALIDATOR");
}
@Override
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();
- }
+public class ServiceValidatorExecutorTest
+ implements ValidatorExecutorContract, TopologyTemplateValidatorExecutorContract {
- @Test(expected = NullPointerException.class)
- public void testExecuteValidations() {
- Report report = Report.make();
- createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter()));
+ @Override
+ public ServiceValidatorExecutor createTestSubject(JanusGraphDao dao) {
+ return new ServiceValidatorExecutor(dao);
}
}
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * 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.
* 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.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
+import static org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum.PRODUCT;
-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;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
+public interface TopologyTemplateValidatorExecutorContract {
- @Test
- public void testGetVerticesToValidate() {
- TopologyTemplateValidatorExecutor testSubject;
+ TopologyTemplateValidatorExecutor createTestSubject(JanusGraphDao dao);
- // default test
- testSubject = createTestSubject();
- Assertions.assertThrows(NullPointerException.class, () -> testSubject.getVerticesToValidate(ComponentTypeEnum.PRODUCT));
- }
+ @Test
+ default void testGetVerticesToValidate() {
+ JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
+ TopologyTemplateValidatorExecutor testSubject = createTestSubject(janusGraphDaoMock);
+ assertThrows(NullPointerException.class,
+ () -> testSubject.getVerticesToValidate(PRODUCT));
+ }
}
--- /dev/null
+/*-
+ * ============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()))
+ );
+ }
+}
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<VfValidationTask> validationTasks = new ArrayList<>();
- JanusGraphDao janusGraphDaoMock = mock(JanusGraphDao.class);
-
- return new VfValidatorExecutor(validationTasks, janusGraphDaoMock);
- }
-
- @Test
- public void testGetName() {
- createTestSubject().getName();
- }
+public class VfValidatorExecutorTest
+ implements ValidatorExecutorContract, TopologyTemplateValidatorExecutorContract {
- @Test(expected = NullPointerException.class)
- public void testExecuteValidations() {
- Report report = Report.make();
- createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter()));
+ @Override
+ public VfValidatorExecutor createTestSubject(JanusGraphDao dao) {
+ return new VfValidatorExecutor(new ArrayList<>(), dao);
}
}