summaryrefslogtreecommitdiffstats
path: root/asdctool/src/test
diff options
context:
space:
mode:
authorFrancis Toth <francis.toth@yoppworks.com>2020-04-20 18:43:20 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-05-28 07:48:23 +0000
commitf38f7e583f1d311e0fe108c09d201112bb4d135f (patch)
treedc9828c729f9ba2f1259cd40becd017d6206d337 /asdctool/src/test
parent1de7b75829b3bf0c06ee7a8b3006b0edfb239420 (diff)
Encapsulate ReportManager's failedVerticesPerTask and resultsPerVertex in Report
This commit aims to encapsulate the static fields failedVerticesPerTask and resultsPerVertex in their own class (called Report). In the short terms, any state needing to be passed around will be stored there. Unfortunately, this commit required many minor changes in functions signature (to pass the Report instance). Signed-off-by: Francis Toth <francis.toth@yoppworks.com> Change-Id: I3756d9a939cbd0f2856be72aa2bd24a3980dde49 Issue-ID: SDC-2499
Diffstat (limited to 'asdctool/src/test')
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/ValidationToolBLTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java15
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java17
8 files changed, 38 insertions, 18 deletions
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 b412d7bc92..3db011bae5 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
@@ -22,6 +22,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.report.Report;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import java.util.ArrayList;
@@ -41,8 +42,9 @@ public class ValidationToolBLTest {
ValidationToolBL testSubject = createTestSubject();
testSubject.validators = new LinkedList<>();
testSubject.validators.add(new ServiceValidatorExecuter(janusGraphDaoMock));
+ Report report = Report.make();
// 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);
+ testSubject.validateAll(report, null);
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
index a1728d8a94..98b8b250c3 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/ServiceValidatorExecuterTest.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
import org.junit.Test;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import static org.mockito.Mockito.mock;
@@ -39,8 +40,9 @@ public class ServiceValidatorExecuterTest {
@Test(expected = NullPointerException.class)
public void testExecuteValidations() {
+ Report report = Report.make();
// 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);
+ createTestSubject().executeValidations(report, null);
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
index c9bc5debd6..8ea87b1241 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/executers/VfValidatorExecuterTest.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.executers;
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;
@@ -45,8 +46,9 @@ public class VfValidatorExecuterTest {
@Test(expected = NullPointerException.class)
public void testExecuteValidations() {
+ Report report = Report.make();
// 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);
+ createTestSubject().executeValidations(report, null);
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
index 0399dbed38..354714b0c2 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java
@@ -30,6 +30,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManagerHelper;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
@@ -113,12 +114,13 @@ public class ArtifactValidationUtilsTest {
@Test
public void testValidateArtifactsAreInCassandra() {
// given
+ Report report = Report.make();
List<ArtifactDataDefinition> artifacts = new ArrayList<>();
artifacts.add(artifactDataDefinition);
// when
ArtifactsVertexResult result =
- testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts, txtReportFilePath);
+ testSubject.validateArtifactsAreInCassandra(report, vertex, TASK_NAME, artifacts, txtReportFilePath);
List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
@@ -131,14 +133,15 @@ public class ArtifactValidationUtilsTest {
@Test
public void testValidateArtifactsNotInCassandra() {
// given
+ Report report = Report.make();
List<ArtifactDataDefinition> artifacts = new ArrayList<>();
artifacts.add(artifactDataDefinition);
artifacts.add(artifactDataDefinitionNotInCassandra);
// when
ArtifactsVertexResult result =
- testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts, txtReportFilePath);
- ReportManager.reportEndOfToolRun(csvReportFilePath, txtReportFilePath);
+ testSubject.validateArtifactsAreInCassandra(report, vertex, TASK_NAME, artifacts, txtReportFilePath);
+ ReportManager.reportEndOfToolRun(report, csvReportFilePath, txtReportFilePath);
List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
@@ -195,6 +198,7 @@ public class ArtifactValidationUtilsTest {
@Test
public void testValidateTopologyTemplateArtifacts() {
// given
+ Report report = Report.make();
Map<String, ArtifactDataDefinition> artifacts = new HashMap<>();
artifacts.put(ES_ID, artifactDataDefinition);
@@ -214,7 +218,7 @@ public class ArtifactValidationUtilsTest {
// when
ArtifactsVertexResult result =
- testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME, txtReportFilePath);
+ testSubject.validateTopologyTemplateArtifacts(report, vertex, TASK_NAME, txtReportFilePath);
List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
@@ -229,12 +233,13 @@ public class ArtifactValidationUtilsTest {
@Test
public void testValidateTopologyTemplateArtifactsNotFoundToscaElement() {
// given
+ Report report = Report.make();
when(topologyTemplateOperation.getToscaElement(eq(vertex.getUniqueId()), any()))
.thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
// when
ArtifactsVertexResult result =
- testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME, txtReportFilePath);
+ testSubject.validateTopologyTemplateArtifacts(report, vertex, TASK_NAME, txtReportFilePath);
// then
assertFalse(result.getStatus());
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
index cf28d74803..b45b589752 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
import org.junit.Test;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -38,11 +39,12 @@ public class ServiceArtifactValidationTaskTest {
@Test
public void testValidate() {
+ Report report = Report.make();
GraphVertex vertex = null;
ServiceArtifactValidationTask testSubject = createTestSubject();
// Initially no outputFilePath was passed to this function (hence it is set to null)
// TODO: Fix this null and see if the argument is used by this function
- VertexResult actual = testSubject.validate(vertex, null);
+ VertexResult actual = testSubject.validate(report, vertex, null);
assertThat(actual, is(nullValue()));
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
index 5302f4f23e..60e41abf4f 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
import org.junit.Test;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -38,11 +39,12 @@ public class VfArtifactValidationTaskTest {
@Test
public void testValidate() {
+ Report report = Report.make();
GraphVertex vertex = null;
VfArtifactValidationTask testSubject = createTestSubject();
// Initially no outputFilePath was passed to this function (hence it is set to null)
// TODO: Fix this null and see if the argument is used by this function
- VertexResult actual = testSubject.validate(vertex, null);
+ VertexResult actual = testSubject.validate(report, vertex, null);
assertThat(actual, is(nullValue()));
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
index 9a9f20bcc7..4ea31386e4 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/moduleJson/ModuleJsonTaskTest.java
@@ -27,6 +27,7 @@ import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
@@ -89,7 +90,8 @@ public class ModuleJsonTaskTest {
// Initially no outputFilePath was passed to this function (hence it is set to null)
// TODO: Fix this null and see if the argument is used by this function
try {
- VertexResult actual = test.validate(vertex, null);
+ Report report = Report.make();
+ VertexResult actual = test.validate(report, vertex, null);
assertThat(actual.getStatus(), is(true));
} catch (Exception e) {
// TODO: Fix this test, as currently, any exception is ignored
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
index e87347269c..c231ca3677 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java
@@ -26,6 +26,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import java.io.File;
@@ -63,7 +64,7 @@ public class ReportManagerTest {
private final SortedSet<String> successTasksNames =
new TreeSet<>(Arrays.asList(TASK_1_NAME, TASK_2_NAME));
- private VertexResult successResult = new VertexResult();
+ private final VertexResult successResult = new VertexResult();
private final static String resourcePath = new File("src/test/resources").getAbsolutePath();
private final static String csvReportFilePath = ValidationConfigManager
@@ -86,9 +87,10 @@ public class ReportManagerTest {
@Test
public void testReportTaskEnd() {
// when
- ReportManager.reportTaskEnd(VERTEX_1_ID, TASK_1_NAME, successResult);
- ReportManager.reportTaskEnd(VERTEX_2_ID, TASK_2_NAME, successResult);
- ReportManager.printAllResults(csvReportFilePath);
+ Report report = Report.make();
+ report.addSuccess(VERTEX_1_ID, TASK_1_NAME, successResult);
+ report.addSuccess(VERTEX_2_ID, TASK_2_NAME, successResult);
+ ReportManager.printAllResults(report, csvReportFilePath);
List<String> reportCsvFile = ReportManagerHelper.getReportCsvFileAsList(csvReportFilePath);
@@ -102,10 +104,11 @@ public class ReportManagerTest {
@Test
public void testAddFailedVertex() {
// when
- ReportManager.addFailedVertex(TASK_1_NAME, VERTEX_1_ID);
- ReportManager.reportEndOfToolRun(csvReportFilePath, txtReportFilePath);
+ Report report = Report.make();
+ report.addFailure(TASK_1_NAME, VERTEX_1_ID);
+ ReportManager.reportEndOfToolRun(report, csvReportFilePath, txtReportFilePath);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
+ List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
// then
assertNotNull(reportOutputFile);