aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2019-07-02 11:04:56 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-07-22 08:08:46 +0000
commit2ca6a9f860889c17202d4a518eefc980a1bb139a (patch)
tree2eba77cb98402d692cb46e0d41abf6edc84c12b0 /asdctool
parentaebdb3efa77f2cbeaf65361be3f46528f089b17a (diff)
Improved unit tests for ArtifactValidationUtils and Sonar fixes.
Added new tests for ArtifactValidationUtils. Checkstyle in the ValidationConfigManager and ArtifactValidationUtils. Added private constructor to ValidationConfigManager. Added logger for ArtifactValidationUtils and simplified code. Updated the ValidationConfigManagerTest and ReportManagerTests to not influence on each other. Issue-ID: SDC-2327 Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com> Change-Id: I9c7c725792737b6cfa6bba20eeeb3b1d4ef1e471
Diffstat (limited to 'asdctool')
-rw-r--r--asdctool/pom.xml6
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java26
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java44
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManagerTest.java130
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtilsTest.java257
-rw-r--r--asdctool/src/test/java/org/openecomp/sdc/asdctool/impl/validator/utils/ReportManagerTest.java9
6 files changed, 314 insertions, 158 deletions
diff --git a/asdctool/pom.xml b/asdctool/pom.xml
index d754deced7..3eef6cc5b3 100644
--- a/asdctool/pom.xml
+++ b/asdctool/pom.xml
@@ -490,6 +490,12 @@
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>2.0.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
index 5630a2be7f..cc75dfc968 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/config/ValidationConfigManager.java
@@ -3,13 +3,17 @@
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,6 +28,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,37 +43,40 @@ public class ValidationConfigManager {
private static String outputFullFilePath;
private static String outputFilePath;
+ private ValidationConfigManager() {
+ }
+
public static String getOutputFullFilePath() {
return outputFullFilePath;
}
+
public static String getOutputFilePath() {
return outputFilePath;
}
public static void setOutputFullFilePath(String outputPath) {
- ValidationConfigManager.outputFilePath = outputPath;
- ValidationConfigManager.outputFullFilePath = outputPath+ "/reportOutput.txt";
+ ValidationConfigManager.outputFilePath = outputPath;
+ ValidationConfigManager.outputFullFilePath = outputPath + "/reportOutput.txt";
}
-
-
public static String getCsvReportFilePath() {
return csvReportFilePath;
}
public static void setCsvReportFilePath(String outputPath) {
- ValidationConfigManager.csvReportFilePath = outputPath +"/csvSummary_"+System.currentTimeMillis()+".csv";
+ ValidationConfigManager.csvReportFilePath =
+ outputPath + "/csvSummary_" + System.currentTimeMillis() + ".csv";
}
private static String csvReportFilePath = "summary.csv";
- public static Properties setValidationConfiguration(String path){
- InputStream input = null;
+ public static Properties setValidationConfiguration(String path) {
+ InputStream input;
try {
input = new FileInputStream(path);
prop.load(input);
} catch (IOException ex) {
- log.info("FileInputStream failed - " , ex);
+ log.info("FileInputStream failed - {}", ex);
}
return prop;
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
index 025e0b61e1..2e804cc8a2 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/validator/tasks/artifacts/ArtifactValidationUtils.java
@@ -3,13 +3,14 @@
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +21,12 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
-import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
@@ -32,15 +38,18 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.TopologyTemplateOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.*;
+import fj.data.Either;
/**
* Created by chaya on 7/6/2017.
*/
public class ArtifactValidationUtils {
+ private static final Logger logger = Logger.getLogger(ArtifactValidationUtils.class);
+
private ArtifactCassandraDao artifactCassandraDao;
private TopologyTemplateOperation topologyTemplateOperation;
@@ -55,10 +64,9 @@ public class ArtifactValidationUtils {
public ArtifactsVertexResult validateArtifactsAreInCassandra(GraphVertex vertex, String taskName, List<ArtifactDataDefinition> artifacts) {
ArtifactsVertexResult result = new ArtifactsVertexResult(true);
for(ArtifactDataDefinition artifact:artifacts) {
- boolean isArtifactExist = isArtifcatInCassandra(artifact.getEsId());
+ boolean isArtifactExist = isArtifactInCassandra(artifact.getEsId());
String status = isArtifactExist ? "Artifact " + artifact.getEsId() + " is in Cassandra" :
"Artifact " + artifact.getEsId() + " doesn't exist in Cassandra";
-
ReportManager.writeReportLineToFile(status);
if (!isArtifactExist) {
ReportManager.addFailedVertex(taskName, vertex.getUniqueId());
@@ -69,24 +77,20 @@ public class ArtifactValidationUtils {
return result;
}
- public boolean isArtifcatInCassandra(String uniueId) {
+ public boolean isArtifactInCassandra(String uniqueId) {
Either<Long, CassandraOperationStatus> countOfArtifactsEither =
- artifactCassandraDao.getCountOfArtifactById(uniueId);
+ artifactCassandraDao.getCountOfArtifactById(uniqueId);
if (countOfArtifactsEither.isRight()) {
- // print to console
- System.out.print("Failed to retrieve artifact with id: "+uniueId+" from Cassandra" );
+ logger.debug("Failed to retrieve artifact with id: {} from Cassandra", uniqueId);
return false;
}
Long count = countOfArtifactsEither.left().value();
- if (count <1) {
- return false;
- }
- return true;
+ return count >= 1;
}
public List<ArtifactDataDefinition> addRelevantArtifacts(Map<String, ArtifactDataDefinition> artifactsMap) {
List<ArtifactDataDefinition> artifacts = new ArrayList<>();
- Optional.ofNullable(artifactsMap).orElse(Collections.emptyMap()).forEach( (key, dataDef) -> {
+ Optional.ofNullable(artifactsMap).orElse(Collections.emptyMap()).forEach((key, dataDef) -> {
if (dataDef.getEsId() != null && !dataDef.getEsId().isEmpty()) {
artifacts.add(dataDef);
}
@@ -119,15 +123,13 @@ public class ArtifactValidationUtils {
allArtifacts.addAll(addRelevantArtifacts(apiArtifacts));
if (instanceArtifacts != null) {
- instanceArtifacts.forEach((key, artifactMap) -> {
- allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition()));
- });
+ instanceArtifacts.forEach((key, artifactMap) ->
+ allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition())));
}
if (instanceDeploymentArtifacts != null) {
- instanceDeploymentArtifacts.forEach((key, artifactMap) -> {
- allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition()));
- });
+ instanceDeploymentArtifacts.forEach((key, artifactMap) ->
+ allArtifacts.addAll(addRelevantArtifacts(artifactMap.getMapToscaDataDefinition())));
}
return validateArtifactsAreInCassandra(vertex, taskName, allArtifacts);
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 2b169e9db8..4813cff764 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
@@ -21,77 +21,71 @@
package org.openecomp.sdc.asdctool.impl.validator.config;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Properties;
-
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ReportManager.class})
public class ValidationConfigManagerTest {
- private ValidationConfigManager createTestSubject() {
- return new ValidationConfigManager();
- }
-
-
- @Test
- public void testGetOutputFilePath() {
- String result;
-
- // default test
- result = ValidationConfigManager.getOutputFilePath();
- }
-
- @Test
- public void testGetCsvReportFilePath() {
- String result;
-
- // default test
- result = ValidationConfigManager.getCsvReportFilePath();
- }
-
-
- @Test
- public void testSetCsvReportFilePath() {
- String outputPath = "";
-
- // default test
- ValidationConfigManager.setCsvReportFilePath(outputPath);
- }
-
-
- @Test
- public void testSetValidationConfiguration() {
- String path = "";
- Properties result;
-
- // default test
- result = ValidationConfigManager.setValidationConfiguration(path);
- }
-
-
- @Test
- public void testGetValidationConfiguration() {
- Properties result;
-
- // default test
- result = ValidationConfigManager.getValidationConfiguration();
- }
-
-
- @Test
- public void testGetOutputFullFilePath() throws Exception {
- String result;
-
- // default test
- result=ValidationConfigManager.getOutputFullFilePath();
- }
-
-
- @Test
- public void testSetOutputFullFilePath() throws Exception {
- String outputPath = "";
-
-
- // default test
- ValidationConfigManager.setOutputFullFilePath(outputPath);
- }
+ @Test
+ public void testGetOutputFilePath() {
+ String result;
+
+ // default test
+ result = ValidationConfigManager.getOutputFilePath();
+ }
+
+ @Test
+ public void testGetCsvReportFilePath() {
+ String result;
+
+ // default test
+ result = ValidationConfigManager.getCsvReportFilePath();
+ }
+
+ @Test
+ public void testSetCsvReportFilePath() {
+ String outputPath = "";
+
+ // default test
+ ValidationConfigManager.setCsvReportFilePath(outputPath);
+ }
+
+ @Test
+ public void testSetValidationConfiguration() {
+ String path = "";
+ Properties result;
+
+ // default test
+ result = ValidationConfigManager.setValidationConfiguration(path);
+ }
+
+ @Test
+ public void testGetValidationConfiguration() {
+ Properties result;
+
+ // default test
+ result = ValidationConfigManager.getValidationConfiguration();
+ }
+
+ @Test
+ public void testGetOutputFullFilePath() throws Exception {
+ String result;
+
+ // default test
+ result = ValidationConfigManager.getOutputFullFilePath();
+ }
+
+ @Test
+ public void testSetOutputFullFilePath() throws Exception {
+ String outputPath = "";
+
+ // default test
+ ValidationConfigManager.setOutputFullFilePath(outputPath);
+ }
}
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 5053f4b9e3..2dca89f2fa 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
@@ -3,13 +3,14 @@
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (c) 2019 Samsung
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,69 +21,209 @@
package org.openecomp.sdc.asdctool.impl.validator.tasks.artifacts;
-import static org.mockito.Mockito.mock;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+
+import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.asdctool.impl.validator.config.ValidationConfigManager;
+import org.openecomp.sdc.asdctool.impl.validator.utils.ReportManager;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
+import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
+
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-
-import java.util.List;
-import java.util.Map;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+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;
+
+import fj.data.Either;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(MockitoJUnitRunner.class)
+@PrepareForTest({ReportManager.class})
public class ArtifactValidationUtilsTest {
+
+ @Mock
+ private ArtifactCassandraDao artifactCassandraDao;
+ @Mock
+ private TopologyTemplateOperation topologyTemplateOperation;
+ @InjectMocks
+ private ArtifactValidationUtils testSubject;
+
+ @Mock
+ private GraphVertex vertex;
+ @Mock
+ private MapArtifactDataDefinition mapToscaDataDefinition;
+ @Mock
+ private ArtifactDataDefinition artifactDataDefinition;
+ @Mock
+ private ArtifactDataDefinition artifactDataDefinitionNotInCassandra;
+ @Mock
+ private ArtifactDataDefinition artifactDataDefinitionDummy;
+ @Mock
+ private TopologyTemplate topologyTemplate;
+
+ 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";
+
+ public void initReportManager() {
+ String resourcePath = new File(Objects
+ .requireNonNull(ArtifactValidationUtilsTest.class.getClassLoader().getResource(""))
+ .getFile()).getAbsolutePath();
+ ValidationConfigManager.setOutputFullFilePath(resourcePath);
+ new ReportManager();
+ }
+
+ @Before
+ public void setup() {
+ initReportManager();
+ when(artifactCassandraDao.getCountOfArtifactById(ES_ID)).thenReturn(Either.left(1L));
+ when(artifactCassandraDao.getCountOfArtifactById(ES_ID_NOT_IN_CASS))
+ .thenReturn(Either.right(CassandraOperationStatus.NOT_FOUND));
+
+ when(artifactDataDefinition.getEsId()).thenReturn(ES_ID);
+ when(artifactDataDefinitionNotInCassandra.getEsId()).thenReturn(ES_ID_NOT_IN_CASS);
+
+ when(artifactDataDefinitionNotInCassandra.getUniqueId()).thenReturn(UNIQUE_ID);
+ when(vertex.getUniqueId()).thenReturn(UNIQUE_ID_VERTEX);
+ }
+
+ @Test
+ public void testValidateArtifactsAreInCassandra() {
+ // given
+ List<ArtifactDataDefinition> artifacts = new ArrayList<>();
+ artifacts.add(artifactDataDefinition);
+
+ // when
+ ArtifactsVertexResult result =
+ testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts);
+
+ // then
+ assertTrue(result.getStatus());
+ assertEquals(0, result.notFoundArtifacts.size());
+ }
+
+ @Test
+ public void testValidateArtifactsNotInCassandra() {
+ // given
+ List<ArtifactDataDefinition> artifacts = new ArrayList<>();
+ artifacts.add(artifactDataDefinition);
+ artifacts.add(artifactDataDefinitionNotInCassandra);
+
+ // when
+ ArtifactsVertexResult result =
+ testSubject.validateArtifactsAreInCassandra(vertex, TASK_NAME, artifacts);
+
+ // then
+ assertFalse(result.getStatus());
+ assertEquals(1, result.notFoundArtifacts.size());
+ assertEquals(UNIQUE_ID, result.notFoundArtifacts.iterator().next());
+ }
+
+ @Test
+ public void testIsArtifactsInCassandra() {
+ // when
+ boolean notInCass = testSubject.isArtifactInCassandra(ES_ID_NOT_IN_CASS);
+ boolean inCass = testSubject.isArtifactInCassandra(ES_ID);
+
+ // then
+ assertFalse(notInCass);
+ assertTrue(inCass);
+ }
+
+ @Test
+ public void testAddRelevantArtifacts() {
+ // given
+ Map<String, ArtifactDataDefinition> artifactsMap = new HashMap<>();
+ artifactsMap.put(ES_ID_NOT_IN_CASS, artifactDataDefinitionNotInCassandra);
+ artifactsMap.put(ES_ID, artifactDataDefinition);
+
+ // when
+ List<ArtifactDataDefinition> result = testSubject.addRelevantArtifacts(artifactsMap);
+
+ // then
+ result.forEach(Assert::assertNotNull);
+ }
+
+ @Test
+ public void testAddRelevantArtifactsWithNullEsId() {
+ // given
+ Map<String, ArtifactDataDefinition> artifactsMap = new HashMap<>();
+ artifactsMap.put("", artifactDataDefinitionDummy);
+
+ // when
+ List<ArtifactDataDefinition> result = testSubject.addRelevantArtifacts(artifactsMap);
+
+ // then
+ assertEquals(0, result.size());
+ }
+
+ @Test
+ public void testValidateTopologyTemplateArtifacts() {
+ // given
+ 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(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(topologyTemplateOperation.getToscaElement(eq(vertex.getUniqueId()), any()))
+ .thenReturn(Either.left(topologyTemplate));
+
+ // when
+ ArtifactsVertexResult result =
+ testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME);
+
+ // then
+ assertTrue(result.getStatus());
+ assertEquals(0, result.notFoundArtifacts.size());
+ }
+
+ @Test
+ public void testValidateTopologyTemplateArtifactsNotFoundToscaElement() {
+ // given
+ when(topologyTemplateOperation.getToscaElement(eq(vertex.getUniqueId()), any()))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+
+ // when
+ ArtifactsVertexResult result =
+ testSubject.validateTopologyTemplateArtifacts(vertex, TASK_NAME);
- private ArtifactValidationUtils createTestSubject() {
- ArtifactCassandraDao artifactCassandraDao = mock(ArtifactCassandraDao.class);
- TopologyTemplateOperation topologyTemplateOperation = mock(TopologyTemplateOperation.class);
- return new ArtifactValidationUtils(artifactCassandraDao, topologyTemplateOperation);
- }
-
- @Test(expected=NullPointerException.class)
- public void testValidateArtifactsAreInCassandra() throws Exception {
- ArtifactValidationUtils testSubject;
- GraphVertex vertex = null;
- String taskName = "";
- List<ArtifactDataDefinition> artifacts = null;
- ArtifactsVertexResult result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.validateArtifactsAreInCassandra(vertex, taskName, artifacts);
- }
-
- @Test(expected=NullPointerException.class)
- public void testIsArtifcatInCassandra() throws Exception {
- ArtifactValidationUtils testSubject;
- String uniueId = "";
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isArtifcatInCassandra(uniueId);
- }
-
- @Test
- public void testAddRelevantArtifacts() throws Exception {
- ArtifactValidationUtils testSubject;
- Map<String, ArtifactDataDefinition> artifactsMap = null;
- List<ArtifactDataDefinition> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addRelevantArtifacts(artifactsMap);
- }
-
- @Test(expected=NullPointerException.class)
- public void testValidateTopologyTemplateArtifacts() throws Exception {
- ArtifactValidationUtils testSubject;
- GraphVertex vertex = null;
- String taskName = "";
- ArtifactsVertexResult result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.validateTopologyTemplateArtifacts(vertex, taskName);
- }
+ // then
+ assertFalse(result.getStatus());
+ }
}
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 7f67334da6..1da3d6d551 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
@@ -20,11 +20,16 @@
package org.openecomp.sdc.asdctool.impl.validator.utils;
+import java.util.Set;
+
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
-import java.util.Set;
-
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ReportManager.class})
public class ReportManagerTest {
@Test