summaryrefslogtreecommitdiffstats
path: root/asdctool/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'asdctool/src/test/java')
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java27
-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/ReportManagerHelper.java8
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java38
4 files changed, 54 insertions, 50 deletions
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java
index efc7dd82a8..570e5b21df 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java
@@ -20,6 +20,10 @@
package org.openecomp.sdc.asdctool.impl.validator.config;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager.csvReportFilePath;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
@@ -33,27 +37,20 @@ import java.util.Properties;
public class ValidationConfigManagerTest {
@Test
- public void testGetOutputFilePath() {
- String result;
-
- // default test
- result = ValidationConfigManager.getOutputFilePath();
+ public void testCsvReportFilePath() {
+ String randomOutput = System.currentTimeMillis() + "";
+ long millis = System.currentTimeMillis();
+ assertThat(
+ csvReportFilePath(randomOutput, () -> millis),
+ is(randomOutput + "/csvSummary_" + millis + ".csv"));
}
@Test
- public void testGetCsvReportFilePath() {
+ public void testGetOutputFilePath() {
String result;
// default test
- result = ValidationConfigManager.getCsvReportFilePath();
- }
-
- @Test
- public void testSetCsvReportFilePath() {
- String outputPath = "";
-
- // default test
- ValidationConfigManager.setCsvReportFilePath(outputPath);
+ result = ValidationConfigManager.getOutputFilePath();
}
@Test
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 b5ce1abca0..1af4a13472 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
@@ -64,7 +64,7 @@ import static org.mockito.Mockito.when;
@PowerMockRunnerDelegate(MockitoJUnitRunner.class)
@PrepareForTest({ReportManager.class})
public class ArtifactValidationUtilsTest {
-
+
@Mock
private ArtifactCassandraDao artifactCassandraDao;
@Mock
@@ -91,12 +91,15 @@ public class ArtifactValidationUtilsTest {
private static final String UNIQUE_ID = "4321";
private static final String UNIQUE_ID_VERTEX = "321";
+ private final static String resourcePath = new File("src/test/resources").getAbsolutePath();
+ private final static String csvReportFilePath = ValidationConfigManager.DEFAULT_CSV_PATH;
+
public void initReportManager() {
String resourcePath = new File(Objects
.requireNonNull(ArtifactValidationUtilsTest.class.getClassLoader().getResource(""))
.getFile()).getAbsolutePath();
ValidationConfigManager.setOutputFullFilePath(resourcePath);
- new ReportManager();
+ ReportManager.make(csvReportFilePath);
}
@Before
@@ -115,7 +118,7 @@ public class ArtifactValidationUtilsTest {
@After
public void clean() {
- ReportManagerHelper.cleanReports();
+ ReportManagerHelper.cleanReports(csvReportFilePath);
}
@Test
@@ -146,7 +149,7 @@ public class ArtifactValidationUtilsTest {
// when
ArtifactsVertexResult result =
testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts);
- ReportManager.reportEndOfToolRun();
+ ReportManager.reportEndOfToolRun(csvReportFilePath);
List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
@@ -203,19 +206,19 @@ public class ArtifactValidationUtilsTest {
@Test
public void testValidateTopologyTemplateArtifacts() {
// given
- Map<String, ArtifactDataDefinition> artifacts = new HashMap<>();
- artifacts.put(ES_ID, artifactDataDefinition);
+ Map<String, ArtifactDataDefinition> artifacts = new HashMap<>();
+ artifacts.put(ES_ID, artifactDataDefinition);
- when(topologyTemplate.getDeploymentArtifacts()).thenReturn(artifacts);
- when(topologyTemplate.getArtifacts()).thenReturn(artifacts);
- when(topologyTemplate.getServiceApiArtifacts()).thenReturn(artifacts);
+ when(topologyTemplate.getDeploymentArtifacts()).thenReturn(artifacts);
+ when(topologyTemplate.getArtifacts()).thenReturn(artifacts);
+ when(topologyTemplate.getServiceApiArtifacts()).thenReturn(artifacts);
- when(mapToscaDataDefinition.getMapToscaDataDefinition()).thenReturn(artifacts);
- Map<String, MapArtifactDataDefinition> artifactsMap = new HashMap<>();
- artifactsMap.put(ES_ID, mapToscaDataDefinition);
+ when(mapToscaDataDefinition.getMapToscaDataDefinition()).thenReturn(artifacts);
+ Map<String, MapArtifactDataDefinition> artifactsMap = new HashMap<>();
+ artifactsMap.put(ES_ID, mapToscaDataDefinition);
- when(topologyTemplate.getInstanceArtifacts()).thenReturn(artifactsMap);
- when(topologyTemplate.getInstDeploymentArtifacts()).thenReturn(artifactsMap);
+ when(topologyTemplate.getInstanceArtifacts()).thenReturn(artifactsMap);
+ when(topologyTemplate.getInstDeploymentArtifacts()).thenReturn(artifactsMap);
when(topologyTemplateOperation.getToscaElement(eq(vertex.getUniqueId()), any()))
.thenReturn(Either.left(topologyTemplate));
diff --git a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
index c832c47df4..011039d591 100644
--- a/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
+++ b/asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerHelper.java
@@ -38,12 +38,12 @@ public class ReportManagerHelper {
return readFileAsList(ValidationConfigManager.getOutputFullFilePath());
}
- public static List<String> getReportCsvFileAsList() {
- return readFileAsList(ValidationConfigManager.getCsvReportFilePath());
+ public static List<String> getReportCsvFileAsList(String csvReportFilePath) {
+ return readFileAsList(csvReportFilePath);
}
- public static void cleanReports() {
- cleanFile(ValidationConfigManager.getCsvReportFilePath());
+ public static void cleanReports(String csvReportFilePath) {
+ cleanFile(csvReportFilePath);
cleanFile(ValidationConfigManager.getOutputFullFilePath());
}
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 4926c1dee1..22aaf6e539 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
@@ -74,24 +74,28 @@ public class ReportManagerTest {
private 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);
+
+
@Mock
GraphVertex vertexScanned;
- @Before
+ @Before
public void setup() {
String resourcePath = new File(Objects
.requireNonNull(ReportManagerTest.class.getClassLoader().getResource("")).getFile())
- .getAbsolutePath();
+ .getAbsolutePath();
ValidationConfigManager.setOutputFullFilePath(resourcePath);
- ValidationConfigManager.setCsvReportFilePath(resourcePath);
- new ReportManager();
+ ReportManager.make(csvReportFilePath);
successResult.setStatus(true);
}
@After
public void clean() {
- ReportManagerHelper.cleanReports();
+ ReportManagerHelper.cleanReports(csvReportFilePath);
}
@Test
@@ -99,9 +103,9 @@ public class ReportManagerTest {
// when
ReportManager.reportTaskEnd(VERTEX_1_ID, TASK_1_NAME, successResult);
ReportManager.reportTaskEnd(VERTEX_2_ID, TASK_2_NAME, successResult);
- ReportManager.printAllResults();
+ ReportManager.printAllResults(csvReportFilePath);
- List reportCsvFile = ReportManagerHelper.getReportCsvFileAsList();
+ List<String> reportCsvFile = ReportManagerHelper.getReportCsvFileAsList(csvReportFilePath);
// then
assertNotNull(reportCsvFile);
@@ -114,7 +118,7 @@ public class ReportManagerTest {
public void testAddFailedVertex() {
// when
ReportManager.addFailedVertex(TASK_1_NAME, VERTEX_1_ID);
- ReportManager.reportEndOfToolRun();
+ ReportManager.reportEndOfToolRun(csvReportFilePath);
List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
@@ -178,19 +182,19 @@ public class ReportManagerTest {
reportOutputFile.get(4));
}
- @Test
- public void testReportStartValidatorRun() {
- // when
- ReportManager.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM);
+ @Test
+ public void testReportStartValidatorRun() {
+ // when
+ ReportManager.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM);
- List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
+ List reportOutputFile = ReportManagerHelper.getReportOutputFileAsList();
- // then
+ // then
assertNotNull(reportOutputFile);
assertEquals(EXPECTED_OUTPUT_FILE_HEADER, reportOutputFile.get(0));
assertEquals("------ValidatorExecuter " + VALIDATOR_NAME + " Validation Started, on "
+ COMPONENT_SUM + " components---------", reportOutputFile.get(2));
- }
+ }
@Test
public void testReportStartTaskRun() {
@@ -206,11 +210,11 @@ public class ReportManagerTest {
assertNotNull(reportOutputFile);
assertEquals(EXPECTED_OUTPUT_FILE_HEADER, reportOutputFile.get(0));
assertEquals("-----------------------Vertex: " + UNIQUE_ID + ", Task " + TASK_1_NAME
- + " Started-----------------------", reportOutputFile.get(2));
+ + " Started-----------------------", reportOutputFile.get(2));
}
private String getCsvExpectedResult(String vertexID, String taskID) {
- return String.join(",", new String[] {vertexID, taskID,
+ return String.join(",", new String[]{vertexID, taskID,
String.valueOf(successResult.getStatus()), successResult.getResult()});
}
} \ No newline at end of file