PM_Dictionary Support in GAB

UI Sanity for PM Dictionary events in GAB:
* added dedicated test for PM_Dictionary
* fixed legacy keywords for VES_Event test
* Moved GAB tests to separate suite

Change-Id: I8b033b3f14b5b18e74bd6c566d5c269e4a94001a
Issue-ID: SDC-2095
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java
index 7a8bcd3..0046489 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/DataTestIdEnum.java
@@ -112,6 +112,7 @@
         UPGRADE_SERVICES_OK("upgradeVspModal-button-upgrade"),
         UPDATE_SERVICES_OK("upgradeVspModal-button-update"),
         UPGRADE_SERVICES_CLOSE("upgradeVspModal-button-close"),
+        UPGRADE_ARTIFACT_BUTTON("upgradeVspModal-button-done"),
         ACCEPT_TESTING_MESSAGE("checkindialog");
 
         private final String value;
@@ -203,7 +204,7 @@
     @AllArgsConstructor
     @Getter
     public enum ArtifactPageEnum {
-        ADD_DEPLOYMENT_ARTIFACT("add-deployment-artifact-button"),
+        ADD_DEPLOYMENT_ARTIFACT("add_artifact_btn"),
         ADD_INFORMATIONAL_ARTIFACT("add-information-artifact-button"),
         DOWNLOAD_ARTIFACT_ENV("download_env_"),
         ADD_ANOTHER_ARTIFACT("add-another-artifact-button"),
@@ -396,11 +397,12 @@
     @AllArgsConstructor
     @Getter
     public enum ArtifactPopup {
-
         BROWSE("browseButton"),
+        FILE_UNDEFINED("fileundefined"),
         ARTIFACT_DESCRIPTION("description"),
         ARTIFACT_LABEL("artifactLabel"),
         ARTIFACT_TYPE("artifacttype"),
+        ARTIFACT_TYPE_ICON("artifacttype-icon"),
         OK("OK"),
         SAVE("Save"),
         DONE_BUTTON("Done"),
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/GAB.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/GAB.java
new file mode 100644
index 0000000..348400e
--- /dev/null
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/GAB.java
@@ -0,0 +1,123 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020  Nokia Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.ci.tests.execute.sanity;
+
+import com.aventstack.extentreports.Status;
+import java.util.Collections;
+import java.util.List;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
+import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
+import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
+import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
+import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
+import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
+import org.openecomp.sdc.ci.tests.utilities.FileHandling;
+import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
+import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openqa.selenium.WebElement;
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class GAB extends SetupCDTest {
+
+    private static final int THREAD_SLEEP_TIME = 1000;
+    private static final int MAIN_PAGE_ROWS_SIZE = 2;
+    private static final int MAIN_PAGE_COLUMN_SIZE = 5;
+
+    private String pnfFilePath;
+    private String vnfFilePath;
+
+    @BeforeClass
+    public void beforeClass() {
+        pnfFilePath = FileHandling.getFilePath("PNFs");
+        vnfFilePath = FileHandling.getFilePath("VNFs");
+    }
+
+    @Test
+    public void addPmDictionaryDeploymentArtifactToPnfAndCheckMagnifierTest() throws Exception {
+        final int expectedHeaderSize = MAIN_PAGE_COLUMN_SIZE + 10;
+        final int expectedRowSize = MAIN_PAGE_ROWS_SIZE + 3;
+        ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser());
+        ResourceUIUtils.createPNF(pnfMetaData, getUser());
+        ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
+        ArtifactInfo art1 = new ArtifactInfo(pnfFilePath, "pmDictionary.yml", "desc", "artifactpm", "PM_DICTIONARY");
+        addArtifactAndOpenGAB(art1);
+        assertHeaderAndRowSize(expectedHeaderSize, expectedRowSize);
+    }
+
+    @Test
+    public void addVesEventsDeploymentArtifactToVfAndCheckMagnifierTest() throws Exception {
+        final int expectedHeaderSize = MAIN_PAGE_COLUMN_SIZE + 4;
+        final int expectedRowSize = MAIN_PAGE_ROWS_SIZE + 3;
+        ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
+        ResourceUIUtils.createVF(vfMetaData, getUser());
+        ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
+        ArtifactInfo art1 = new ArtifactInfo(vnfFilePath, "vesEvent.yml", "desc", "artifactfault", "VES_EVENTS");
+        addArtifactAndOpenGAB(art1);
+        assertHeaderAndRowSize(expectedHeaderSize, expectedRowSize);
+    }
+
+    private void addArtifactAndOpenGAB(ArtifactInfo art1) throws Exception {
+        addNewArtifact(Collections.singletonList(art1));
+        openGABPopup(art1);
+    }
+
+    private void assertHeaderAndRowSize(int expectedHeaderSize, int expectedRowSize) {
+        List<WebElement> headers = getListOfHeaders();
+        AssertJUnit.assertEquals(expectedHeaderSize, headers.size());
+        List<WebElement> rows = GeneralUIUtils.getWebElementsListByContainsClassName("datatable-body-row");
+        AssertJUnit.assertEquals(expectedRowSize, rows.size());
+    }
+
+    private void openGABPopup(ArtifactInfo art1) throws InterruptedException {
+        SetupCDTest.getExtendTest()
+                .log(Status.INFO, String.format("Clicking on magnifier button %s", art1.getArtifactLabel()));
+        WebElement magnifierButtonElement = GeneralUIUtils.getWebElementByTestID(
+                DataTestIdEnum.ArtifactPageEnum.BROWSE_ARTIFACT.getValue() + art1.getArtifactLabel());
+        SetupCDTest.getExtendTest()
+                .log(Status.INFO, String.format("Found magnifier button: %s", magnifierButtonElement.getText()));
+        magnifierButtonElement.click();
+        Thread.sleep(THREAD_SLEEP_TIME); // have to wait until table will be rendered
+    }
+
+    private List<WebElement> getListOfHeaders() {
+        return GeneralUIUtils.getWebElementsListByClassName("datatable-header-cell");
+    }
+
+    private void addNewArtifact(List<ArtifactInfo> deploymentArtifactList) throws Exception {
+        for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
+            DeploymentArtifactPage.clickAddNewArtifact();
+            ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
+        }
+        AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
+    }
+
+    @Override
+    protected UserRoleEnum getRole() {
+        return UserRoleEnum.DESIGNER;
+    }
+
+}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java
index 51f78f9..1bbebd3 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/Vf.java
@@ -510,34 +510,6 @@
 
     }
 
