aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-04-20 16:55:18 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2022-04-20 22:41:17 +0000
commit4aec2ba08cf3dcb75e07f2a66d162142382d4a4a (patch)
treec0b9c9ee8134ae327f89e2bd434f9386cb569485 /asdctool
parentbdc400de969cdfb72b1e681ca1f38161f4f5db57 (diff)
Fix unit tests with conflicting folder
Fixes two tests that relies on the same output folder from ValidationConfigManager.txtReportFilePath. This was resulting in intermittent errors during the build. Change-Id: I7bafc022dd38e2fe8e648abc8ec1d113ef7346b4 Issue-ID: SDC-3975 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'asdctool')
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java31
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java35
2 files changed, 42 insertions, 24 deletions
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 f3997edd40..44b13bd8cc 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
@@ -31,15 +31,17 @@ import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileNioHelp
import static org.openecomp.sdc.asdctool.impl.validator.report.ReportFileNioHelper.withTxtFile;
import fj.data.Either;
-import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -54,15 +56,14 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-public class ArtifactValidationUtilsTest {
+class ArtifactValidationUtilsTest {
private static final String ES_ID = "testEsInCassandra";
private static final String ES_ID_NOT_IN_CASS = "testEsNotInCassandra";
private static final String TASK_NAME = "testTaskName";
private static final String UNIQUE_ID = "4321";
private static final String UNIQUE_ID_VERTEX = "321";
- private static final String resourcePath = new File("src/test/resources").getAbsolutePath();
- private static final String txtReportFilePath = ValidationConfigManager.txtReportFilePath(resourcePath);
+ private static String txtReportFilePath;
@InjectMocks
private ArtifactValidationUtils testSubject;
@@ -84,6 +85,14 @@ public class ArtifactValidationUtilsTest {
@Mock
private TopologyTemplate topologyTemplate;
+ @TempDir
+ static Path reportOutputPath;
+
+ @BeforeAll
+ static void beforeAll() {
+ txtReportFilePath = ValidationConfigManager.txtReportFilePath(reportOutputPath.toString());
+ }
+
@BeforeEach
public void initMocks() {
MockitoAnnotations.openMocks(this);
@@ -98,7 +107,7 @@ public class ArtifactValidationUtilsTest {
}
@Test
- public void testValidateArtifactsAreInCassandra() {
+ void testValidateArtifactsAreInCassandra() {
// given
Report report = Report.make();
List<ArtifactDataDefinition> artifacts = new ArrayList<>();
@@ -119,7 +128,7 @@ public class ArtifactValidationUtilsTest {
}
@Test
- public void testValidateArtifactsNotInCassandra() {
+ void testValidateArtifactsNotInCassandra() {
// given
Report report = Report.make();
List<ArtifactDataDefinition> artifacts = new ArrayList<>();
@@ -148,7 +157,7 @@ public class ArtifactValidationUtilsTest {
}
@Test
- public void testIsArtifactsInCassandra() {
+ void testIsArtifactsInCassandra() {
// when
boolean notInCass = testSubject.isArtifactInCassandra(ES_ID_NOT_IN_CASS);
boolean inCass = testSubject.isArtifactInCassandra(ES_ID);
@@ -159,7 +168,7 @@ public class ArtifactValidationUtilsTest {
}
@Test
- public void testAddRelevantArtifacts() {
+ void testAddRelevantArtifacts() {
// given
Map<String, ArtifactDataDefinition> artifactsMap = new HashMap<>();
artifactsMap.put(ES_ID_NOT_IN_CASS, artifactDataDefinitionNotInCassandra);
@@ -173,7 +182,7 @@ public class ArtifactValidationUtilsTest {
}
@Test
- public void testAddRelevantArtifactsWithNullEsId() {
+ void testAddRelevantArtifactsWithNullEsId() {
// given
Map<String, ArtifactDataDefinition> artifactsMap = new HashMap<>();
artifactsMap.put("", artifactDataDefinitionDummy);
@@ -186,7 +195,7 @@ public class ArtifactValidationUtilsTest {
}
@Test
- public void testValidateTopologyTemplateArtifacts() {
+ void testValidateTopologyTemplateArtifacts() {
// given
Report report = Report.make();
Map<String, ArtifactDataDefinition> artifacts = new HashMap<>();
@@ -223,7 +232,7 @@ public class ArtifactValidationUtilsTest {
}
@Test
- public void testValidateTopologyTemplateArtifactsNotFoundToscaElement() {
+ void testValidateTopologyTemplateArtifactsNotFoundToscaElement() {
// given
Report report = Report.make();
when(topologyTemplateOperation.getToscaElement(eq(vertex.getUniqueId()), any()))
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 af056103ff..c8d524878d 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
@@ -25,19 +25,21 @@ 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.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
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 {
+class ReportManagerTest {
private static final String VERTEX_1_ID = "testID1";
private static final String TASK_1_FAILED_NAME = "testFailedTask1";
@@ -64,15 +66,22 @@ public class ReportManagerTest {
private final VertexResult successResult = new VertexResult();
- private final static String resourcePath = new File("src/test/resources").getAbsolutePath();
- private final static String csvReportFilePath = ValidationConfigManager
- .csvReportFilePath(resourcePath, System::currentTimeMillis);
- private final static String txtReportFilePath = ValidationConfigManager.txtReportFilePath(resourcePath);
+ private static String csvReportFilePath;
+ private static String txtReportFilePath;
private final GraphVertex vertexScanned = Mockito.mock(GraphVertex.class);
+ @TempDir
+ static Path reportOutputPath;
+
+ @BeforeAll
+ static void beforeAll() {
+ csvReportFilePath = ValidationConfigManager.csvReportFilePath(reportOutputPath.toString(), System::currentTimeMillis);
+ txtReportFilePath = ValidationConfigManager.txtReportFilePath(reportOutputPath.toString());
+ }
+
@Test
- public void testReportTaskEnd() {
+ void testReportTaskEnd() {
// when
Report report = Report.make();
report.addSuccess(VERTEX_1_ID, TASK_1_NAME, successResult);
@@ -91,7 +100,7 @@ public class ReportManagerTest {
}
@Test
- public void testAddFailedVertex() {
+ void testAddFailedVertex() {
// when
Report report = Report.make();
report.addFailure(TASK_1_NAME, VERTEX_1_ID);
@@ -110,7 +119,7 @@ public class ReportManagerTest {
}
@Test
- public void testPrintValidationTaskStatus() {
+ void testPrintValidationTaskStatus() {
// given
when(vertexScanned.getUniqueId()).thenReturn(UNIQUE_ID);
@@ -128,7 +137,7 @@ public class ReportManagerTest {
}
@Test
- public void testWriteReportLineToFile() {
+ void testWriteReportLineToFile() {
// when
List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
file.writeReportLineToFile(DUMMY_MESSAGE);
@@ -142,7 +151,7 @@ public class ReportManagerTest {
}
@Test
- public void testReportValidatorTypeSummary() {
+ void testReportValidatorTypeSummary() {
// when
List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
file.reportValidatorTypeSummary(VALIDATOR_NAME, failedTasksNames, successTasksNames);
@@ -159,7 +168,7 @@ public class ReportManagerTest {
}
@Test
- public void testReportStartValidatorRun() {
+ void testReportStartValidatorRun() {
// when
List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
file.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM);
@@ -174,7 +183,7 @@ public class ReportManagerTest {
}
@Test
- public void testReportStartTaskRun() {
+ void testReportStartTaskRun() {
// given
when(vertexScanned.getUniqueId()).thenReturn(UNIQUE_ID);