summaryrefslogtreecommitdiffstats
path: root/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java
diff options
context:
space:
mode:
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java')
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java103
1 files changed, 61 insertions, 42 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java
index 0d06d8ef96..8eb2122b3d 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/DeploymentViewVerificator.java
@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.io.FileUtils;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
@@ -46,15 +47,12 @@ import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupsTopologyTemplateDef
import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
import org.openqa.selenium.WebElement;
-import org.testng.SkipException;
-import org.testng.TestException;
-import org.testng.TestNGException;
import com.aventstack.extentreports.Status;
public class DeploymentViewVerificator {
- private static String[] currentProperties = {"isBase",
+ private static List<String> currentPropertiesForUI = Arrays.asList("isBase",
"vf_module_label",
"vf_module_description",
"min_vf_module_instances",
@@ -63,7 +61,28 @@ public class DeploymentViewVerificator {
"vf_module_type",
"volume_group",
"vfc_list",
- "availability_zone_count"};
+ "availability_zone_count");
+
+ private static List<String> currentPropertiesWithoutIsBaseForFile = Arrays.asList("vf_module_label",
+ "vf_module_description",
+ "min_vf_module_instances",
+ "max_vf_module_instances",
+ "initial_count",
+ "vf_module_type",
+ "volume_group",
+ "vfc_list",
+ "availability_zone_count");
+
+ public static List<String> getCurrentProperties() {
+ return currentPropertiesForUI;
+ }
+
+ public static List<String> getCurrentPropertiesWithoutIsBase() {
+ return currentPropertiesWithoutIsBaseForFile;
+ }
+
+
+ public static final String partToReplace = "_group";
private static Map<String, HashMap<String, List<String>>> deploymentViewData = new HashMap<String, HashMap<String, List<String>>>(){
{
@@ -72,7 +91,7 @@ public class DeploymentViewVerificator {
segw_heat_c3_base = new HashMap<String, List<String>>();
segw_heat_c3_base.put("members", Arrays.asList("segw_internet_security_group", "segw_security_group", "int_layer2vlan_net"));
segw_heat_c3_base.put("artifacts", Arrays.asList("segw_heat_c3_base.yml", "segw_heat_c3_base.env"));
- segw_heat_c3_base.put("properties", Arrays.asList(currentProperties));
+ segw_heat_c3_base.put("properties", currentPropertiesForUI);
put("segw_heat_c3_base", segw_heat_c3_base);
segw_heat_c3_VMs1 = new HashMap<String, List<String>>();
segw_heat_c3_VMs1.put("members", Arrays.asList("segw_oam_protected_0_port",
@@ -88,41 +107,42 @@ public class DeploymentViewVerificator {
"fw_oam_0",
"fw_gn_int_layer2vlan_1_port"));
segw_heat_c3_VMs1.put("artifacts", Arrays.asList("segw_heat_c3_VMs1.yml", "segw_heat_c3_VMs1.env"));
- segw_heat_c3_VMs1.put("properties", Arrays.asList(currentProperties));
+ segw_heat_c3_VMs1.put("properties", currentPropertiesForUI);
put("segw_heat_c3_VMs1", segw_heat_c3_VMs1);
}
};
- private static Map<String, HashMap<String, List<String>>> deploymentViewDataMixedArtefects = new HashMap<String, HashMap<String, List<String>>>(){
+ private static Map<String, HashMap<String, List<String>>> deploymentViewDataMixedArtifacts = new HashMap<String, HashMap<String, List<String>>>(){
{
HashMap<String, List<String>> module_1_ldsa, module_2_ldsa, base_ldsa;
module_1_ldsa = new HashMap<String, List<String>>();
- module_1_ldsa.put("members", new ArrayList(Arrays.asList("ltm_oam_protected_0_port", "ltm_dmz_direct_0_port", "ltm_server_0")));
- module_1_ldsa.put("artifacts", new ArrayList(Arrays.asList("module_1_ldsa.yaml", "module_1_ldsa.env", "base_ldsa.33.yaml", "module_1_ldsa.11.yaml")));
- module_1_ldsa.put("properties", new ArrayList(Arrays.asList(currentProperties)));
+ module_1_ldsa.put("members", Stream.of("ltm_oam_protected_0_port", "ltm_dmz_direct_0_port", "ltm_server_0").collect(Collectors.toList()));
+ module_1_ldsa.put("artifacts", Stream.of("module_1_ldsa.yaml", "module_1_ldsa.env", "base_ldsa.33.yaml", "module_1_ldsa.11.yaml").collect(Collectors.toList()));
+ module_1_ldsa.put("properties", currentPropertiesForUI);
put("module_1_ldsa", module_1_ldsa);
module_2_ldsa = new HashMap<String, List<String>>();
- module_2_ldsa.put("members", new ArrayList(Arrays.asList("ltm_server_0")));
- module_2_ldsa.put("artifacts", new ArrayList(Arrays.asList("module_2_ldsa.yaml", "module_2_ldsa.env", "base_ldsa.3.yaml", "module_2_ldsa.22.yaml")));
- module_2_ldsa.put("properties", new ArrayList(Arrays.asList(currentProperties)));
+ module_2_ldsa.put("members", Stream.of("ltm_server_0").collect(Collectors.toList()));
+ module_2_ldsa.put("artifacts", Stream.of("module_2_ldsa.yaml", "module_2_ldsa.env", "base_ldsa.3.yaml", "module_2_ldsa.22.yaml").collect(Collectors.toList()));
+ module_2_ldsa.put("properties", currentPropertiesForUI);
put("module_2_ldsa", module_2_ldsa);
base_ldsa = new HashMap<String, List<String>>();
- base_ldsa.put("members", new ArrayList(Arrays.asList("ldsa_sec_grp_1")));
- base_ldsa.put("artifacts", new ArrayList(Arrays.asList("base_ldsa.yaml", "module_2_ldsa.2.yaml", "module_1_ldsa.1.yaml")));
- base_ldsa.put("properties", new ArrayList(Arrays.asList(currentProperties)));
+ base_ldsa.put("members", Stream.of("ldsa_sec_grp_1").collect(Collectors.toList()));
+ base_ldsa.put("artifacts", Stream.of("base_ldsa.yaml", "module_2_ldsa.2.yaml", "module_1_ldsa.1.yaml").collect(Collectors.toList()));
+ base_ldsa.put("properties", currentPropertiesForUI);
put("base_ldsa", base_ldsa);
}
};
+
private Map<String, HashMap<String, List<String>>> deploymentViewDataFromFile;
- public DeploymentViewVerificator(String pathToCSAR) throws Exception {
- deploymentViewDataFromFile = getDeploymentViewDataFromCSAR(pathToCSAR);
+ public DeploymentViewVerificator(String pathToCsar) throws Exception {
+ deploymentViewDataFromFile = buildDeploymentViewDataFromCSAR(pathToCsar);
}
public DeploymentViewVerificator() throws Exception {
- deploymentViewDataFromFile = deploymentViewDataMixedArtefects;
+ deploymentViewDataFromFile = deploymentViewDataMixedArtifacts;
}
@@ -141,7 +161,7 @@ public class DeploymentViewVerificator {
File imageFilePath = GeneralUIUtils.takeScreenshot(moduleName + UUID.randomUUID(), SetupCDTest.getScreenshotFolder(), null);
final String absolutePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFilePath.toURI()).getPath();
- SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating group %s, should be %s members, %s artefacts " + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath),
+ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating group %s, should be %s members, %s artifacts " + SetupCDTest.getExtendTest().addScreenCaptureFromPath(absolutePath),
moduleName, moduleProperties.get("members").size(), moduleProperties.get("artifacts").size()));
assertTrue(moduleProperties.get("artifacts").size() == artifacts.size(), "Artifacts amount not as expected, expected " + moduleProperties.get("artifacts").size());
@@ -183,52 +203,47 @@ public class DeploymentViewVerificator {
return getDeploymentViewDataFromFile();
}
- public static Map<String, HashMap<String, List<String>>> buildDeploymentViewDataFromCSAR(String pathToCSAR, File mainServiceTemplate) throws Exception{
- ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaYamlToJavaObject(mainServiceTemplate);
+ public static Map<String, HashMap<String, List<String>>> buildDeploymentViewDataFromCSAR(String pathToCSAR) throws Exception{
+ ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(new File(pathToCSAR));
Map<String, HashMap<String, List<String>>> deploymentViewDataFromFile = new HashMap<String, HashMap<String, List<String>>>();
Map<String, ToscaGroupsTopologyTemplateDefinition> groups = toscaDefinition.getTopology_template().getGroups();
List<String> keyList = groups.keySet().stream().collect(Collectors.toList());
- HashMap<String, List<String>> groupsToArtefacts = getDeploymentArtefactsMapedToGroupsFromCSAR(pathToCSAR);
+ HashMap<String, List<String>> groupsToArtifacts = getDeploymentArtifactsMappedToGroupsFromCSAR(pathToCSAR);
for(String groupKey: keyList){
HashMap<String, List<String>> tempGroupMap = new HashMap<String, List<String>>();
- tempGroupMap.put("artifacts", groupsToArtefacts.get(groupKey));
+ tempGroupMap.put("artifacts", groupsToArtifacts.get(convertAmdocsCsarGroupNameToSdcCsarGroupName(groupKey)));
if (groups.get(groupKey).getMembers() == null){
tempGroupMap.put("members", Arrays.asList());
} else {
tempGroupMap.put("members", groups.get(groupKey).getMembers());
}
- tempGroupMap.put("properties", Arrays.asList(currentProperties));
- deploymentViewDataFromFile.put(groupKey, tempGroupMap);
+ tempGroupMap.put("properties", currentPropertiesForUI);
+ deploymentViewDataFromFile.put(convertAmdocsCsarGroupNameToSdcCsarGroupName(groupKey), tempGroupMap);
}
return deploymentViewDataFromFile;
}
- public static HashMap<String, List<String>> getDeploymentArtefactsMapedToGroupsFromCSAR(String pathToFile) throws Exception {
+ public static HashMap<String, List<String>> getDeploymentArtifactsMappedToGroupsFromCSAR(String pathToFile) throws Exception {
Map<String, Object> combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(pathToFile);
LinkedList<HeatMetaFirstLevelDefinition> deploymentArtifacts = ((LinkedList<HeatMetaFirstLevelDefinition>) combinedMap.get("Deployment"));
+
HashMap<String, List<String>> tempGroupMap = new HashMap<String, List<String>>();
for(HeatMetaFirstLevelDefinition deploymentArtifact: deploymentArtifacts) {
String groupName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().indexOf("."));
- if(deploymentArtifact.getType().equals("HEAT")) {
- tempGroupMap.put(groupName, new ArrayList(Arrays.asList(deploymentArtifact.getFileName().trim())));
+ if(deploymentArtifact.getType().equals("HEAT") || deploymentArtifact.getType().equals("HEAT_NET") || deploymentArtifact.getType().equals("HEAT_VOL")) {
+ List<String> list = new ArrayList<>();
+ list.add(deploymentArtifact.getFileName().trim());
+ tempGroupMap.put(groupName, list);
} else {
// update current key
- tempGroupMap.get(groupName).add(deploymentArtifact.getFileName().trim());
- tempGroupMap.put(groupName, tempGroupMap.get(groupName));
+ List<String> list = tempGroupMap.get(groupName);
+ list.add(deploymentArtifact.getFileName().trim());
+ tempGroupMap.put(groupName, list);
}
}
return tempGroupMap;
}
- public static Map<String, HashMap<String, List<String>>> getDeploymentViewDataFromCSAR(String pathToCsar) throws Exception {
- String outputFolder = unzipCsarFile(pathToCsar);
-
- File pathToMainServiceTemplate = new File(outputFolder + File.separator + "Definitions" + File.separator + "MainServiceTemplate.yaml");
- Map<String, HashMap<String, List<String>>> deploymentViewData = buildDeploymentViewDataFromCSAR(pathToCsar, pathToMainServiceTemplate);
- cleanFolders(outputFolder);
-
- return deploymentViewData;
- }
public static void cleanFolders(String outputFolder) throws IOException {
System.gc();
@@ -240,7 +255,7 @@ public class DeploymentViewVerificator {
File csarFile = new File(pathToCsar);
- File dir = new File(csarFile.getParent() + File.separator + "output"+UUID.randomUUID() + File.separator + UUID.randomUUID());
+ File dir = new File(csarFile.getParent() + File.separator + "output"+ UUID.randomUUID() + File.separator + UUID.randomUUID());
if(!dir.exists()) {
dir.mkdirs();
}
@@ -322,6 +337,10 @@ public class DeploymentViewVerificator {
}
}
+ public static String convertAmdocsCsarGroupNameToSdcCsarGroupName(String originalString){
+ return originalString.replace(partToReplace, "");
+ }
+