Functional Test Automation: VSP 38/85038/2
authorVodafone <onap@vodafone.com>
Thu, 11 Apr 2019 10:37:52 +0000 (16:07 +0530)
committerOren Kleks <orenkle@amdocs.com>
Thu, 11 Apr 2019 11:28:18 +0000 (11:28 +0000)
Change-Id: I2090a0646c1f1c7077830dbf49294f9a711774e4
Issue-ID: SDC-2047
Co-authored-by: rahul.ghugikar@vodafone.com, soumyarup.paul@vodafone.com
Signed-off-by: Vodafone <onap@vodafone.com>
test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardingFlowsUI.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationPage.java [new file with mode: 0644]
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationResultsPage.java [new file with mode: 0644]
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/GeneralUIUtils.java
ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/OnboardingUiUtils.java
ui-ci/src/main/resources/ci/testSuites/onapUiSanity.xml
ui-ci/src/main/resources/ci/testSuites/vspValidationAllFlows.xml [new file with mode: 0644]

index f85f326..a4338fb 100644 (file)
@@ -422,4 +422,6 @@ public interface Urls {
        String DELETE_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities/%s";
        String GET_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities/%s";
 
+       //VSP Validation Operation
+       final String VSP_VALIDATION_CONFIGURATION = SDC_HTTP_METHOD + "://%s:%s/onboarding-api/v1.0/externaltesting/config";
 }
index 4f03767..8b5f91b 100644 (file)
@@ -27,6 +27,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
 import org.openecomp.sdc.ci.tests.utils.Utils;
+import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
 
 import java.util.*;
 
@@ -138,6 +139,36 @@ public class OnboardingUtils {
                return response;
        }
 
+       public static String getVspValidationConfiguration() throws Exception {
+               Config config = Utils.getConfig();
+               String url = String.format(Urls.VSP_VALIDATION_CONFIGURATION, config.getOnboardingBeHost(), config.getOnboardingBePort());
+               Map<String, String> headersMap = prepareHeadersMap("cs0008");
+
+               HttpRequest http = new HttpRequest();
+               RestResponse response = http.httpSendGet(url, headersMap);
+               if(response.getErrorCode().intValue() == 200){
+                       return ResponseParser.getValueFromJsonResponse(response.getResponse(), "enabled");
+               }
+               throw new Exception("Cannot get configuration file");
+               //return response;
+       }
+
+       public static String putVspValidationConfiguration(boolean value) throws Exception {
+               Config config = Utils.getConfig();
+               String url = String.format(Urls.VSP_VALIDATION_CONFIGURATION, config.getOnboardingBeHost(), config.getOnboardingBePort());
+               Map<String, String> headersMap = prepareHeadersMap("cs0008");
+
+               String body = String.format("{\"enabled\": \"%s\"}", value);
+
+               HttpRequest http = new HttpRequest();
+               RestResponse response = http.httpSendPut(url, body, headersMap);
+               if(response.getErrorCode().intValue() == 200){
+                       return ResponseParser.getValueFromJsonResponse(response.getResponse(), "enabled");
+               }
+               throw new Exception("Cannot set configuration file");
+               //return response;
+       }
+
        protected static Map<String, String> prepareHeadersMap(String userId) {
                Map<String, String> headersMap = new HashMap<String, String>();
                headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
index 662b239..3823611 100644 (file)
@@ -1033,4 +1033,42 @@ public final class DataTestIdEnum {
                }
        }
 