-    @Test
-    public void addVesEventsDeploymentArtifactToVfAndCheckMagnifierTest() throws Exception {
-        final int expectedHeaderAndRowSize = 3;
-        ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
-        ResourceUIUtils.createVF(vfMetaData, getUser());
-
-        ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
-
-        List<ArtifactInfo> deploymentArtifactList = new ArrayList<>();
-        ArtifactInfo art1 = new ArtifactInfo(filePath, "fm_metadata_three_fault_defs.yml", "desc", "artifactfault", "VES_EVENTS");
-        deploymentArtifactList.add(art1);
-        for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
-            DeploymentArtifactPage.clickAddNewArtifact();
-            ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
-        }
-        AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
-
-        SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on magnifier button %s", art1.getArtifactLabel()));
-        WebElement magnifierButtonElement = GeneralUIUtils.getWebElementByTestID(ArtifactPageEnum.BROWSE_ARTIFACT.getValue() + art1.getArtifactLabel());
-        SetupCDTest.getExtendTest().log(Status.INFO, String.format("Found magnifier button: %s", magnifierButtonElement.getText()));
-        magnifierButtonElement.click();
-        List<WebElement> headers = GeneralUIUtils.getWebElementsListByClassName("datatable-header-cell");
-        AssertJUnit.assertEquals(expectedHeaderAndRowSize, headers.size());
-        headers.get(0).getText();
-        List<WebElement> rows = GeneralUIUtils.getWebElementsListByContainsClassName("datatable-body-row");
-        AssertJUnit.assertEquals(expectedHeaderAndRowSize, rows.size());
-    }
-
     private void takeScreenshot(final String screenshotName, final String errorMsg) {
         try {
             ExtentTestActions.addScreenshot(Status.ERROR, screenshotName, errorMsg);
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java
index d8007c0..586f02c 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/pages/UploadArtifactPopup.java
@@ -54,6 +54,13 @@
         GeneralUIUtils.ultimateWait();
     }
 
+    public void loadUndefinedFile(String path, String filename) {
+        final WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.ArtifactPopup.FILE_UNDEFINED.getValue());
+        SetupCDTest.getExtendTest().log(Status.INFO, String.format("Uploading file: %s", path + File.separator + filename));
+        browseWebElement.sendKeys(path + File.separator + filename);
+        GeneralUIUtils.ultimateWait();
+    }
+
 
     public void insertDescription(String artifactDescriptoin) {
         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Changing artifact description to: %s", artifactDescriptoin));
@@ -76,8 +83,9 @@
         return selectList;
     }
 
