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;
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;
@Mock
private TopologyTemplate topologyTemplate;
+ @TempDir
+ static Path reportOutputPath;
+
+ @BeforeAll
+ static void beforeAll() {
+ txtReportFilePath = ValidationConfigManager.txtReportFilePath(reportOutputPath.toString());
+ }
+
@BeforeEach
public void initMocks() {
MockitoAnnotations.openMocks(this);
}
@Test
- public void testValidateArtifactsAreInCassandra() {
+ void testValidateArtifactsAreInCassandra() {
// given
Report report = Report.make();
List<ArtifactDataDefinition> artifacts = new ArrayList<>();
}
@Test
- public void testValidateArtifactsNotInCassandra() {
+ void testValidateArtifactsNotInCassandra() {
// given
Report report = Report.make();
List<ArtifactDataDefinition> artifacts = new ArrayList<>();
}
@Test
- public void testIsArtifactsInCassandra() {
+ void testIsArtifactsInCassandra() {
// when
boolean notInCass = testSubject.isArtifactInCassandra(ES_ID_NOT_IN_CASS);
boolean inCass = testSubject.isArtifactInCassandra(ES_ID);
}
@Test
- public void testAddRelevantArtifacts() {
+ void testAddRelevantArtifacts() {
// given
Map<String, ArtifactDataDefinition> artifactsMap = new HashMap<>();
artifactsMap.put(ES_ID_NOT_IN_CASS, artifactDataDefinitionNotInCassandra);
}
@Test
- public void testAddRelevantArtifactsWithNullEsId() {
+ void testAddRelevantArtifactsWithNullEsId() {
// given
Map<String, ArtifactDataDefinition> artifactsMap = new HashMap<>();
artifactsMap.put("", artifactDataDefinitionDummy);
}
@Test
- public void testValidateTopologyTemplateArtifacts() {
+ void testValidateTopologyTemplateArtifacts() {
// given
Report report = Report.make();
Map<String, ArtifactDataDefinition> artifacts = new HashMap<>();
}
@Test
- public void testValidateTopologyTemplateArtifactsNotFoundToscaElement() {
+ void testValidateTopologyTemplateArtifactsNotFoundToscaElement() {
// given
Report report = Report.make();
when(topologyTemplateOperation.getToscaElement(eq(vertex.getUniqueId()), any()))
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";
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);
}
@Test
- public void testAddFailedVertex() {
+ void testAddFailedVertex() {
// when
Report report = Report.make();
report.addFailure(TASK_1_NAME, VERTEX_1_ID);
}
@Test
- public void testPrintValidationTaskStatus() {
+ void testPrintValidationTaskStatus() {
// given
when(vertexScanned.getUniqueId()).thenReturn(UNIQUE_ID);
}
@Test
- public void testWriteReportLineToFile() {
+ void testWriteReportLineToFile() {
// when
List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
file.writeReportLineToFile(DUMMY_MESSAGE);
}
@Test
- public void testReportValidatorTypeSummary() {
+ void testReportValidatorTypeSummary() {
// when
List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
file.reportValidatorTypeSummary(VALIDATOR_NAME, failedTasksNames, successTasksNames);
}
@Test
- public void testReportStartValidatorRun() {
+ void testReportStartValidatorRun() {
// when
List<String> reportTxtFile = ReportFileNioHelper.withTxtFile(txtReportFilePath, file -> {
file.reportStartValidatorRun(VALIDATOR_NAME, COMPONENT_SUM);
}
@Test
- public void testReportStartTaskRun() {
+ void testReportStartTaskRun() {
// given
when(vertexScanned.getUniqueId()).thenReturn(UNIQUE_ID);