+       public enum VspValidationPage {
+
+               VSP_VALIDATION_PAGE_NAVBAR("navbar-group-item-SOFTWARE_PRODUCT_VALIDATION"),
+               VSP_VALIDATION_PAGE_BREADCRUMBS("sub-menu-button-validation"),
+               VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON("go-to-vsp-validation-inputs"),
+               VSP_VALIDATION_PAGE_PROCEED_TO_SETUP_BUTTON("go-to-vsp-validation-setup"),
+               VSP_VALIDATION_PAGE_INPUT("%s_%s_input"),
+               VSP_VALIDATION_PAGE_PROCEED_TO_RESULTS_BUTTON("proceed-to-validation-results-btn"),
+               VSP_VALIDATION_PAGE_COMPLIANCE_CHECKBOX_TREE("vsp-validation-compliance-checks-checkbox-tree"),
+               VSP_VALIDATION_PAGE_CERTIFICATION_CHECKBOX_TREE("vsp-validation-certifications-query-checkbox-tree");
+
+               private String value;
+
+               public String getValue() {
+                       return value;
+               }
+
+               private VspValidationPage(String value) {
+                       this.value = value;
+               }
+       }
+
+       public enum VspValidationResultsPage {
+
+               VSP_VALIDATION_RESULTS_PAGE_NAVBAR("navbar-group-item-SOFTWARE_PRODUCT_VALIDATION_RESULTS"),
+               VSP_VALIDATION_RESULTS_PAGE_BREADCRUMBS("sub-menu-button-validation results");
+
+               private String value;
+
+               public String getValue() {
+                       return value;
+               }
+
+               private VspValidationResultsPage(String value) {
+                       this.value = value;
+               }
+       }
+
 }
index 77b2a0a..419ca6e 100644 (file)
@@ -107,7 +107,158 @@ public class OnboardingFlowsUI extends SetupCDTest {
         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, vnfFile);
     }
 