-    public Select selectArtifactType(String artifactType) {
-        return GeneralUIUtils.getSelectList(artifactType, DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE.getValue());
+    public void selectArtifactType(String artifactType) {
+        GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ArtifactPopup.ARTIFACT_TYPE_ICON.getValue());
+        GeneralUIUtils.clickOnElementByTestId(artifactType);
     }
 
     public void clickDoneButton() throws Exception {
@@ -86,6 +94,12 @@
         GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), WAITING_FOR_ELEMENT_TIME_OUT);
     }
 
+    public void clickUpgradeArtifactsButton() throws Exception {
+        GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.UPGRADE_ARTIFACT_BUTTON.getValue());
+        GeneralUIUtils.waitForLoader();
+        GeneralUIUtils.waitForElementInVisibilityBy(By.className("sdc-add-artifact"), WAITING_FOR_ELEMENT_TIME_OUT);
+    }
+
     public void clickCancelButton() throws Exception {
         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPopup.CANCEL_BUTTON.getValue()).click();
         GeneralUIUtils.waitForLoader();
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java
index 61a648c..d85e17f 100644
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java
+++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/utilities/ArtifactUIUtils.java
@@ -58,8 +58,8 @@
         artifactPopup.defineArtifactLabel(artifactInfo.getArtifactLabel());
         artifactPopup.selectArtifactType(artifactInfo.getArtifactType());
         artifactPopup.insertDescription(artifactInfo.getDescription());
-        artifactPopup.loadFile(artifactInfo.getFilepath(), artifactInfo.getFilename());
-        artifactPopup.clickDoneButton();
+        artifactPopup.loadUndefinedFile(artifactInfo.getFilepath(), artifactInfo.getFilename());
+        artifactPopup.clickUpgradeArtifactsButton();
         SetupCDTest.getExtendTest().log(Status.INFO, String.format("A new artifact of type %s was added", artifactInfo.getArtifactType()));
     }
 
diff --git a/ui-ci/src/main/resources/ci/testSuites/gabSanity.xml b/ui-ci/src/main/resources/ci/testSuites/gabSanity.xml
new file mode 100644
index 0000000..035bf69
--- /dev/null
+++ b/ui-ci/src/main/resources/ci/testSuites/gabSanity.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="uitests" configfailurepolicy="continue" parallel="methods" thread-count="1"
+       data-provider-thread-count="1">
+
+    <parameter name="makeDistribution" value="false"/>
+
+    <test name="uiSanity">
+        <classes>
+            <class name="org.openecomp.sdc.ci.tests.execute.sanity.GAB"/>
+        </classes>
+    </test>
+</suite>
diff --git a/ui-ci/src/main/resources/ci/testSuites/onapUiSanity.xml b/ui-ci/src/main/resources/ci/testSuites/onapUiSanity.xml
index 0ba4a17..546f269 100644
--- a/ui-ci/src/main/resources/ci/testSuites/onapUiSanity.xml
+++ b/ui-ci/src/main/resources/ci/testSuites/onapUiSanity.xml
@@ -24,6 +24,7 @@
           <include name="onboardPNFSoftwareInformationFlow"/>
         </methods>
       </class>
+      <class name="org.openecomp.sdc.ci.tests.execute.sanity.GAB"/>
     </classes>
   </test>
 </suite>