aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'asdctool/src/test')
-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/report/ReportFileNioHelper.java4
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java61
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ServiceArtifactValidationTaskTest.java19
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/VfArtifactValidationTaskTest.java9
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java46
7 files changed, 62 insertions, 85 deletions
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 2f9f11b28f..41fb048757 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
@@ -43,8 +43,6 @@ 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(report, makeTxtFile(makeConsoleWriter()), null);
+ createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter()));
}
}
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 3760a57e33..aa388f68b7 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
@@ -48,8 +48,6 @@ 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(report, makeTxtFile(makeConsoleWriter()), null);
+ createTestSubject().executeValidations(report, makeTxtFile(makeConsoleWriter()));
}
}
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFileNioHelper.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFileNioHelper.java
index cd35f4ba2e..2ef85fda1f 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFileNioHelper.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/report/ReportFileNioHelper.java
@@ -78,9 +78,7 @@ public class ReportFileNioHelper {
* @param <A> The type returned by the function consuming the file
*/
public static <A> A withTxtFile(String txtReportFilePath, Function<ReportFile.TXTFile, A> f) {
- // TODO: Switch to makeTxtFile once all the report file business logic has been moved to
- // ReportFile
- ReportFile.TXTFile file = ReportFile.makeAppendableTxtFile(makeNioWriter(txtReportFilePath));
+ ReportFile.TXTFile file = ReportFile.makeTxtFile(makeNioWriter(txtReportFilePath));
A result = f.apply(file);
try {
Files.delete(Paths.get(txtReportFilePath));
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 763c69f61e..26ad7d8e20 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
@@ -37,17 +37,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.IntStream;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
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;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -101,16 +97,6 @@ public class ArtifactValidationUtilsTest {
when(vertex.getUniqueId()).thenReturn(UNIQUE_ID_VERTEX);
}
- @BeforeEach
- public void setup() {
- ReportManager.make(txtReportFilePath);
- }
-
- @AfterEach
- public void clean() {
- ReportManagerHelper.cleanReports(txtReportFilePath);
- }
-
@Test
public void testValidateArtifactsAreInCassandra() {
// given
@@ -119,15 +105,17 @@ public class ArtifactValidationUtilsTest {
artifacts.add(artifactDataDefinition);
// when
- ArtifactsVertexResult result =
- testSubject.validateArtifactsAreInCassandra(report, vertex, TASK_NAME, artifacts, txtReportFilePath);
+ withTxtFile(txtReportFilePath, file -> {
+ ArtifactsVertexResult result =
+ testSubject.validateArtifactsAreInCassandra(report, vertex, TASK_NAME, artifacts, file);
- List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
+ List<String> reportOutputFile = readFileAsList(txtReportFilePath);
- // then
- assertTrue(result.getStatus());
- assertEquals(0, result.notFoundArtifacts.size());
- assertEquals("Artifact " + ES_ID + " is in Cassandra", reportOutputFile.get(2));
+ // then
+ assertTrue(result.getStatus());
+ assertEquals(0, result.notFoundArtifacts.size());
+ assertEquals("Artifact " + ES_ID + " is in Cassandra", reportOutputFile.get(2));
+ });
}
@Test
@@ -141,7 +129,7 @@ public class ArtifactValidationUtilsTest {
// when
withTxtFile(txtReportFilePath, file -> {
ArtifactsVertexResult result =
- testSubject.validateArtifactsAreInCassandra(report, vertex, TASK_NAME, artifacts, txtReportFilePath);
+ testSubject.validateArtifactsAreInCassandra(report, vertex, TASK_NAME, artifacts, file);
file.reportEndOfToolRun(report);
List<String> reportOutputFile = readFileAsList(txtReportFilePath);
@@ -219,17 +207,19 @@ public class ArtifactValidationUtilsTest {
.thenReturn(Either.left(topologyTemplate));
// when
- ArtifactsVertexResult result =
- testSubject.validateTopologyTemplateArtifacts(report, vertex, TASK_NAME, txtReportFilePath);
+ withTxtFile(txtReportFilePath, file -> {
+ ArtifactsVertexResult result =
+ testSubject.validateTopologyTemplateArtifacts(report, vertex, TASK_NAME, file);
- List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
+ List<String> reportOutputFile = readFileAsList(txtReportFilePath);
- // then
- assertTrue(result.getStatus());
- assertEquals(0, result.notFoundArtifacts.size());
+ // then
+ assertTrue(result.getStatus());
+ assertEquals(0, result.notFoundArtifacts.size());
- IntStream.range(2, reportOutputFile.size()).forEach(
- i -> assertEquals("Artifact " + ES_ID + " is in Cassandra", reportOutputFile.get(i)));
+ IntStream.range(2, reportOutputFile.size()).forEach(
+ i -> assertEquals("Artifact " + ES_ID + " is in Cassandra", reportOutputFile.get(i)));
+ });
}
@Test
@@ -240,10 +230,11 @@ public class ArtifactValidationUtilsTest {
.thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
// when
- ArtifactsVertexResult result =
- testSubject.validateTopologyTemplateArtifacts(report, vertex, TASK_NAME, txtReportFilePath);
-
- // then
- assertFalse(result.getStatus());
+ withTxtFile(txtReportFilePath, file -> {
+ ArtifactsVertexResult result =
+ testSubject.validateTopologyTemplateArtifacts(report, vertex, TASK_NAME, file);
+ // 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 b45b589752..849c679376 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
@@ -20,15 +20,17 @@
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;
-
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
+import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile;
+
+import org.junit.Test;
+import org.openecomp.sdc.asdctool.impl.validator.report.Report;
+import org.openecomp.sdc.asdctool.impl.validator.report.ReportFileWriterTestFactory;
+import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
public class ServiceArtifactValidationTaskTest {
@@ -42,9 +44,10 @@ public class ServiceArtifactValidationTaskTest {
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(report, vertex, null);
+ VertexResult actual = testSubject.validate(
+ report, vertex,
+ makeTxtFile(ReportFileWriterTestFactory.makeConsoleWriter())
+ );
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 60e41abf4f..a70326b928 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
@@ -22,6 +22,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.report.ReportFileWriterTestFactory;
import org.openecomp.sdc.asdctool.impl.validator.utils.VertexResult;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
@@ -29,6 +30,7 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
+import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFile.makeTxtFile;
public class VfArtifactValidationTaskTest {
@@ -42,9 +44,10 @@ public class VfArtifactValidationTaskTest {
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(report, vertex, null);
+ VertexResult actual = testSubject.validate(
+ report, vertex,
+ makeTxtFile(ReportFileWriterTestFactory.makeConsoleWriter())
+ );
assertThat(actual, is(nullValue()));
}
}
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 d2276fdd5a..af056103ff 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
@@ -21,24 +21,21 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
-import org.junit.jupiter.api.AfterEach;
-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.asdctool.impl.validator.report.ReportFileNioHelper;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.mockito.Mockito.when;
+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.asdctool.impl.validator.report.ReportFileNioHelper;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
public class ReportManagerTest {
@@ -74,17 +71,6 @@ public class ReportManagerTest {
private final GraphVertex vertexScanned = Mockito.mock(GraphVertex.class);
- @BeforeEach
- public void setup() {
- ReportManager.make(txtReportFilePath);
- successResult.setStatus(true);
- }
-
- @AfterEach
- public void clean() {
- ReportManagerHelper.cleanReports(txtReportFilePath);
- }
-
@Test
public void testReportTaskEnd() {
// when
@@ -144,15 +130,15 @@ public class ReportManagerTest {
@Test
public void testWriteReportLineToFile() {
// when
- ReportManager.writeReportLineToFile(DUMMY_MESSAGE, txtReportFilePath);
-
- List<String> reportOutputFile = ReportManagerHelper.getReportOutputFileAsList(txtReportFilePath);
+ List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
+ file.writeReportLineToFile(DUMMY_MESSAGE);
+ return ReportFileNioHelper.readFileAsList(txtReportFilePath);
+ });
// then
- assertNotNull(reportOutputFile);
-
- assertEquals(EXPECTED_OUTPUT_FILE_HEADER, reportOutputFile.get(0));
- assertEquals(DUMMY_MESSAGE, reportOutputFile.get(2));
+ assertNotNull(reportTxtFile);
+ assertEquals(EXPECTED_OUTPUT_FILE_HEADER, reportTxtFile.get(0));
+ assertEquals(DUMMY_MESSAGE, reportTxtFile.get(2));
}
@Test