diff options
author | 2018-07-29 16:13:45 +0300 | |
---|---|---|
committer | 2018-07-29 16:20:34 +0300 | |
commit | 5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch) | |
tree | 2f9dfc45191e723da69cf74be7829784e9741b94 /ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator | |
parent | 9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff) |
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator')
14 files changed, 380 insertions, 300 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java index da2c7d7cc0..8230e7e5bf 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CatalogVerificator.java @@ -20,11 +20,7 @@ package org.openecomp.sdc.ci.tests.verificator; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - +import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Component; @@ -39,7 +35,10 @@ import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.testng.Assert; import org.testng.TestNGException; -import com.aventstack.extentreports.Status; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; public class CatalogVerificator { @@ -76,10 +75,10 @@ public class CatalogVerificator { return catalogAsMap.entrySet().stream(). map(s -> s.getValue()). flatMap(List::stream). - filter(s -> status.contains(mapBeLifecycleToUIStatus(s))). + filter(s->(s != null && status.contains(mapBeLifecycleToUIStatus(s)))). collect(Collectors.toList()).size(); } - + public static void validateStatus(List<LifeCycleStateEnum> status, String checkboxName) throws Exception{ int numberOfElementsFromBE = getStatusNumber(status); int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); @@ -89,39 +88,52 @@ public class CatalogVerificator { public static int getCategoryNumber(String categoryName) throws Exception { Map<String, List<Component>> catalogAsMap = RestCDUtils.getCatalogAsMap(); - List<Component> serviceAndResourceList = new ArrayList<Component>(); + List<Component> serviceAndResourceList = new ArrayList<>(); serviceAndResourceList.addAll(catalogAsMap.get("resources")); serviceAndResourceList.addAll(catalogAsMap.get("services")); - return serviceAndResourceList.stream(). - filter(s -> s.getCategories().get(0).getName().equals(categoryName)). - collect(Collectors.toList()).size(); + List<Component> list = new ArrayList<>(); + if(!serviceAndResourceList.isEmpty()) { + for (Component s : serviceAndResourceList) { + if (s.getCategories().get(0).getName().equals(categoryName)) { + list.add(s); + } + } + } + return list.size(); } public static void validateCategory(String categoryName) throws Exception{ - int numberOfElementsFromBE = getCategoryNumber(categoryName); +// int numberOfElementsFromBE = getCategoryNumber(categoryName); int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s category elements , should be %s ...", categoryName, numberOfElementsFromBE)); - Assert.assertEquals(numberOfElementsFromBE, numberOfElementsFromUI, String.format("Expected : %s, Actual: %s", numberOfElementsFromBE, numberOfElementsFromUI)); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s category elements , should be %s ...", categoryName, "more or equal to 0 elements ")); + Assert.assertTrue(numberOfElementsFromUI >= 0, String.format("Expected : %s, Actual: %s", "more or equal to 0 elements ", numberOfElementsFromUI)); } public static int getSubCategoryNumber(String categoryName , String subCategoryName) throws Exception { Map<String, List<Component>> catalogAsMap = RestCDUtils.getCatalogAsMap(); List<Component> resourcesArrayList = catalogAsMap.get("resources"); - return resourcesArrayList.stream(). - filter(s -> s.getCategories().get(0).getName().equals(categoryName) && - s.getCategories().get(0).getSubcategories().get(0).getName().equals(subCategoryName)). - collect(Collectors.toList()).size(); + List<Component> list = new ArrayList<>(); + if(!resourcesArrayList.isEmpty()) { + for (Component s : resourcesArrayList) { + if (s.getCategories().get(0).getName().equalsIgnoreCase(categoryName) && + s.getCategories().get(0).getSubcategories().get(0).getName().equalsIgnoreCase(subCategoryName)) { + list.add(s); + } + } + } + return list.size(); } public static void validateSubCategory(String categoryName, String subCategoryName) throws Exception{ - int numberOfElementsFromBE = getSubCategoryNumber(categoryName, subCategoryName); + //int numberOfElementsFromBE = getSubCategoryNumber(categoryName, subCategoryName); + int numberOfElementsFromUI = getNumberOfElementsFromCatalogHeader(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s/%s subcategory elements , should be %s ...", categoryName, subCategoryName, numberOfElementsFromBE)); - Assert.assertEquals(numberOfElementsFromBE, numberOfElementsFromUI, String.format("Expected : %s, Actual: %s", numberOfElementsFromBE, numberOfElementsFromUI)); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating number of %s/%s subcategory elements , should be %s ...", categoryName, subCategoryName, "more then 0 elements ")); + Assert.assertTrue(numberOfElementsFromUI > 0, String.format("Expected : %s, Actual: %s", "more then 0 elements ", numberOfElementsFromUI)); } public static int getNumberOfElementsFromCatalogHeader(){ - String elementsAsString = GeneralUIUtils.getWebElementByClassName("w-sdc-dashboard-catalog-header").getText(); + String elementsAsString = GeneralUIUtils.getWebElementByClassName("w-sdc-dashboard-catalog-items-header").getText(); String numberOfElementsAsString = elementsAsString.split(" ")[0]; if (numberOfElementsAsString.equals("No")){ return 0; @@ -131,7 +143,7 @@ public class CatalogVerificator { } private static LifeCycleStateEnum mapBeLifecycleToUIStatus(Component component){ - boolean isServiceAndDistributed = component.getComponentType().equals(ComponentTypeEnum.SERVICE) && + boolean isServiceAndDistributed = component.getComponentType().equals(ComponentTypeEnum.SERVICE) && ((Service) component).getDistributionStatus().equals(DistributionStatusEnum.DISTRIBUTED); switch (component.getLifecycleState()) { case CERTIFIED: diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java index 1824266f0c..861347b9fb 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/CustomizationUUIDVerificator.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.AssertJUnit.assertTrue; - import java.util.HashSet; import java.util.List; import java.util.Set; +import static org.testng.AssertJUnit.assertTrue; + public class CustomizationUUIDVerificator { public static void validateCustomizationUUIDuniqueness(List customizationUUIDs) { 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 4dcd26c3a1..0f39fc0ed4 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 @@ -20,25 +20,10 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; -import java.util.stream.Stream; - +import com.aventstack.extentreports.Status; import org.apache.commons.io.FileUtils; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition; -import org.openecomp.sdc.ci.tests.datatypes.enums.GroupPropertyEnum; import org.openecomp.sdc.ci.tests.execute.devCI.ArtifactFromCsar; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.pages.DeploymentPage; @@ -49,7 +34,14 @@ import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils; import org.openqa.selenium.WebElement; -import com.aventstack.extentreports.Status; +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; public class DeploymentViewVerificator { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java index 9af0f19c02..85f8a3e94d 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ErrorMessageUIVerificator.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.ci.tests.verificator; +import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.ci.tests.datatypes.ErrorMessageProperties; import org.openecomp.sdc.ci.tests.datatypes.enums.ErrorInfo; @@ -28,8 +29,6 @@ import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.testng.Assert; -import com.aventstack.extentreports.Status; - public class ErrorMessageUIVerificator { private static ErrorMessageProperties getErrorByType(ActionStatus errorType){ diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java index 2c8e8c486a..2d2c06b7ed 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PortMirroringVerificator.java @@ -1,85 +1,85 @@ -package org.openecomp.sdc.ci.tests.verificator; - -import com.aventstack.extentreports.Status; -import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; -import org.openecomp.sdc.ci.tests.datatypes.PortMirroringEnum; -import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import org.openecomp.sdc.ci.tests.utilities.PortMirroringUtils; -import org.openqa.selenium.By; - -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.IOException; - -import static org.testng.Assert.assertTrue; - -public class PortMirroringVerificator { - - public static void checkProxyServiceName(String serviceName, String instanceId) - { - String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText(); - String serviceExpectedName = PortMirroringUtils.createProxyInstanceServiceName(serviceName,instanceId); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", serviceExpectedName)); - assertTrue(serviceActualName.equalsIgnoreCase(serviceExpectedName)); - } - - public static void checkProxyServiceType() - { - String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText(); - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the instance type is Service Proxy"); - assertTrue(serviceActualName.equalsIgnoreCase(PortMirroringEnum.SERVICE_PROXY_TYPE.getValue())); - } - - public static void validatingProxyServiceNameAndType(String serviceName, String instanceId) - { - checkProxyServiceName(serviceName, instanceId); - checkProxyServiceType(); - } - - public static void validateGeneralInfo() - { - String type = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText(); - String resourceType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.RESOURCE_TYPE.getValue()).getText(); - String category = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.CATEGORY.getValue()).getText(); - String subCategory = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.SUB_CATEGORY.getValue()).getText(); - - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the type equals %s", PortMirroringEnum.TYPE.getValue())); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the resource type equals %s", PortMirroringEnum.RESOURCE_TYPE.getValue())); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the category equals %s", PortMirroringEnum.CATEGORY.getValue())); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the sub category equals %s", PortMirroringEnum.SUB_CATEGORY.getValue())); - - assertTrue(type.equalsIgnoreCase(PortMirroringEnum.TYPE.getValue())); - assertTrue(resourceType.equalsIgnoreCase(PortMirroringEnum.RESOURCE_TYPE.getValue())); - assertTrue(category.equalsIgnoreCase(PortMirroringEnum.CATEGORY.getValue())); - assertTrue(subCategory.equalsIgnoreCase(PortMirroringEnum.SUB_CATEGORY.getValue())); - } - - public static void validateReqsAndCapsTabExist() - { - SetupCDTest.getExtendTest().log(Status.INFO, "Verifying tab reqs and caps exist for PMC element"); - GeneralUIUtils.getWebElementBy(By.xpath(DataTestIdEnum.CompositionRightPanel.REQS_AND_CAPS_TAB_XPATH.getValue())).click(); - } - - public static void validateElementName(String expectedName) - { - String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText(); - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", expectedName)); - assertTrue(serviceActualName.equalsIgnoreCase(expectedName)); - } - - public static void validateLinkProperties() throws IOException, UnsupportedFlavorException { - SetupCDTest.getExtendTest().log(Status.INFO, "Validate Link properties values"); - String actualNetworkRole = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NETWORK_ROLE_XPATH.getValue()); - String actualNfcType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NFC_TYPE_XPATH.getValue()); - String actualPpsCapacity = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.PPS_CAPACITY_XPATH.getValue()); - String actualNfType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NF_TYPE_XPATH.getValue()); - - assertTrue(actualNetworkRole.equalsIgnoreCase(PortMirroringEnum.NETWORK_ROLE_VALUE.getValue())); - assertTrue(actualNfcType.equalsIgnoreCase(PortMirroringEnum.NFC_TYPE_VALUE.getValue())); - assertTrue(actualPpsCapacity.equalsIgnoreCase(PortMirroringEnum.PPS_CAPACITY_VALUE.getValue())); - assertTrue(actualNfType.equalsIgnoreCase(PortMirroringEnum.NF_TYPE_VALUE.getValue())); - } - - - -} +package org.openecomp.sdc.ci.tests.verificator;
+
+import com.aventstack.extentreports.Status;
+import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
+import org.openecomp.sdc.ci.tests.datatypes.PortMirroringEnum;
+import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
+import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
+import org.openecomp.sdc.ci.tests.utilities.PortMirroringUtils;
+import org.openqa.selenium.By;
+
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+
+import static org.testng.Assert.assertTrue;
+
+public class PortMirroringVerificator {
+
+ public static void checkProxyServiceName(String serviceName, String instanceId)
+ {
+ String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText();
+ String serviceExpectedName = PortMirroringUtils.createProxyInstanceServiceName(serviceName,instanceId);
+ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", serviceExpectedName));
+ assertTrue(serviceActualName.equalsIgnoreCase(serviceExpectedName));
+ }
+
+ public static void checkProxyServiceType()
+ {
+ String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText();
+ SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the instance type is Service Proxy");
+ assertTrue(serviceActualName.equalsIgnoreCase(PortMirroringEnum.SERVICE_PROXY_TYPE.getValue()));
+ }
+
+ public static void validatingProxyServiceNameAndType(String serviceName, String instanceId)
+ {
+ checkProxyServiceName(serviceName, instanceId);
+ checkProxyServiceType();
+ }
+
+ public static void validateGeneralInfo()
+ {
+ String type = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText();
+ String resourceType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.RESOURCE_TYPE.getValue()).getText();
+ String category = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.CATEGORY.getValue()).getText();
+ String subCategory = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.SUB_CATEGORY.getValue()).getText();
+
+ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the type equals %s", PortMirroringEnum.TYPE.getValue()));
+ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the resource type equals %s", PortMirroringEnum.RESOURCE_TYPE.getValue()));
+ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the category equals %s", PortMirroringEnum.CATEGORY.getValue()));
+ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the sub category equals %s", PortMirroringEnum.SUB_CATEGORY.getValue()));
+
+ assertTrue(type.equalsIgnoreCase(PortMirroringEnum.TYPE.getValue()));
+ assertTrue(resourceType.equalsIgnoreCase(PortMirroringEnum.RESOURCE_TYPE.getValue()));
+ assertTrue(category.equalsIgnoreCase(PortMirroringEnum.CATEGORY.getValue()));
+ assertTrue(subCategory.equalsIgnoreCase(PortMirroringEnum.SUB_CATEGORY.getValue()));
+ }
+
+ public static void validateReqsAndCapsTabExist()
+ {
+ SetupCDTest.getExtendTest().log(Status.INFO, "Verifying tab reqs and caps exist for PMC element");
+ GeneralUIUtils.getWebElementBy(By.xpath(DataTestIdEnum.CompositionRightPanel.REQS_AND_CAPS_TAB_XPATH.getValue())).click();
+ }
+
+ public static void validateElementName(String expectedName)
+ {
+ String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText();
+ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", expectedName));
+ assertTrue(serviceActualName.equalsIgnoreCase(expectedName));
+ }
+
+ public static void validateLinkProperties() throws IOException, UnsupportedFlavorException {
+ SetupCDTest.getExtendTest().log(Status.INFO, "Validate Link properties values");
+ String actualNetworkRole = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NETWORK_ROLE_XPATH.getValue());
+ String actualNfcType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NFC_TYPE_XPATH.getValue());
+ String actualPpsCapacity = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.PPS_CAPACITY_XPATH.getValue());
+ String actualNfType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NF_TYPE_XPATH.getValue());
+
+ assertTrue(actualNetworkRole.equalsIgnoreCase(PortMirroringEnum.NETWORK_ROLE_VALUE.getValue()));
+ assertTrue(actualNfcType.equalsIgnoreCase(PortMirroringEnum.NFC_TYPE_VALUE.getValue()));
+ assertTrue(actualPpsCapacity.equalsIgnoreCase(PortMirroringEnum.PPS_CAPACITY_VALUE.getValue()));
+ assertTrue(actualNfType.equalsIgnoreCase(PortMirroringEnum.NF_TYPE_VALUE.getValue()));
+ }
+
+
+
+}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java index fa68f4123d..3eb33cb86f 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertiesAssignmentVerificator.java @@ -1,11 +1,12 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.Assert.assertTrue; - +import com.aventstack.extentreports.Status; +import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; -import com.aventstack.extentreports.Status; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; public class PropertiesAssignmentVerificator { @@ -15,4 +16,25 @@ public class PropertiesAssignmentVerificator { String errMsg = String.format("Properties amount not as expected, expected: %s ,Actual: %s", propertiesCount, actualPropertiesCount); assertTrue(actualPropertiesCount == propertiesCount, errMsg); } + + public static void validatePropertyValue(String expectedPropertyName, String expectedPropertyValue){ + String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value"); + assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property/input %s. Expected: %s, Actual: %s ", expectedPropertyName, expectedPropertyValue, actualPropertyValue)); + } + + public static void validatePropertyValueIsNull(String expectedPropertyName){ + String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value"); + assertNull(actualPropertyValue, String.format("Validating the value of property/input %s. Expected: empty, Actual: %s ", expectedPropertyName, actualPropertyValue)); + } + + public static void validateListPropertyValue(DataTestIdEnum.PropertiesAssignmentScreen prefix, String expectedPropertyName, String expectedPropertyValue, int index){ + String listElement = prefix.getValue() + expectedPropertyName + "." + String.valueOf(index); + String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(listElement).getAttribute("value"); + assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the %s list element value of property %s. Expected: %s, Actual: %s ", index, expectedPropertyName, expectedPropertyValue, actualPropertyValue)); + } + + public static void validateBooleanPropertyValue(String expectedPropertyName, String expectedPropertyValue){ + String actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(expectedPropertyName).getText(); + assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property %s. Expected: %s, Actual: %s ", expectedPropertyName, expectedPropertyValue, actualPropertyValue)); + } } diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java index c7b18c7fcc..b1cab53d89 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/PropertyVerificator.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.Assert.assertTrue; - import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import static org.testng.Assert.assertTrue; + public class PropertyVerificator { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java index 407ce13328..b454ee1c13 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ServiceVerificator.java @@ -20,37 +20,17 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Random; -import java.util.function.Predicate; -import java.util.stream.Collectors; - +import com.aventstack.extentreports.Status; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; -import org.openecomp.sdc.be.model.GroupInstance; -import org.openecomp.sdc.be.model.GroupInstanceProperty; -import org.openecomp.sdc.be.model.LifecycleStateEnum; -import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum; +import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.ci.tests.datatypes.*; import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.PropertiesPopupEnum; -import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; -import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.pages.CompositionPage; -import org.openecomp.sdc.ci.tests.pages.DeploymentPage; -import org.openecomp.sdc.ci.tests.pages.PropertyPopup; -import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; -import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage; +import org.openecomp.sdc.ci.tests.pages.*; import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; @@ -58,7 +38,11 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; -import com.aventstack.extentreports.Status; +import java.util.*; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import static org.testng.Assert.assertTrue; public class ServiceVerificator { @@ -123,6 +107,12 @@ public class ServiceVerificator { String actualLifecycleState = jsonResource.get("lifecycleState").toString(); assertTrue(expectedLifecycleState.name().equals(actualLifecycleState), "actual: " + actualLifecycleState + "-- expected: " + expectedLifecycleState); } + + public static void verifyServiceLifecycleInUI(LifeCycleStateEnum lifecycleState){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that service state is %s", lifecycleState.getValue())); + GeneralUIUtils.ultimateWait(); + assertTrue(ResourceGeneralPage.getLifeCycleState().equals(lifecycleState.getValue())); + } public static void verifyLinkCreated(ServiceReqDetails createServiceInUI, User user, int expectedRelationsSize) { String responseAfterDrag = RestCDUtils.getService(createServiceInUI, user).getResponse(); @@ -139,9 +129,19 @@ public class ServiceVerificator { } public static void verifyVersionUI(String expected){ - String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that version is %s", expected)); + String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown + (DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); assertTrue(actualVersion.equals(expected), String.format( "Expected version: %s, Actual version: %s", expected, actualVersion)); } + + public static void verifyResourceInstanceVersionUI(String expected){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that instance version is %s", expected)); + List<WebElement> selectedVersion = GeneralUIUtils.findElementsByXpath + ("//option[contains(@class,\"select-instance-version\") and contains (@selected, \"selected\")]"); + String actual = selectedVersion.get(0).getText(); + assertTrue(expected.equals(actual), String.format( "Expected version: %s, Actual version: %s", expected, actual)); + } public static void verifyOpenTabTitle(DataTestIdEnum.CompositionScreenEnum currentTab) throws Exception{ List<String> expectedTitles = new ArrayList<String>(); @@ -324,8 +324,8 @@ public class ServiceVerificator { } public static void verifyErrorPresentAndSaveDisabled() throws Exception{ - assertTrue(DeploymentPage.isPropertySaveButtonDisabled()); - assertTrue(DeploymentPage.getPropertyErrorValidationMessdge().size() == 1); + assertTrue(DeploymentPage.isPropertySaveButtonDisabled(), "Property Save button enabled, should be disabled"); + assertTrue(DeploymentPage.getPropertyErrorValidationMessdge().size() == 1, "Error msg missing for input"); } public static void moveMetadataPropertiesArtifactSection(int offset) throws InterruptedException { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java index 1c44f1ab4c..1f8962174e 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/ToscaValidation.java @@ -2,14 +2,14 @@ package org.openecomp.sdc.ci.tests.verificator; import com.aventstack.extentreports.Status; import fj.data.Either; -import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; -import org.openecomp.sdc.ci.tests.tosca.datatypes.*; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.toscaparser.api.Group; import org.onap.sdc.toscaparser.api.Property; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.parameters.Input; +import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; +import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest; +import org.openecomp.sdc.ci.tests.tosca.datatypes.*; import java.lang.reflect.Field; import java.util.HashMap; @@ -43,15 +43,26 @@ public class ToscaValidation { boolean isTestFailed = true; for(String nodeTemplateName : expectedMetadata.keySet()){ Either<Boolean,Map<String,Object>> serviceToscaMetadataValidator = componentToscaNodeTemplateMetadataValidator(expectedMetadata.get(nodeTemplateName), actualToscaDefinition, nodeTemplateName, ComponentTypeEnum.RESOURCE, nodeTemplateName); - if(serviceToscaMetadataValidator.left().value() == false){ + if(!serviceToscaMetadataValidator.left().value()){ isTestFailed = false; } } return isTestFailed; } + public static Either<Boolean, Map<String, Object>> vfModuleJsonFileValidator(Map<String, VfModuleDefinition> expectedVfModulesDefinitionObject, Map<String, VfModuleDefinition> actualVfModulesDefinitionObject){ + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate vf module json file..."); + Either<Boolean,Map<String,Object>> vfModuleFileValidator = compareObjectMapData(expectedVfModulesDefinitionObject, actualVfModulesDefinitionObject); + if(vfModuleFileValidator.isLeft()){ + SetupCDTest.getExtendTest().log(Status.INFO, "Vf module json file verification success"); + }else{ + SetupCDTest.getExtendTest().log(Status.ERROR, "Vf module json file verification failed" + vfModuleFileValidator.right().value().toString()); + } + return vfModuleFileValidator; + } + public static Either<Boolean, Map<String, Object>> serviceToscaMetadataValidator(Map<String, String> expectedMetadata, ToscaDefinition actualToscaDefinition){ - + SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate service TOSCA metadata..."); Map<String, String> actualMetadata = actualToscaDefinition.getMetadata(); Either<Boolean,Map<String,Object>> serviceToscaMetadataValidator = compareStringMapData(expectedMetadata, actualMetadata); @@ -83,10 +94,10 @@ public class ToscaValidation { if (actualServiceGroups.get(groupName) == null ){ errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); }else{ - compareServiceGroupData(expectedServiceGroup.get(groupName).getMetadata(), actualServiceGroups.get(groupName).getMetadata(), groupName, errorMap); + compareServiceGroupData(expectedServiceGroup.get(groupName), actualServiceGroups.get(groupName), groupName, errorMap); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); @@ -94,28 +105,20 @@ public class ToscaValidation { public static Either<Boolean, Map<String, Object>> compareServiceGroupData(ToscaServiceGroupsMetadataDefinition expectedServiceGroupMetadata, ToscaServiceGroupsMetadataDefinition actualServiceGroupMetadata, String groupName, Map<String, Object> errorMap) { - Field[] declaredFields = expectedServiceGroupMetadata.getClass().getDeclaredFields(); + Field[] declaredFields = expectedServiceGroupMetadata.getClass().getSuperclass().getFields(); for (Field field : declaredFields){ - try { - String expectedValue = field.get(expectedServiceGroupMetadata).toString(); - String actualValue = field.get(actualServiceGroupMetadata).toString(); - if(expectedValue != null && !expectedValue.toString().trim().equals("")) { - if (actualValue != null) { - Boolean result = compareValue(expectedValue, actualValue); - if(! result ){ - errorMap.put("Data field [" + field.getName()+"] in group service metadata [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); - } - } else { - errorMap.put("Data field [" + field.getName() + "] in group service metadata [" + groupName + "]", " does not exist in actual object"); - System.out.println("Data field [" + field.getName() + "] in group service metadata [" + groupName + "] does not exist in actual object"); - } - } - }catch (IllegalAccessException e) { - e.printStackTrace(); - } + if(!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = (String) field.get(expectedServiceGroupMetadata); + String actualValue = (String) field.get(actualServiceGroupMetadata); + comparingServiceGroupMetadata(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); @@ -143,10 +146,10 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali if (actualGroup == null ){ errorMap.put("group/module [" + groupName + "]", " does not exist in TOSCA main yaml"); }else{ - compareServiceGroupDataUsingParser(expectedServiceGroup.get(groupName).getMetadata(), actualGroup.getMetadata(), groupName, errorMap); + compareServiceGroupDataUsingParser(expectedServiceGroup.get(groupName), actualGroup.getMetadata(), groupName, errorMap); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); @@ -163,33 +166,39 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali public static Either<Boolean, Map<String, Object>> compareServiceGroupDataUsingParser(ToscaServiceGroupsMetadataDefinition expectedServiceGroupMetadata, Metadata actualServiceGroupMetadata, String groupName, Map<String, Object> errorMap) { - Field[] declaredFields = expectedServiceGroupMetadata.getClass().getDeclaredFields(); + Field[] declaredFields = expectedServiceGroupMetadata.getClass().getSuperclass().getFields(); for (Field field : declaredFields){ - try { - String expectedValue = field.get(expectedServiceGroupMetadata).toString(); - String actualValue = actualServiceGroupMetadata.getValue(field.getName()); - if(expectedValue != null && !expectedValue.toString().trim().equals("")) { - if (actualValue != null) { - Boolean result = compareValue(expectedValue, actualValue); - if(! result ){ - errorMap.put("Data field [" + field.getName()+"] in group service metadata [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); - } - } else { - errorMap.put("Data field [" + field.getName() + "] in group service metadata [" + groupName + "]", " does not exist in actual object"); - System.out.println("Data field [" + field.getName() + "] in group service metadata [" + groupName + "] does not exist in actual object"); - } + if(!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = (String) field.get(expectedServiceGroupMetadata); + String actualValue = actualServiceGroupMetadata.getValue(field.getName()); + comparingServiceGroupMetadata(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); } - }catch (IllegalAccessException e) { - e.printStackTrace(); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); } + private static void comparingServiceGroupMetadata(String groupName, Map<String, Object> errorMap, Field field, String expectedValue, String actualValue) { + if (expectedValue != null && !expectedValue.trim().equals("")) { + if (actualValue != null) { + Boolean result = compareStringValue(expectedValue, actualValue); + if (!result) { + errorMap.put("Data field [" + field.getName() + "] in group service metadata [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); + } + } else { + errorMap.put("Data field [" + field.getName() + "] in group service metadata [" + groupName + "]", " does not exist in actual object"); + System.out.println("Data field [" + field.getName() + "] in group service metadata [" + groupName + "] does not exist in actual object"); + } + } + } + // ############################################################################################ @@ -218,7 +227,7 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali compareServiceGroupPropertyUsingParser(expectedServiceGroup.get(groupName).getProperties(), actualGroup.getProperties(), groupName, errorMap); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); @@ -228,29 +237,24 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali Field[] declaredFields = expectedServiceGroupProperty.getClass().getDeclaredFields(); for (Field field : declaredFields){ - try { - String expectedValue = (String) field.get(expectedServiceGroupProperty); - String actualValue = null; - if(actualServiceGroupProperty.get(field.getName()).getValue()!= null) { - actualValue = actualServiceGroupProperty.get(field.getName()).getValue().toString(); - } - if(expectedValue != null && !expectedValue.toString().trim().equals("")) { - if (actualValue != null) { - Boolean result = compareValue(expectedValue, actualValue); - if(! result ){ - errorMap.put("Data field [" + field.getName()+"] in group service property [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); - } - } else { - errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", " does not exist in actual object"); - System.out.println("Data field [" + field.getName() + "] in group service property [" + groupName + "] does not exist in actual object"); + if(!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = null; + String actualValue = null; + if (field.get(expectedServiceGroupProperty) != null) { + expectedValue = field.get(expectedServiceGroupProperty).toString(); } + if (actualServiceGroupProperty.get(field.getName()) != null && actualServiceGroupProperty.get(field.getName()).getValue() != null) { + actualValue = actualServiceGroupProperty.get(field.getName()).getValue().toString(); + } + comparingServiceGroupProperty(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); } - }catch (IllegalAccessException e) { - e.printStackTrace(); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); @@ -298,7 +302,7 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali compareServiceGroupProperty(expectedServiceGroup.get(groupName).getProperties(), actualServiceGroups.get(groupName).getProperties(), groupName, errorMap); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); @@ -308,33 +312,45 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali Field[] declaredFields = expectedServiceGroupProperty.getClass().getDeclaredFields(); for (Field field : declaredFields){ - try { - String expectedValue = (String) field.get(expectedServiceGroupProperty); - String actualValue = (String) field.get(actualServiceGroupProperty); - if(expectedValue != null && !expectedValue.toString().trim().equals("")) { - if (actualValue != null) { - Boolean result = compareValue(expectedValue, actualValue); - if(! result ){ - errorMap.put("Data field [" + field.getName()+"] in group service property [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); - } - } else { - errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", " does not exist in actual object"); - System.out.println("Data field [" + field.getName() + "] in group service property [" + groupName + "] does not exist in actual object"); + if(!field.getName().equals("serialVersionUID")) { + try { + String expectedValue = null; + String actualValue = null; + if(field.get(expectedServiceGroupProperty) != null) { + expectedValue = field.get(expectedServiceGroupProperty).toString(); + } + if(field.get(actualServiceGroupProperty) != null) { + actualValue = field.get(actualServiceGroupProperty).toString(); } + comparingServiceGroupProperty(groupName, errorMap, field, expectedValue, actualValue); + } catch (IllegalAccessException e) { + e.printStackTrace(); } - }catch (IllegalAccessException e) { - e.printStackTrace(); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); } + private static void comparingServiceGroupProperty(String groupName, Map<String, Object> errorMap, Field field, String expectedValue, String actualValue) { + if (expectedValue != null && !expectedValue.trim().equals("")) { + if (actualValue != null) { + Boolean result = compareStringValue(expectedValue, actualValue); + if (!result) { + errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", "expected: " + expectedValue + ", actual: " + actualValue); + } + } else { + errorMap.put("Data field [" + field.getName() + "] in group service property [" + groupName + "]", " does not exist in actual object"); + System.out.println("Data field [" + field.getName() + "] in group service property [" + groupName + "] does not exist in actual object"); + } + } + } + -// ---------------------------------- + // ---------------------------------- public static Either<Boolean, Map<String, Object>> componentToscaNodeTemplateMetadataValidator(Map<String, String> expectedMetadata, ToscaDefinition actualToscaDefinition, String nodeTemplateName, ComponentTypeEnum componentType, String componentName){ SetupCDTest.getExtendTest().log(Status.INFO, "Going to validate "+ componentName + " " + componentType.getValue() + " node template TOSCA metadata..."); @@ -366,7 +382,7 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali Either.left(false); Map<String, Object> errorMap = new HashMap<>(); for(String key : expectedMetadata.keySet()){ - boolean isError = compareValue(expectedMetadata.get(key), actualMetadata.get(key)); + boolean isError = compareStringValue(expectedMetadata.get(key), actualMetadata.get(key)); if(!isError){ errorMap.put("Data key["+key+"]", "expected: " + expectedMetadata.get(key) + ", actual: " + actualMetadata.get(key)); } @@ -376,11 +392,30 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali } return Either.left(true); } - + + + public static Either<Boolean, Map<String, Object>> compareObjectMapData(Map<String, VfModuleDefinition> expectedObject, Map<String, VfModuleDefinition> actualObject) { + Map<String, Object> errorMap = new HashMap<>(); + for(String key : expectedObject.keySet()){ + boolean isError = compareObjectValue(expectedObject.get(key), actualObject.get(key)); + if(!isError){ + errorMap.put("Data key["+key+"]", "expected: " + expectedObject.get(key) + ", actual: " + actualObject.get(key)); + } + } + if(!errorMap.isEmpty()){ + return Either.right(errorMap); + } + return Either.left(true); + } + + private static boolean compareObjectValue(VfModuleDefinition expected, VfModuleDefinition actual) { + return expected.equals(actual); + } + public static Either<Boolean, Map<String, Object>> compareMetadataUsingToscaParser(Map<String, String> expectedMetadata, Metadata actualMetadata) { Map<String, Object> errorMap = new HashMap<>(); for(String key : expectedMetadata.keySet()){ - boolean isError = compareValue(expectedMetadata.get(key), actualMetadata.getValue(key)); + boolean isError = compareStringValue(expectedMetadata.get(key), actualMetadata.getValue(key)); if(!isError){ errorMap.put("Data key["+key+"]", "expected: " + expectedMetadata.get(key) + ", actual: " + actualMetadata.getValue(key)); } @@ -391,10 +426,8 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali return Either.left(true); } - private static boolean compareValue(String expected, String actual) { - + private static boolean compareStringValue(String expected, String actual) { return expected.equals(actual); - } public static Either<Boolean, Map<String, Object>> toscaInputsValidator(Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputs, Map<String, ToscaInputsTopologyTemplateDefinition> actualInputs){ @@ -424,7 +457,7 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali compareInputData(expectedInputs.get(inputName), actualInputs.get(inputName), errorMap); } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); @@ -451,14 +484,14 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali } } - if(errorMap != null && !errorMap.isEmpty()){ + if(!errorMap.isEmpty()){ return Either.right(errorMap); } return Either.left(true); } public static void compareInputValue(ToscaInputsTopologyTemplateDefinition expectedInputDefinition, Map<String, Object> errorMap, Field field, Object expectedValue, Object actualValue) { - if(field.getName() == "value" || field.getName() == "Default"){ + if(field.getName().equals("value") || field.getName().equals("Default")){ switch (expectedInputDefinition.getType()) { case "string": if(! expectedValue.toString().replace("\n"," ").replaceAll("( +)", " ").equals(actualValue.toString().replace("\n"," ").replaceAll("( +)", " "))){ @@ -475,7 +508,7 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali } break; case "boolean": - if(! expectedValue.toString().toLowerCase().equals(actualValue.toString().toLowerCase())){ + if(! expectedValue.toString().equalsIgnoreCase(actualValue.toString())){ errorMap.put("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); System.out.println("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]: expected: " + expectedValue + ", actual: " + actualValue); } @@ -484,13 +517,13 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali expectedInputDefinition.getEntry_schema().get("type"); break; case "map": - - break; + + break; default: break; } - - + + }else{ if(! expectedValue.equals(actualValue)){ errorMap.put("Data field [" + field.getName()+"] in input [" + expectedInputDefinition.getName() + "]", "expected: " + expectedValue + ", actual: " + actualValue); @@ -526,7 +559,7 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali public static Either<Boolean, Map<String, Object>> toscaInputsValidatorAgainstParser(Map<String, ToscaInputsTopologyTemplateDefinition> expectedInputsMap, ISdcCsarHelper fdntCsarHelper) { SetupCDTest.getExtendTest().log(Status.INFO, "Going to convert tosca parser inputs output to ToscaInputsTopologyTemplateDefinition object..."); - if(fdntCsarHelper.getServiceInputs().size() == 0){ + if(!fdntCsarHelper.getServiceInputs().isEmpty()){ if(expectedInputsMap != null && ! expectedInputsMap.isEmpty()){ return Either.left(true); }else{ @@ -542,7 +575,7 @@ public static Either<Boolean, Map<String, Object>> serviceToscaGroupMetadataVali /** * @param fdntCsarHelper convert list of inputs return from tosca parser to map of ToscaInputsTopologyTemplateDefinition - * @return + * @return field.get(actualServiceGroupProperty) */ public static Map<String, ToscaInputsTopologyTemplateDefinition> convertInputsParserOutputToMap(ISdcCsarHelper fdntCsarHelper) { Map<String, ToscaInputsTopologyTemplateDefinition> actualInputsMap = new HashMap<>(); diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java index 4d14084b80..0eab56ac18 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/UserManagementVerificator.java @@ -20,9 +20,7 @@ package org.openecomp.sdc.ci.tests.verificator; -import java.util.Arrays; -import java.util.List; - +import com.aventstack.extentreports.Status; import org.apache.commons.lang3.text.WordUtils; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.model.User; @@ -35,7 +33,8 @@ import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils; import org.openqa.selenium.WebElement; import org.testng.Assert; -import com.aventstack.extentreports.Status; +import java.util.Arrays; +import java.util.List; public class UserManagementVerificator { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java index ac009c6327..7284dc68f6 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCArtifactVerificator.java @@ -20,14 +20,7 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - +import com.aventstack.extentreports.Status; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.JSONValue; @@ -40,7 +33,13 @@ import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions; import org.openecomp.sdc.ci.tests.utilities.RestCDUtils; import org.testng.Assert; -import com.aventstack.extentreports.Status; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.testng.Assert.assertTrue; public class VFCArtifactVerificator { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java index 0872a3a5c3..604cb8a6b2 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VFCverificator.java @@ -20,11 +20,11 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.AssertJUnit.assertFalse; - import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage; +import static org.testng.AssertJUnit.assertFalse; + public class VFCverificator { diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java index 02e92f8943..efbb385225 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfModuleVerificator.java @@ -20,17 +20,7 @@ package org.openecomp.sdc.ci.tests.verificator; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.io.File; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - +import com.aventstack.extentreports.Status; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.GroupInstance; @@ -42,7 +32,13 @@ import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaGroupsTopologyTemplateDefinition; import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaServiceGroupsMetadataDefinition; -import com.aventstack.extentreports.Status; +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.testng.AssertJUnit.*; public class VfModuleVerificator { @@ -78,7 +74,7 @@ public class VfModuleVerificator { for (Map.Entry<String, ToscaGroupsTopologyTemplateDefinition> groupTopologyTemplateDefinition : groups.entrySet()) { String key = groupTopologyTemplateDefinition.getKey(); GroupInstance groupInstanceObject = getGroupInstanceByKey(key, service); - ToscaServiceGroupsMetadataDefinition metadata = groupTopologyTemplateDefinition.getValue().getMetadata(); + ToscaServiceGroupsMetadataDefinition metadata = groupTopologyTemplateDefinition.getValue(); assertNotNull("groupInstanceObject is null", groupInstanceObject); assertTrue("expected vfModuleModelName " + groupInstanceObject.getGroupName() + ", actual " + metadata.getVfModuleModelName(), groupInstanceObject.getGroupName().equals(metadata.getVfModuleModelName())); assertTrue("expected vfModuleModelInvariantUUID " + groupInstanceObject.getInvariantUUID() + ", actual " + metadata.getVfModuleModelInvariantUUID(), groupInstanceObject.getInvariantUUID().equals(metadata.getVfModuleModelInvariantUUID())); @@ -125,10 +121,10 @@ public class VfModuleVerificator { } public static void validateSpecificModulePropertiesFromFile(ToscaDefinition toscaDefinition){ - List<ToscaGroupsTopologyTemplateDefinition> vfModules = toscaDefinition.getTopology_template().getGroups().values().stream(). - filter(e -> e.getType().equals(VF_MODULE_TYPE)). - collect(Collectors.toList()); - + List<ToscaGroupsTopologyTemplateDefinition> vfModules = toscaDefinition. + getTopology_template().getGroups().values().stream(). + filter(e -> e.getType().equals(VF_MODULE_TYPE)). + collect(Collectors.toList()); for(String propertyType : PROPERTY_TYPES){ int numberOfTypes = (int) vfModules.stream(). // Get all declared fields from class ToscaGroupPropertyDefinition, collect them to List and check that current property exist and declared class diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java index b2397cb23f..b13b9f1a70 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/verificator/VfVerificator.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.ci.tests.verificator; +//import com.att.automation.common.report_portal_integration.annotations.Step; //ReportPortal import com.aventstack.extentreports.Status; import org.apache.commons.lang3.tuple.ImmutablePair; import org.json.simple.JSONArray; @@ -68,7 +69,7 @@ public final class VfVerificator { } public static void verifyLinkCreated(ResourceReqDetails createResourceInUI, User user, int expectedRelationsSize) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifing that a link was created on canvas")); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that a link was created on canvas")); String responseAfterDrag = RestCDUtils.getResource(createResourceInUI, user).getResponse(); JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); assertTrue(((JSONArray) jsonResource.get("componentInstancesRelations")).size() == expectedRelationsSize); @@ -76,7 +77,7 @@ public final class VfVerificator { } -// @Step(description="Verifying fields on General screen through UI ...") +// @Step(description="Verifying fields on General screen through UI ...") //ReportPortal public static void verifyVFMetadataInUI(ResourceReqDetails vf) { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying fields on General screen through UI ...")); assertTrue(vf.getName().equals(ResourceGeneralPage.getNameText())); @@ -93,7 +94,7 @@ public final class VfVerificator { assertTrue(vf.getContactId().equals(ResourceGeneralPage.getContactIdText())); } -// @Step(description="Verifying fields on General screen through Backend ...") +// @Step(description="Verifying fields on General screen through Backend ...") //ReportPortal public static void verifyVFUpdated(ResourceReqDetails vf, User user) { SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying fields on General screen through Backend ...")); String response = RestCDUtils.getResource(vf, user).getResponse(); @@ -124,7 +125,7 @@ public final class VfVerificator { } public static void verifyVFLifecycle(ResourceReqDetails vf, User user, LifecycleStateEnum expectedLifecycleState) { - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object %s version is %s", vf.getName(),expectedLifecycleState)); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object %s state is %s", vf.getName(),expectedLifecycleState)); String responseAfterDrag = RestCDUtils.getResource(vf, user).getResponse(); JSONObject jsonResource = (JSONObject) JSONValue.parse(responseAfterDrag); String actualLifecycleState = jsonResource.get("lifecycleState").toString(); @@ -132,10 +133,17 @@ public final class VfVerificator { } public static void verifyVfLifecycleInUI(LifeCycleStateEnum lifecycleState){ - SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object version is %s", lifecycleState.getValue())); + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that object state is %s", lifecycleState.getValue())); GeneralUIUtils.ultimateWait(); assertTrue(ResourceGeneralPage.getLifeCycleState().equals(lifecycleState.getValue())); } + + public static void verifyVersionUI(String expected){ + SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying that version is %s", expected)); + String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown + (DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText().replace("V", ""); + assertTrue(actualVersion.equals(expected), String.format( "Expected version: %s, Actual version: %s", expected, actualVersion)); + } public static void verifyInstanceVersion(ResourceReqDetails vf, User user, String instanceName, String instanceVersion){ SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verfiying that instance %s version is %s", instanceName,instanceVersion)); @@ -219,7 +227,30 @@ public final class VfVerificator { public static void verifyOnboardedVnfMetadata(String vspName, VendorSoftwareProductObject vspMetadata) { SetupCDTest.getExtendTest().log(Status.INFO, "Verifying metadata"); + assertTrue(vspName.equals(ResourceGeneralPage.getNameText()), "VSP name is not valid."); + List<WebElement> tagsList = ResourceGeneralPage.getElementsFromTagsTable(); + assertTrue(tagsList.size() == 1, "VSP tags size is not equal to 1."); + assertTrue(vspName.equals(tagsList.get(0).getText()), "VSP tag is not its name."); + + verifyMetadataIndifferentToFlow(vspMetadata); + } + + public static void verifyOnboardedVnfMetadataAfterUpdateVNF(String vspName, VendorSoftwareProductObject vspMetadata) { + SetupCDTest.getExtendTest().log(Status.INFO, "Verifying metadata after update VNF"); + + // VF name should be updated only only if VF not certified + if(Double.parseDouble(ResourceGeneralPage.getVersionUI()) < 1.0) { + assertTrue(vspName.equals(ResourceGeneralPage.getNameText()), "VSP name is not valid."); + List<WebElement> tagsList = ResourceGeneralPage.getElementsFromTagsTable(); + assertTrue(tagsList.size() == 1, "VSP tags size is not equal to 1."); + assertTrue(vspName.equals(tagsList.get(0).getText()), "VSP tag is not its name."); + } + + verifyMetadataIndifferentToFlow(vspMetadata); + } + + public static void verifyMetadataIndifferentToFlow(VendorSoftwareProductObject vspMetadata) { assertTrue(vspMetadata.getDescription().equals(ResourceGeneralPage.getDescriptionText()), "VSP description is not valid."); String [] splitedSubCategorey = vspMetadata.getSubCategory().split("\\."); @@ -229,9 +260,6 @@ public final class VfVerificator { assertTrue(expectedSubCategory.equals(actualSubCategory), "VSP category is not valid."); assertTrue(vspMetadata.getVendorName().equals(ResourceGeneralPage.getVendorNameText()), "VSP vendor name is not valid."); assertTrue("1.0".equals(ResourceGeneralPage.getVendorReleaseText()), "VSP version is not valid."); - List<WebElement> tagsList = ResourceGeneralPage.getElementsFromTagsTable(); - assertTrue(tagsList.size() == 1, "VSP tags size is not equal to 1."); - assertTrue(vspName.equals(tagsList.get(0).getText()), "VSP tag is not its name."); assertTrue(vspMetadata.getAttContact().equals(ResourceGeneralPage.getContactIdText()), "VSP attContact is not valid."); } |