+    @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders.class, dataProvider = "Single_VNF")
+    public void onapOnboardVSPValidationsSanityFlow(String filePath, String vnfFile) throws Exception, Throwable {
+        setLog(vnfFile);
+        String vspName = createNewVSP(filePath, vnfFile);
+        if(OnboardingUiUtils.getVspValidationCongiguration()){
+            goToVspScreen(true, vspName);
+
+            //check links are available
+            checkVspValidationLinksVisibility();
+
+            VspValidationPage.navigateToVspValidationPageUsingNavbar();
+            assertTrue("Next Button is enabled, it should have been disabled", VspValidationPage.checkNextButtonDisabled());
+            VspValidationResultsPage.navigateToVspValidationResultsPageUsingNavbar();
+            GeneralUIUtils.ultimateWait();
+            assertNotNull(GeneralUIUtils.findByText("No Validation Checks Performed"));
+        }
+        else {
+            goToVspScreen(true, vspName);
+
+            //check links are not available
+            checkVspValidationLinksInvisibility();
+        }
+    }
+
+
+    @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders.class, dataProvider = "Single_VNF")
+    public void onapOnboardVSPValidationsConfigurationChangeCheck(String filePath, String vnfFile) throws Exception, Throwable {
+        setLog(vnfFile);
+        String vspName = createNewVSP(filePath, vnfFile);
+        if(OnboardingUiUtils.getVspValidationCongiguration()){
+            goToVspScreen(true, vspName);
+            //check links are available
+            checkVspValidationLinksVisibility();
+
+            //change config
+            changeVspValidationConfig(false, vspName, OnboardingUiUtils.getVspValidationCongiguration());
+
+            //check links are not available
+            checkVspValidationLinksInvisibility();
+        }
+        else {
+            goToVspScreen(true, vspName);
+            //check links are not available
+            checkVspValidationLinksInvisibility();
 
+            changeVspValidationConfig(false, vspName, OnboardingUiUtils.getVspValidationCongiguration());
+
+            //check links are available
+            checkVspValidationLinksVisibility();
+        }
+    }
+
+    @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders.class, dataProvider = "Single_VNF")
+    public void onapOnboardVSPCertificationQueryFlow(String filePath, String vnfFile) throws Exception, Throwable {
+        setLog(vnfFile);
+        String vspName = createNewVSP(filePath, vnfFile);
+        if(!OnboardingUiUtils.getVspValidationCongiguration()){
+            //change config to true to test the feature
+            changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
+        }
+        else {
+            goToVspScreen(true, vspName);
+        }
+        VspValidationPage.navigateToVspValidationPageUsingNavbar();
+        assertTrue("Next Button is enabled, it should have been disabled", VspValidationPage.checkNextButtonDisabled());
+
+        if(VspValidationPage.checkCertificationQueryExists()){
+            VspValidationPage.clickCertificationQueryAll();
+            GeneralUIUtils.ultimateWait();
+            assertTrue("Next Button is disabled, it should have been enabled", !VspValidationPage.checkNextButtonDisabled());
+            VspValidationPage.clickOnNextButton();
+            GeneralUIUtils.ultimateWait();
+            VspValidationPage.clickOnSubmitButton();
+            GeneralUIUtils.waitForLoader();
+            assertTrue("Results are not available", VspValidationResultsPage.checkResultsExist());
+        }
+        else {
+            assertNotNull(GeneralUIUtils.findByText("No Certifications Query are Available"));
+        }
+
+    }
+
+    @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders.class, dataProvider = "Single_VNF")
+    public void onapOnboardVSPComplianceCheckFlow(String filePath, String vnfFile) throws Exception, Throwable {
+        setLog(vnfFile);
+        String vspName = createNewVSP(filePath, vnfFile);
+        if(!OnboardingUiUtils.getVspValidationCongiguration()){
+            //change config to true to test the feature
+            changeVspValidationConfig(true, vspName, OnboardingUiUtils.getVspValidationCongiguration());
+        }
+        else {
+            goToVspScreen(true, vspName);
+        }
+
+        VspValidationPage.navigateToVspValidationPageUsingNavbar();
+        assertTrue("Next Button is enabled, it should have been enabled", VspValidationPage.checkNextButtonDisabled());
+        if(VspValidationPage.checkComplianceCheckExists()){
+            VspValidationPage.clickComplianceChecksAll();
+            GeneralUIUtils.ultimateWait();
+            assertTrue("Next Button is disabled, it should have been enabled", !VspValidationPage.checkNextButtonDisabled());
+            VspValidationPage.clickOnNextButton();
+            GeneralUIUtils.ultimateWait();
+            VspValidationPage.clickOnSubmitButton();
+            GeneralUIUtils.waitForLoader();
+            assertTrue("Results are not available", VspValidationResultsPage.checkResultsExist());
+        }
+        else {
+            assertNotNull(GeneralUIUtils.findByText("No Compliance Checks are Available"));
+        }
+
+    }
+
+    private void checkVspValidationLinksVisibility(){
+        //check links are available
+        assertTrue("Validation Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue()));
+        assertTrue("Validation Results Link is not available", GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue()));
+    }
+
+    private void checkVspValidationLinksInvisibility(){
+        //check links not available
+        assertTrue("Validation Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR.getValue()));
+        assertTrue("Validation Results Link is still available", GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR.getValue()));
+    }
+
+    private void changeVspValidationConfig(boolean isCurrentScreenCatalogPage, String vspName, boolean vspConfig) throws Exception{
+        //change config
+        OnboardingUiUtils.putVspValidationCongiguration(!vspConfig);
+        assertTrue(String.format("Failed to set Congiguration to %s", !vspConfig), OnboardingUiUtils.getVspValidationCongiguration() != vspConfig);
+
+        if(!isCurrentScreenCatalogPage){
+            GeneralUIUtils.refreshWebpage();
+            GeneralUIUtils.ultimateWait();
+        }
+
+        goToVspScreen(isCurrentScreenCatalogPage, vspName);
+
+        //revert the config
+        OnboardingUiUtils.putVspValidationCongiguration(vspConfig);
+        assertTrue(String.format("Failed to revert Congiguration to %s", vspConfig), OnboardingUiUtils.getVspValidationCongiguration() == vspConfig);
+    }
+
+    private void goToVspScreen(boolean isCurrentScreenCatalogPage, String vspName) throws Exception{
+        if(isCurrentScreenCatalogPage)
+            GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.MainMenuButtons.ONBOARD_BUTTON.getValue());
+        GeneralUIUtils.clickOnElementByText(vspName);
+        GeneralUIUtils.waitForLoader();
+    }
+
+    private String createNewVSP(String filePath, String vnfFile) throws Exception {
+        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
+        return OnboardingUiUtils.createVSP(resourceReqDetails, vnfFile, filePath, getUser()).getName();
+    }
     public void runOnboardToDistributionFlow(ResourceReqDetails resourceReqDetails, ServiceReqDetails serviceMetadata, String filePath, String vnfFile) throws Exception {
         getExtendTest().log(Status.INFO, "Going to create resource with category: " + resourceReqDetails.getCategories().get(0).getName()
                 + " subCategory: " + resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName()
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationPage.java
new file mode 100644 (file)
index 0000000..286ee46
--- /dev/null
@@ -0,0 +1,100 @@
+/**\r
+ * Copyright (c) 2019 Vodafone Group\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openecomp.sdc.ci.tests.pages;\r
+\r
+import com.aventstack.extentreports.Status;\r
+import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;\r
+import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;\r
+import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;\r
+import org.openqa.selenium.WebElement;\r
+import org.openqa.selenium.*;\r
+import static org.testng.AssertJUnit.assertTrue;\r
+\r
+\r
+import java.util.List;\r
+\r
+public class VspValidationPage extends GeneralPageElements {\r
+\r
+    public VspValidationPage() { super(); }\r
+\r
+    public static void navigateToVspValidationPageUsingNavbar() throws Exception {\r
+        clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_NAVBAR);\r
+    }\r
+\r
+    public static void navigateToVspValidationPageUsingBreadcrumbs() throws Exception {\r
+        clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_BREADCRUMBS);\r
+    }\r
+\r
+    public static void clickOnNextButton() throws Exception {\r
+        clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON);\r
+    }\r
+\r
+    public static void clickOnBackButton() throws Exception {\r
+        clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_SETUP_BUTTON);\r
+    }\r
+\r
+    public static void clickOnSubmitButton() throws Exception {\r
+        clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_RESULTS_BUTTON);\r
+    }\r
+\r
+    public static boolean checkNextButtonDisabled() throws Exception {\r
+        return GeneralUIUtils.isElementDisabled(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_PROCEED_TO_INPUTS_BUTTON.getValue());\r
+    }\r
+\r
+    public static void clickCertificationQueryAll() throws Exception {\r
+        List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-certifications-query-checkbox-tree']//label//span[@class='rct-checkbox']");\r
+        if(checkboxes.size() > 0){\r
+            checkboxes.get(0).click();\r
+        }\r
+        else\r
+            assertTrue("Checkbox Not Found", checkboxes.size() > 0);\r
+    }\r
+\r
+    public static void clickComplianceChecksAll() throws Exception {\r
+        List<WebElement> checkboxes = GeneralUIUtils.findElementsByXpath("//div[@data-test-id='vsp-validation-compliance-checks-checkbox-tree']//label//span[@class='rct-checkbox']");\r
+        if(checkboxes.size() > 0)\r
+            checkboxes.get(checkboxes.size() - 1).click();\r
+        else\r
+            assertTrue("Checkbox Not Found", checkboxes.size() > 0);\r
+    }\r
+\r
+    public static boolean checkCertificationQueryExists() throws Exception {\r
+        WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_CERTIFICATION_CHECKBOX_TREE.getValue());\r
+        List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);\r
+        List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));\r
+        return (orderedList.size() > 0);\r
+    }\r
+\r
+    public static boolean checkComplianceCheckExists() throws Exception {\r
+        WebElement parentDiv = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.VspValidationPage.VSP_VALIDATION_PAGE_COMPLIANCE_CHECKBOX_TREE.getValue());\r
+        List<WebElement> checkboxTreeDivs = getChildElements(parentDiv);\r
+        List<WebElement> orderedList = getChildElements(checkboxTreeDivs.get(0));\r
+        return (orderedList.size() > 0);\r
+    }\r
+\r
+    public static void clickOnElementUsingTestId(DataTestIdEnum.VspValidationPage elementTestId) throws Exception {\r
+        SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", elementTestId.name()));\r
+        GeneralUIUtils.getWebElementByTestID(elementTestId.getValue()).click();\r
+        GeneralUIUtils.ultimateWait();\r
+    }\r
+\r
+    public static List<WebElement> getChildElements(WebElement webElement) throws Exception {\r
+        return webElement.findElements(By.xpath(".//*"));\r
+    }\r
+\r
+\r
+}
\ No newline at end of file
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationResultsPage.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/VspValidationResultsPage.java
new file mode 100644 (file)
index 0000000..e71afd9
--- /dev/null
@@ -0,0 +1,50 @@
+/**\r
+ * Copyright (c) 2019 Vodafone Group\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openecomp.sdc.ci.tests.pages;\r
+\r
+import com.aventstack.extentreports.Status;\r
+import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;\r
+import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;\r
+import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;\r
+import org.openqa.selenium.WebElement;\r
+import org.testng.AssertJUnit;\r
+\r
+import java.util.List;\r
+\r
+public class VspValidationResultsPage extends GeneralPageElements {\r
+\r
+    public VspValidationResultsPage() { super(); }\r
+\r
+    public static void navigateToVspValidationResultsPageUsingNavbar() throws Exception {\r
+        clickOnElementUsingTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_NAVBAR);\r
+    }\r
+\r
+    public static void navigateToVspValidationResultsPageUsingBreadcrumbs() throws Exception {\r
+        clickOnElementUsingTestId(DataTestIdEnum.VspValidationResultsPage.VSP_VALIDATION_RESULTS_PAGE_BREADCRUMBS);\r
+    }\r
+\r
+    public static boolean checkResultsExist() throws Exception {\r
+        List<WebElement> results = GeneralUIUtils.findElementsByXpath("//h4[contains(text(),'No Validation Checks Performed')]");\r
+        return results.size() == 0;\r
+    }\r
+\r
+    public static void clickOnElementUsingTestId(DataTestIdEnum.VspValidationResultsPage elementTestId) throws Exception {\r
+        SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s", elementTestId.name()));\r
+        GeneralUIUtils.getWebElementByTestID(elementTestId.getValue()).click();\r
+        GeneralUIUtils.ultimateWait();\r
+    }\r
+}
\ No newline at end of file
index 30e6823..eed2590 100644 (file)
@@ -49,7 +49,7 @@ import static org.testng.AssertJUnit.assertTrue;
 
 public final class GeneralUIUtils {
 
-    private static final String DATA_TESTS_ID = "//*[@data-tests-id='";
+    private static final String DATA_TESTS_ID = "//*[@data-tests-id='%1$s' or @data-test-id='%1$s']";
     private static final String COLOR_YELLOW_BORDER_4PX_SOLID_YELLOW = "color: yellow; border: 4px solid yellow;";
 
     private static int timeOut = (int) (60 * 1.5);
@@ -105,11 +105,11 @@ public final class GeneralUIUtils {
 
     public static WebElement getWebElementByTestID(String dataTestId, int timeout) {
         WebDriverWait wait = new WebDriverWait(getDriver(), timeout);
-        return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(DATA_TESTS_ID + dataTestId + "']")));
+        return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId))));
     }
 
     public static boolean isWebElementExistByTestId(String dataTestId) {
-        return getDriver().findElements(By.xpath(DATA_TESTS_ID + dataTestId + "']")).size() != 0;
+        return getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID,dataTestId))).size() != 0;
     }
 
     public static boolean isWebElementExistByClass(String className) {
@@ -119,7 +119,7 @@ public final class GeneralUIUtils {
     public static WebElement getInputElement(String dataTestId) {
         try {
             ultimateWait();
-            return getDriver().findElement(By.xpath(DATA_TESTS_ID + dataTestId + "']"));
+            return getDriver().findElement(By.xpath(String.format(DATA_TESTS_ID,dataTestId)));
         } catch (Exception e) {
             return null;
         }
@@ -127,7 +127,7 @@ public final class GeneralUIUtils {
 
     public static List<WebElement> getInputElements(String dataTestId) {
         ultimateWait();
-        return getDriver().findElements(By.xpath(DATA_TESTS_ID + dataTestId + "']"));
+        return getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID,dataTestId)));
 
     }
 
@@ -165,7 +165,7 @@ public final class GeneralUIUtils {
     public static List<WebElement> getWebElementsListByContainTestID(String dataTestId) {
         try {
             WebDriverWait wait = new WebDriverWait(getDriver(), 10);
-            return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[contains(@data-tests-id, '" + dataTestId + "')]")));
+            return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(String.format("//*[contains(@data-tests-id, '%1$s') or contains(@data-test-id, '%1$s')]",dataTestId))));
         } catch (Exception e) {
             return new ArrayList<WebElement>();
         }
@@ -187,7 +187,7 @@ public final class GeneralUIUtils {
 
     public static List<WebElement> getWebElementsListByTestID(String dataTestId) {
         WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
-        return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(DATA_TESTS_ID + dataTestId + "']")));
+        return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(String.format(DATA_TESTS_ID,dataTestId))));
     }
 
     public static List<WebElement> getWebElementsListByClassName(String className) {
@@ -199,13 +199,13 @@ public final class GeneralUIUtils {
     public static Boolean isElementInvisibleByTestId(String dataTestId) {
         WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
         return wait.until(
-                ExpectedConditions.invisibilityOfElementLocated(By.xpath(DATA_TESTS_ID + dataTestId + "']")));
+                ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId))));
     }
 
     public static Boolean isElementVisibleByTestId(String dataTestId) {
         try {
             WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
-            return wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath(DATA_TESTS_ID + dataTestId + "']")))).isDisplayed();
+            return wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath(String.format(DATA_TESTS_ID,dataTestId))))).isDisplayed();
         } catch (Exception e) {
             return false;
         }
@@ -218,22 +218,22 @@ public final class GeneralUIUtils {
 
     public static void clickOnElementByTestIdWithoutWait(String dataTestId) {
         WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
-        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(DATA_TESTS_ID + dataTestId + "']"))).click();
+        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))).click();
     }
 
     public static void clickOnElementByInputTestIdWithoutWait(String dataTestId) {
         WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
-        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(DATA_TESTS_ID + dataTestId + "']//*"))).click();
+        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID, dataTestId) + "//*"))).click();
     }
 
     public static void clickOnElementByTestId(String dataTestId, int customTimeout) {
         WebDriverWait wait = new WebDriverWait(getDriver(), customTimeout);
-        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(DATA_TESTS_ID + dataTestId + "']"))).click();
+        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))).click();
     }
 
     public static WebElement waitForElementVisibilityByTestId(String dataTestId) {
         WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
-        return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(DATA_TESTS_ID + dataTestId + "']")));
+        return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId))));
     }
 
     public static Boolean waitForElementInVisibilityByTestId(String dataTestId) {
@@ -242,9 +242,9 @@ public final class GeneralUIUtils {
 
     public static Boolean waitForElementInVisibilityByTestId(String dataTestId, int timeOut) {
         WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
-        boolean displayed = getDriver().findElements(By.xpath(DATA_TESTS_ID + dataTestId + "']")).isEmpty();
+        boolean displayed = getDriver().findElements(By.xpath(String.format(DATA_TESTS_ID,dataTestId))).isEmpty();
         if (!displayed) {
-            Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(DATA_TESTS_ID + dataTestId + "'])")));
+            Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(String.format(DATA_TESTS_ID,dataTestId))));
             ultimateWait();
             return until;
         }
@@ -385,7 +385,7 @@ public final class GeneralUIUtils {
 
     public static WebElement getSelectedElementFromDropDown(String dataTestId) {
         GeneralUIUtils.ultimateWait();
-        return new Select(getDriver().findElement(By.xpath(DATA_TESTS_ID + dataTestId + "']"))).getFirstSelectedOption();
+        return new Select(getDriver().findElement(By.xpath(String.format(DATA_TESTS_ID,dataTestId)))).getFirstSelectedOption();
     }
 
     public static boolean checkElementsCountInTable(int expectedElementsCount, Supplier<List<WebElement>> func) {
@@ -492,7 +492,7 @@ public final class GeneralUIUtils {
 
     public static boolean isElementDisabled(WebElement element) {
         return HighlightMyElement(element).getAttribute("class").contains("view-mode") ||
-                element.getAttribute("class").contains("disabled");
+                element.getAttribute("class").contains("disabled") || element.getAttribute("disabled") != null;
     }
 
     public static boolean isElementDisabled(String dataTestId) {
@@ -613,7 +613,7 @@ public final class GeneralUIUtils {
 
     public static void selectByValueTextContained(String dataTestsId, String value) {
 
-        List<WebElement> options = GeneralUIUtils.getWebElementsListBy(By.xpath(String.format("//select[@data-tests-id='%s']//option[contains(@value,'%s')]", dataTestsId, value)));
+        List<WebElement> options = GeneralUIUtils.getWebElementsListBy(By.xpath(String.format("//select[@data-tests-id='%1$s' or @data-test-id='%1$s']//option[contains(@value,'%2$s')]", dataTestsId, value)));
 
         boolean matched = false;
         for (WebElement option : options) {
@@ -668,6 +668,12 @@ public final class GeneralUIUtils {
         getDriver().navigate().to(url);
     }
 
+    public static void refreshWebpage() throws Exception {
+        SetupCDTest.getExtendTest().log(Status.INFO, "Refreshing Webpage");
+        getDriver().navigate().refresh();
+        ultimateWait();
+    }
+
     public static Object getElementPositionOnCanvas(String elementName) {
         String scriptJS = "var cy = window.jQuery('.sdc-composition-graph-wrapper').cytoscape('get');\n" +
                 "var n = cy.nodes('[name=\"" + elementName + "\"]');\n" +
index 9ef9515..6a91ed7 100644 (file)
@@ -35,6 +35,7 @@ import org.openecomp.sdc.ci.tests.utils.general.VendorSoftwareProductRestUtils;
 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
 import org.openqa.selenium.WebElement;
 import org.testng.Assert;
+import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils;
 
 import java.io.File;
 import java.util.LinkedList;
@@ -80,6 +81,14 @@ public class OnboardingUiUtils {
         }
     }
 
+    public static boolean getVspValidationCongiguration() throws Exception{
+        return Boolean.parseBoolean(OnboardingUtils.getVspValidationConfiguration());
+    }
+
+    public static boolean putVspValidationCongiguration(boolean value) throws Exception{
+        return Boolean.parseBoolean(OnboardingUtils.putVspValidationConfiguration(value));
+    }
+
     public static void doCheckOut() {
         String lifeCycleState = ResourceGeneralPage.getLifeCycleState();
         boolean needCheckout = lifeCycleState.equals(LifeCycleStateEnum.CHECKIN.getValue()) || lifeCycleState.equals(LifeCycleStateEnum.CERTIFIED.getValue());
@@ -130,6 +139,14 @@ public class OnboardingUiUtils {
         DeploymentArtifactPage.verifyArtifactsExistInTable(filePath, updatedVnfFile);
     }
 
+    public static VendorSoftwareProductObject createVSP(ResourceReqDetails resourceReqDetails, String vnfFile, String filepath, User user) throws Exception {
+        ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile));
+        System.out.println(String.format("Going to onboard the VNF %s", vnfFile));
+
+        AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(user);
+        return VendorSoftwareProductRestUtils.createVSP(resourceReqDetails, vnfFile, filepath, user, amdocsLicenseMembers);
+    }
+
 
     public static VendorSoftwareProductObject onboardAndValidate(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile, User user) throws Exception {
         ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile));
index de03d3d..3945088 100644 (file)
@@ -23,6 +23,7 @@
         <class name="org.openecomp.sdc.ci.tests.execute.sanity.OnboardingFlowsUI">
             <methods>
                 <include name="onapOnboardVNFflow"/>
+                <include name="onapOnboardVSPValidationsSanityFlow"/>
             </methods>
         </class>
 
diff --git a/ui-ci/src/main/resources/ci/testSuites/vspValidationAllFlows.xml b/ui-ci/src/main/resources/ci/testSuites/vspValidationAllFlows.xml
new file mode 100644 (file)
index 0000000..fcbd41e
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">\r
+<suite name="uitests" configfailurepolicy="continue" parallel="methods" thread-count="1" data-provider-thread-count="1">\r
+\r
+    <parameter name="makeDistribution"  value="false"/>\r
+\r
+  <test name="vspValidationAllFlows">\r
+    <classes>\r
+\r
+        <class name="org.openecomp.sdc.ci.tests.execute.sanity.OnboardingFlowsUI">\r
+            <methods>\r
+                <include name="onapOnboardVSPValidationsSanityFlow"/>\r
+                <include name="onapOnboardVSPValidationsConfigurationChangeCheck" />\r
+                <include name="onapOnboardVSPCertificationQueryFlow"/>\r
+                <include name="onapOnboardVSPComplianceCheckFlow"/>\r
+            </methods>\r
+        </class>\r
+\r
+    </classes>\r
+  </test> <!-- uitests -->\r
+</suite> <!-- uisuite -->
\ No newline at end of file