summaryrefslogtreecommitdiffstats
path: root/integration-tests/src
diff options
context:
space:
mode:
authordavsad <david.sadlier@est.tech>2021-04-28 09:46:46 +0100
committerDavid Sadlier <david.sadlier@est.tech>2021-05-27 23:23:02 +0000
commitf12b2ea0267014cd347ae5f87468b7831fa5ff1b (patch)
tree723d0aaafe0cce7a2b4f26af8cf310629f9d3df7 /integration-tests/src
parent30b974a429821c7a065b393b690e2380afce3284 (diff)
Add IT Tests Adding Metadata to property input
Issue-ID: SDC-3586 Signed-off-by: davsad <david.sadlier@est.tech> Change-Id: I554ff2e226520b1af7af865f394c8af5aaf15469
Diffstat (limited to 'integration-tests/src')
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java24
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java110
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java305
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java351
-rw-r--r--integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml1
5 files changed, 519 insertions, 272 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java
index 79a634e251..2fcd29fc7e 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java
@@ -168,6 +168,28 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
}
@Test(dependsOnMethods = "addRelationshipTemplate")
+ public void createMetadataForServiceProperty() throws Exception {
+ homePage.isLoaded();
+ componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
+ componentPage.isLoaded();
+ final ResourcePropertiesAssignmentPage propertiesAssignmentPage = componentPage.goToPropertiesAssignment();
+
+ propertiesAssignmentPage.isLoaded();
+ propertiesAssignmentPage.selectInputTab();
+ final var propertyName = propertiesAssignmentPage.getInputPropertyNames().get(0);
+ final var key = "Key";
+ final var value = "Test";
+ propertiesAssignmentPage.setInputPropertyMetadata(propertyName, key, value);
+
+ final var topologyTemplate = getMapEntry(downloadToscaTemplate(), "topology_template");
+ final var inputs = getMapEntry(topologyTemplate, "inputs");
+ final var serviceProperty = getMapEntry(inputs, propertyName);
+ final var servicePropertyMetadata = getMapEntry(serviceProperty, "metadata");
+ assertNotNull(servicePropertyMetadata, String.format("Metadata not found for property %s", propertyName));
+ assertEquals(servicePropertyMetadata.get(key), value, "Created service property metadata has invalid value");
+ }
+
+ @Test(dependsOnMethods = "addRelationshipTemplate")
public void addOutputsToVF_test() throws UnzipException, IOException {
homePage.isLoaded();
final ComponentPage resourceCreatePage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
@@ -718,7 +740,7 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
return expectedDefinitionFolderFileList;
}
- private Map<String, Object> getMapEntry(final Map<String, Object> yamlObj, final String entryName) {
+ private Map<String, Object> getMapEntry(final Map<?, ?> yamlObj, final String entryName) {
try {
return (Map<String, Object>) yamlObj.get(entryName);
} catch (final Exception e) {
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java
new file mode 100644
index 0000000000..dedb084147
--- /dev/null
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java
@@ -0,0 +1,110 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.frontend.ci.tests.pages;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+import com.aventstack.extentreports.Status;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Handles the Resource Properties Assignment Input Tab UI actions
+ */
+public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
+
+ public ResourcePropertiesAssignmentInputTab(final WebDriver webDriver) {
+ super(webDriver);
+ }
+
+ @Override
+ public void isLoaded() {
+ waitForElementVisibility(XpathSelector.INPUT_TAB.getXpath());
+ isInputPropertiesTableLoaded();
+ }
+
+ /**
+ * Creates a List of property names from the inputs tab
+ */
+ public List<String> getInputPropertyNames() {
+ isInputPropertiesTableLoaded();
+ final List<WebElement> propertyNames = findElements(By.xpath(XpathSelector.INPUT_PROPERTY_NAME.getXpath()));
+ return propertyNames.stream().map(propertyName -> propertyName.getAttribute("innerText")).collect(Collectors.toList());
+ }
+
+ /**
+ * Adds metadata to a property within the inputs tab based on a property name
+ * @param name used to determine which property to add metadata
+ * @param key the metadata key to add
+ * @param value the metadata value to add
+ */
+ public void setInputPropertyMetadata(String name, String key, String value) {
+ isInputPropertiesTableLoaded();
+ findElement(By.xpath(XpathSelector.INPUT_PROPERTY_ADD_METADATA_BUTTON.formatXpath(name))).click();
+ waitForElementVisibility(XpathSelector.INPUT_PROPERTY_METADATA_KEY_VALUE_PAIR.formatXpath(name));
+ List<WebElement> keyValueInputs = findElements(By.xpath(XpathSelector.INPUT_PROPERTY_METADATA_KEY_VALUE_PAIR.formatXpath(name)));
+ keyValueInputs.get(0).sendKeys(key);
+ keyValueInputs.get(1).sendKeys(value);
+ saveInputProperties();
+ ExtentTestActions.takeScreenshot(Status.INFO, name, String.format("Added metadata for property %s", name));
+ }
+
+ private void isInputPropertiesTableLoaded() {
+ waitForElementVisibility(XpathSelector.PROPERTIES_TABLE.getXpath());
+ waitForElementInvisibility(By.xpath(XpathSelector.NO_DATA_MESSAGE.getXpath()));
+ }
+
+ private void saveInputProperties() {
+ findElement(By.xpath(XpathSelector.PROPERTY_SAVE_BTN.getXpath())).click();
+ waitForElementVisibility(XpathSelector.PROPERTY_SAVE_MESSAGE.getXpath());
+ waitForElementInvisibility(By.xpath(XpathSelector.PROPERTY_SAVE_MESSAGE.getXpath()));
+ }
+
+ /**
+ * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
+ */
+ @AllArgsConstructor
+ @Getter
+ private enum XpathSelector {
+ INPUT_TAB("//*[contains(@data-tests-id, 'Inputs') and contains(@class, 'active')]"),
+ PROPERTIES_TABLE("//div[contains(@class,'properties-table')]"),
+ NO_DATA_MESSAGE("//div[contains(@class,'no-data') and text()='No data to display']"),
+ PROPERTY_SAVE_BTN("//button[@data-tests-id='properties-save-button']"),
+ PROPERTY_SAVE_MESSAGE("//div[contains(text(), 'Successfully saved')]"),
+ INPUT_PROPERTY_NAME("//*[contains(@class, 'property-name')]"),
+ INPUT_PROPERTY_TABLE_ROW("//div[contains(@class, 'table-row') and descendant::*[text() = '%s']]"),
+ INPUT_PROPERTY_ADD_METADATA_BUTTON(INPUT_PROPERTY_TABLE_ROW.getXpath().concat("//a")),
+ INPUT_PROPERTY_METADATA_KEY_VALUE_PAIR(INPUT_PROPERTY_TABLE_ROW.getXpath().concat("//input"));
+
+ private final String xpath;
+
+ public String formatXpath(Object... params) {
+ return String.format(xpath, params);
+ }
+ }
+
+}
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java
index dcc26121e3..e69f1131e5 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java
@@ -19,302 +19,82 @@
package org.onap.sdc.frontend.ci.tests.pages;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import com.aventstack.extentreports.Status;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
-import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper;
-import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent;
-import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.NotificationType;
+
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.Select;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
/**
- * Handles the Resource Properties Assignment Page UI actions
+ * Handles the Resource Properties Assignment Page UI actions.
*/
public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
- private WebElement wrappingElement;
- private LoaderHelper loaderHelper;
- private NotificationComponent notificationComponent;
+ private ResourcePropertiesAssignmentTab resourcePropertiesAssignmentTab;
+ private ResourcePropertiesAssignmentInputTab resourcePropertiesAssignmentInputTab;
public ResourcePropertiesAssignmentPage(final WebDriver webDriver) {
super(webDriver);
- notificationComponent = new NotificationComponent(webDriver);
- loaderHelper = new LoaderHelper(webDriver);
+ resourcePropertiesAssignmentTab = new ResourcePropertiesAssignmentTab(webDriver);
+ resourcePropertiesAssignmentInputTab = new ResourcePropertiesAssignmentInputTab(webDriver);
}
@Override
public void isLoaded() {
- wrappingElement = getWait(5)
- .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.MAIN_DIV.getXpath())));
- getWait(5)
- .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(XpathSelector.TITLE_DIV.getXpath())));
- }
-
- /**
- * Gets the software_version property values.
- *
- * @return the list of software versions found
- */
- public List<String> getSoftwareVersionProperty() {
- waitPropertiesToLoad();
- final By swVersionCheckboxLocator = By.xpath(XpathSelector.SOFTWARE_VERSION_PROPERTY_CHECKBOX.getXpath());
- waitForElementVisibility(swVersionCheckboxLocator, 5);
-
- final List<String> softwareVersionList = new ArrayList<>();
- final List<WebElement> elements = wrappingElement.findElements(By.xpath(XpathSelector.SOFTWARE_VERSION_INPUT.getXpath()));
- for (final WebElement element : elements) {
- softwareVersionList.add(element.getAttribute("value"));
- }
-
- return softwareVersionList;
- }
-
- /**
- * Gets the property row element for the given propertyName
- * @param propertyName the property name
- * @return the property row element
- */
- private WebElement getPropertyRow(String propertyName) {
- final By propertyCheckboxLocator = By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName));
- final WebElement propertyCheckbox = waitForElementVisibility(propertyCheckboxLocator, 5);
- return propertyCheckbox.findElement(By.xpath("./../../.."));
+ waitForElementVisibility((By.xpath(XpathSelector.MAIN_DIV.getXpath())));
+ waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()));
+ resourcePropertiesAssignmentTab.isLoaded();
}
/**
- * Gets the value of a string TOSCA property.
- * @return the value of the property
+ * Select the Properties Tab to be displayed
*/
- public String getStringPropertyValue(final String propertyName) {
- waitPropertiesToLoad();
- final WebElement propertyInput = getPropertyRow(propertyName).findElement(By.xpath(XpathSelector.INPUT_PROPERTY.getXpath(propertyName)));
- return propertyInput.getAttribute("value");
+ public void selectPropertiesTab() {
+ findElement(By.xpath(XpathSelector.PROPERTIES_TAB.getXpath())).click();
+ resourcePropertiesAssignmentTab.isLoaded();
}
/**
- * Sets a String value to a TOSCA property.
- * @param propertyName the property name
- * @param value property value to be set
+ * Select the Input Tab to be displayed
*/
- public void setStringPropertyValue(final String propertyName, final String value) {
- if (value == null) {
- return;
- }
- waitPropertiesToLoad();
- getPropertyRow(propertyName).findElement(By.xpath(XpathSelector.INPUT_PROPERTY.getXpath(propertyName))).sendKeys(value);
- }
-
- /**
- * Sets a boolean value to a TOSCA property.
- * @param propertyName
- */
- private void setBooleanPropertyValue(final String propertyName) {
- waitPropertiesToLoad();
- new Select(getPropertyRow(propertyName).findElement(By.xpath(XpathSelector.SELECT_INPUT_PROPERTY.getXpath(propertyName)))).
- selectByVisibleText("TRUE");
+ public void selectInputTab() {
+ findElement(By.xpath(XpathSelector.INPUT_TAB.getXpath())).click();
+ resourcePropertiesAssignmentInputTab.isLoaded();
}
- /**
- * Sets a complex property type value to a TOSCA property. It handles List and Map
- * @param propertyName the property name
- * @param objectValue the property complex type value
- */
- public void setComplexPropertyValue(final String propertyName, final Object objectValue) {
- if (objectValue == null) {
- return;
- }
- waitPropertiesToLoad();
- final WebElement addToListLink = getPropertyRow(propertyName)
- .findElement(By.xpath(XpathSelector.PROPERTY_ADD_VALUE_COMPLEX_TYPE.getXpath(propertyName)));
- if (objectValue instanceof List) {
- setValueFromList(propertyName, (List<String>) objectValue, addToListLink);
- }
- if (objectValue instanceof Map) {
- setValueFromMap(propertyName, (Map) objectValue, addToListLink);
- }
- }
-
- /**
- * Sets a value to a complex (List) property type.
- * @param propertyName the property name
- * @param values the List of values to be added to the given property name
- * @param addToListLink the link to add the input value
- */
- private void setValueFromList(final String propertyName, final List<String> values, final WebElement addToListLink) {
- AtomicInteger inputIndex = new AtomicInteger(0);
- values.forEach(value -> {
- addToListLink.click();
- final WebElement propertyInput = addToListLink.findElement(By.xpath(XpathSelector.INPUT_PROPERTY_COMPLEX_TYPE_VALUE.getXpath(
- String.valueOf(new StringBuilder(propertyName).append(".").append(inputIndex)))));
- propertyInput.sendKeys(value);
- inputIndex.getAndIncrement();
- });
- }
-
- /**
- * Sets a value to a complex (Map) property type.
- * @param propertyName the property name
- * @param values the Map of values to be added to the given property name
- * @param addToListLink the link to add the input value
- */
- private void setValueFromMap(final String propertyName, final Map values, final WebElement addToListLink) {
- AtomicInteger inputIndex = new AtomicInteger(0);
- values.forEach((key, value) -> {
- addToListLink.click();
- WebElement propertyInput;
- // Add Key
- propertyInput = addToListLink.findElement(By.xpath(XpathSelector.INPUT_PROPERTY_COMPLEX_TYPE_KEY.getXpath(
- String.valueOf(new StringBuilder(propertyName).append(".").append(inputIndex)))));
- propertyInput.sendKeys(key.toString());
- // Add Value
- propertyInput = addToListLink.findElement(By.xpath(XpathSelector.INPUT_PROPERTY_COMPLEX_TYPE_VALUE.getXpath(
- String.valueOf(new StringBuilder(propertyName).append(".").append(inputIndex)))));
- propertyInput.sendKeys(value.toString());
- inputIndex.getAndIncrement();
- });
+ public List<String> getSoftwareVersionProperty() {
+ return resourcePropertiesAssignmentTab.getSoftwareVersionProperty();
}
- /**
- * Sets a property value
- * @param propertyName the property name
- * @param value the property value
- */
public void setPropertyValue(final String propertyName, final Object value) {
- if (value == null) {
- return;
- }
-
- if (value instanceof String) {
- setStringPropertyValue(propertyName, (String) value);
- return;
- }
-
- if (value instanceof Integer) {
- setStringPropertyValue(propertyName, ((Integer) value).toString());
- return;
- }
-
- if (value instanceof Boolean) {
- setBooleanPropertyValue(propertyName);
- return;
- }
-
- if (value instanceof Map) {
- setComplexPropertyValue(propertyName, value);
- return;
- }
-
- if (value instanceof List) {
- setComplexPropertyValue(propertyName, value);
- return;
- }
-
- throw new UnsupportedOperationException("Cannot set property value of type: " + value.getClass());
+ resourcePropertiesAssignmentTab.setPropertyValue(propertyName, value);
}
- /**
- * Checks if a property exists.
- * @param propertyName the property name
- * @return the value of the property
- */
public boolean isPropertyPresent(final String propertyName) {
- waitPropertiesToLoad();
- try {
- waitForElementVisibility(By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName)), 5);
- } catch (final Exception ignored) {
- return false;
- }
- return true;
- }
-
- /**
- * Waits for the properties loading.
- */
- private void waitPropertiesToLoad() {
- waitForElementVisibility(By.xpath(XpathSelector.PROPERTIES_TABLE.getXpath()), 5);
- waitForElementInvisibility(By.xpath(XpathSelector.NO_DATA_MESSAGE.getXpath()), 5);
+ return resourcePropertiesAssignmentTab.isPropertyPresent(propertyName);
}
- /**
- * Saves a property
- */
public void saveProperties() {
- final WebElement saveBtn = waitForElementVisibility(By.xpath(XpathSelector.PROPERTY_SAVE_BTN.getXpath()));
- assertTrue(saveBtn.isEnabled(), "Property save button should be enabled.");
- saveBtn.click();
- loaderHelper.waitForLoaderInvisibility(20);
- notificationComponent.waitForNotification(NotificationType.SUCCESS, 20);
+ resourcePropertiesAssignmentTab.saveProperties();
}
- /**
- * Adds a property
- * @param propertiesMap the properties map to be added
- */
public void addProperties(final Map<String, String> propertiesMap) {
- waitPropertiesToLoad();
- propertiesMap.forEach((propertyName, propertyType) -> {
- final By addPropertyButtonLocator = By.xpath(XpathSelector.PROPERTY_ADD_BTN.getXpath());
- waitForElementVisibility(addPropertyButtonLocator, 30);
- final WebElement addPropertyRightColumn = findElement(By.xpath(XpathSelector.PROPERTY_ADD_RIGHT_COLUMN_DIV.getXpath()));
- final WebElement propertyAddButton = addPropertyRightColumn.findElement(addPropertyButtonLocator);
- assertTrue(propertyAddButton.isDisplayed(), "Property add button should be enabled.");
- propertyAddButton.click();
- createProperty(propertyName, propertyType);
- verifyProperty(propertyName);
- ExtentTestActions.takeScreenshot(Status.INFO, "added-property",
- String.format("Property '%s' was created on component", propertyName));
- });
+ resourcePropertiesAssignmentTab.addProperties(propertiesMap);
}
- /**
- * Fills the creation property modal.
- * @param propertyName the property name to be created
- * @param propertyType the property type to be selected
- */
- private void createProperty(final String propertyName, final String propertyType) {
- final AddPropertyModal addPropertyModal = new AddPropertyModal(webDriver);
- addPropertyModal.isLoaded();
- addPropertyModal.fillPropertyForm(propertyName, propertyType);
- addPropertyModal.clickOnCreate();
+ public Map<String, String> getPropertyNamesAndTypes() {
+ return resourcePropertiesAssignmentTab.getPropertyNamesAndTypes();
}
- /**
- * Verifies if the added property is displayed on the UI.
- * @param propertyName the property name to be found
- */
- private void verifyProperty(final String propertyName) {
- final By propertyCheckboxLocator = By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName));
- final WebElement propertyCheckbox = waitForElementVisibility(propertyCheckboxLocator, 5);
- assertTrue(propertyCheckbox.isDisplayed(), String.format("%s Property should be displayed", propertyName));
- assertTrue(this.getPropertyNamesAndTypes().containsKey(propertyName),
- String.format("%s Property should be listed but found %s", propertyName, this.getPropertyNamesAndTypes().toString()));
+ public void setInputPropertyMetadata(String name, String key, String value) {
+ resourcePropertiesAssignmentInputTab.setInputPropertyMetadata(name, key, value);
}
- /**
- * Creates a map based on property names and data types
- */
- public Map<String, String> getPropertyNamesAndTypes() {
- waitPropertiesToLoad();
- final Map<String, String> namesAndTypes = new HashMap<>();
- final List<WebElement> names = findElements(By.xpath(XpathSelector.PROPERTY_NAMES.getXpath()));
- final List<WebElement> types = findElements(By.xpath(XpathSelector.PROPERTY_TYPES.getXpath()));
-
- for (int i = 0;i < names.size();i++) {
- namesAndTypes.put(names.get(i).getAttribute("innerText"), types.get(i).getAttribute("innerText"));
- }
-
- return namesAndTypes;
+ public List<String> getInputPropertyNames() {
+ return resourcePropertiesAssignmentInputTab.getInputPropertyNames();
}
/**
@@ -324,21 +104,8 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
private enum XpathSelector {
MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'Properties Assignment')]"),
- PROPERTIES_TABLE("properties-table", "//div[contains(@class,'%s')]"),
- NO_DATA_MESSAGE("no-data", "//div[contains(@class,'%s') and text()='No data to display']"),
- SOFTWARE_VERSION_PROPERTY_CHECKBOX("software_versions", "//checkbox[@data-tests-id='%s']"),
- SOFTWARE_VERSION_INPUT("value-prop-software_versions", "//input[starts-with(@data-tests-id,'%s')]"),
- PROPERTY_CHECKBOX("//checkbox[@data-tests-id='%s']"),
- PROPERTY_SAVE_BTN("properties-save-button", "//button[@data-tests-id='%s']"),
- PROPERTY_ADD_RIGHT_COLUMN_DIV("right-column", "//div[@class='%s']"),
- PROPERTY_ADD_BTN("add-btn", "//div[contains(@class,'%s')]"),
- PROPERTY_ADD_VALUE_COMPLEX_TYPE("//a[contains(@data-tests-id, 'add-to-list-%s')]"),
- INPUT_PROPERTY_COMPLEX_TYPE_KEY("//input[contains(@data-tests-id, 'value-prop-key-%s')]"),
- INPUT_PROPERTY_COMPLEX_TYPE_VALUE("//input[contains(@data-tests-id, 'value-prop-%s')]"),
- INPUT_PROPERTY("//input[@data-tests-id='value-prop-%s']"),
- SELECT_INPUT_PROPERTY("//select[@data-tests-id='value-prop-%s']"),
- PROPERTY_TYPES("//*[contains(@data-tests-id, 'propertyType')]"),
- PROPERTY_NAMES("//*[contains(@data-tests-id, 'propertyName')]");
+ PROPERTIES_TAB("//*[contains(@data-tests-id, 'Properties') and contains(@class, 'tab')]"),
+ INPUT_TAB("//*[contains(@data-tests-id, 'Inputs') and contains(@class, 'tab')]");
@Getter
private String id;
@@ -351,10 +118,6 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
public String getXpath() {
return String.format(xpathFormat, id);
}
-
- public String getXpath(final String... xpathParams) {
- return String.format(xpathFormat, xpathParams);
- }
}
}
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java
new file mode 100644
index 0000000000..b237b17272
--- /dev/null
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java
@@ -0,0 +1,351 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.frontend.ci.tests.pages;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
+import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper;
+import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent;
+import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.NotificationType;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.Select;
+
+import com.aventstack.extentreports.Status;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * Handles the Resource Properties Assignment Properties Tab UI actions
+ */
+public class ResourcePropertiesAssignmentTab extends AbstractPageObject {
+
+ private WebElement wrappingElement;
+ private LoaderHelper loaderHelper;
+ private NotificationComponent notificationComponent;
+
+ public ResourcePropertiesAssignmentTab(final WebDriver webDriver) {
+ super(webDriver);
+ notificationComponent = new NotificationComponent(webDriver);
+ loaderHelper = new LoaderHelper(webDriver);
+ }
+
+ @Override
+ public void isLoaded() {
+ wrappingElement = waitForElementVisibility(XpathSelector.MAIN_DIV.getXpath());
+ waitForElementVisibility(XpathSelector.PROPERTIES_TAB.getXpath());
+ isPropertiesTableLoaded();
+ }
+
+ /**
+ * Waits for the table of properties to load
+ */
+ private void isPropertiesTableLoaded() {
+ waitForElementVisibility(By.xpath(XpathSelector.PROPERTIES_TABLE.getXpath()), 5);
+ waitForElementInvisibility(By.xpath(XpathSelector.NO_DATA_MESSAGE.getXpath()), 5);
+ }
+
+ /**
+ * Gets the software_version property values.
+ *
+ * @return the list of software versions found
+ */
+ public List<String> getSoftwareVersionProperty() {
+ isPropertiesTableLoaded();
+ final By swVersionCheckboxLocator = By.xpath(XpathSelector.SOFTWARE_VERSION_PROPERTY_CHECKBOX.getXpath());
+ waitForElementVisibility(swVersionCheckboxLocator, 5);
+
+ final List<String> softwareVersionList = new ArrayList<>();
+ final List<WebElement> elements = wrappingElement.findElements(By.xpath(XpathSelector.SOFTWARE_VERSION_INPUT.getXpath()));
+ for (final WebElement element : elements) {
+ softwareVersionList.add(element.getAttribute("value"));
+ }
+
+ return softwareVersionList;
+ }
+
+ /**
+ * Sets a property value
+ * @param propertyName the property name
+ * @param value the property value
+ */
+ public void setPropertyValue(final String propertyName, final Object value) {
+ if (value == null) {
+ return;
+ }
+
+ if (value instanceof String) {
+ setStringPropertyValue(propertyName, (String) value);
+ return;
+ }
+
+ if (value instanceof Integer) {
+ setStringPropertyValue(propertyName, ((Integer) value).toString());
+ return;
+ }
+
+ if (value instanceof Boolean) {
+ setBooleanPropertyValue(propertyName);
+ return;
+ }
+
+ if (value instanceof Map) {
+ setComplexPropertyValue(propertyName, value);
+ return;
+ }
+
+ if (value instanceof List) {
+ setComplexPropertyValue(propertyName, value);
+ return;
+ }
+
+ throw new UnsupportedOperationException("Cannot set property value of type: " + value.getClass());
+ }
+
+ /**
+ * Checks if a property exists.
+ * @param propertyName the property name
+ * @return the value of the property
+ */
+ public boolean isPropertyPresent(final String propertyName) {
+ isPropertiesTableLoaded();
+ try {
+ waitForElementVisibility(By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName)), 5);
+ } catch (final Exception ignored) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Saves a property
+ */
+ public void saveProperties() {
+ final WebElement saveBtn = waitForElementVisibility(By.xpath(XpathSelector.PROPERTY_SAVE_BTN.getXpath()));
+ assertTrue(saveBtn.isEnabled(), "Property save button should be enabled.");
+ saveBtn.click();
+ loaderHelper.waitForLoaderInvisibility(20);
+ notificationComponent.waitForNotification(NotificationType.SUCCESS, 20);
+ }
+
+ /**
+ * Adds a property
+ * @param propertiesMap the properties map to be added
+ */
+ public void addProperties(final Map<String, String> propertiesMap) {
+ isPropertiesTableLoaded();
+ propertiesMap.forEach((propertyName, propertyType) -> {
+ final By addPropertyButtonLocator = By.xpath(XpathSelector.PROPERTY_ADD_BTN.getXpath());
+ waitForElementVisibility(addPropertyButtonLocator, 30);
+ final WebElement addPropertyRightColumn = findElement(By.xpath(XpathSelector.PROPERTY_ADD_RIGHT_COLUMN_DIV.getXpath()));
+ final WebElement propertyAddButton = addPropertyRightColumn.findElement(addPropertyButtonLocator);
+ assertTrue(propertyAddButton.isDisplayed(), "Property add button should be enabled.");
+ propertyAddButton.click();
+ createProperty(propertyName, propertyType);
+ verifyProperty(propertyName);
+ ExtentTestActions.takeScreenshot(Status.INFO, "added-property",
+ String.format("Property '%s' was created on component", propertyName));
+ });
+ }
+
+ /**
+ * Creates a map based on property names and data types
+ */
+ public Map<String, String> getPropertyNamesAndTypes() {
+ isPropertiesTableLoaded();
+ final Map<String, String> namesAndTypes = new HashMap<>();
+ final List<WebElement> names = findElements(By.xpath(XpathSelector.PROPERTY_NAMES.getXpath()));
+ final List<WebElement> types = findElements(By.xpath(XpathSelector.PROPERTY_TYPES.getXpath()));
+
+ for (int i = 0;i < names.size();i++) {
+ namesAndTypes.put(names.get(i).getAttribute("innerText"), types.get(i).getAttribute("innerText"));
+ }
+
+ return namesAndTypes;
+ }
+
+ /**
+ * Gets the property row element for the given propertyName
+ * @param propertyName the property name
+ * @return the property row element
+ */
+ private WebElement getPropertyRow(String propertyName) {
+ final By propertyCheckboxLocator = By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName));
+ final WebElement propertyCheckbox = waitForElementVisibility(propertyCheckboxLocator, 5);
+ return propertyCheckbox.findElement(By.xpath("./../../.."));
+ }
+
+ /**
+ * Sets a String value to a TOSCA property.
+ * @param propertyName the property name
+ * @param value property value to be set
+ */
+ private void setStringPropertyValue(final String propertyName, final String value) {
+ if (value == null) {
+ return;
+ }
+ isPropertiesTableLoaded();
+ getPropertyRow(propertyName).findElement(By.xpath(XpathSelector.INPUT_PROPERTY.getXpath(propertyName))).sendKeys(value);
+ }
+
+ /**
+ * Sets a boolean value to a TOSCA property.
+ * @param propertyName
+ */
+ private void setBooleanPropertyValue(final String propertyName) {
+ isPropertiesTableLoaded();
+ new Select(getPropertyRow(propertyName).findElement(By.xpath(XpathSelector.SELECT_INPUT_PROPERTY.getXpath(propertyName)))).
+ selectByVisibleText("TRUE");
+ }
+
+ /**
+ * Sets a complex property type value to a TOSCA property. It handles List and Map
+ * @param propertyName the property name
+ * @param objectValue the property complex type value
+ */
+ private void setComplexPropertyValue(final String propertyName, final Object objectValue) {
+ if (objectValue == null) {
+ return;
+ }
+ isPropertiesTableLoaded();
+ final WebElement addToListLink = getPropertyRow(propertyName)
+ .findElement(By.xpath(XpathSelector.PROPERTY_ADD_VALUE_COMPLEX_TYPE.getXpath(propertyName)));
+ if (objectValue instanceof List) {
+ setValueFromList(propertyName, (List) objectValue, addToListLink);
+ }
+ if (objectValue instanceof Map) {
+ setValueFromMap(propertyName, (Map<?, ?>) objectValue, addToListLink);
+ }
+ }
+
+ /**
+ * Sets a value to a complex (List) property type.
+ * @param propertyName the property name
+ * @param values the List of values to be added to the given property name
+ * @param addToListLink the link to add the input value
+ */
+ private void setValueFromList(final String propertyName, final List<String> values, final WebElement addToListLink) {
+ final AtomicInteger inputIndex = new AtomicInteger(0);
+ values.forEach(value -> {
+ addToListLink.click();
+ final WebElement propertyInput = addToListLink.findElement(By.xpath(XpathSelector.INPUT_PROPERTY_COMPLEX_TYPE_VALUE.getXpath(
+ String.valueOf(new StringBuilder(propertyName).append(".").append(inputIndex)))));
+ propertyInput.sendKeys(value);
+ inputIndex.getAndIncrement();
+ });
+ }
+
+ /**
+ * Sets a value to a complex (Map) property type.
+ * @param propertyName the property name
+ * @param values the Map of values to be added to the given property name
+ * @param addToListLink the link to add the input value
+ */
+ private void setValueFromMap(final String propertyName, final Map<?, ?> values, final WebElement addToListLink) {
+ final AtomicInteger inputIndex = new AtomicInteger(0);
+ values.forEach((key, value) -> {
+ addToListLink.click();
+ WebElement propertyInput;
+ // Add Key
+ propertyInput = addToListLink.findElement(By.xpath(XpathSelector.INPUT_PROPERTY_COMPLEX_TYPE_KEY.getXpath(
+ String.valueOf(new StringBuilder(propertyName).append(".").append(inputIndex)))));
+ propertyInput.sendKeys(key.toString());
+ // Add Value
+ propertyInput = addToListLink.findElement(By.xpath(XpathSelector.INPUT_PROPERTY_COMPLEX_TYPE_VALUE.getXpath(
+ String.valueOf(new StringBuilder(propertyName).append(".").append(inputIndex)))));
+ propertyInput.sendKeys(value.toString());
+ inputIndex.getAndIncrement();
+ });
+ }
+
+ /**
+ * Fills the creation property modal.
+ * @param propertyName the property name to be created
+ * @param propertyType the property type to be selected
+ */
+ private void createProperty(final String propertyName, final String propertyType) {
+ final AddPropertyModal addPropertyModal = new AddPropertyModal(webDriver);
+ addPropertyModal.isLoaded();
+ addPropertyModal.fillPropertyForm(propertyName, propertyType);
+ addPropertyModal.clickOnCreate();
+ }
+
+ /**
+ * Verifies if the added property is displayed on the UI.
+ * @param propertyName the property name to be found
+ */
+ private void verifyProperty(final String propertyName) {
+ final By propertyCheckboxLocator = By.xpath(XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName));
+ final WebElement propertyCheckbox = waitForElementVisibility(propertyCheckboxLocator, 5);
+ assertTrue(propertyCheckbox.isDisplayed(), String.format("%s Property should be displayed", propertyName));
+ assertTrue(this.getPropertyNamesAndTypes().containsKey(propertyName),
+ String.format("%s Property should be listed but found %s", propertyName, this.getPropertyNamesAndTypes().toString()));
+ }
+
+ /**
+ * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
+ */
+ @AllArgsConstructor
+ private enum XpathSelector {
+ MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
+ PROPERTIES_TAB("//*[contains(@data-tests-id, 'Properties') and contains(@class, 'active')]"),
+ PROPERTIES_TABLE("properties-table", "//div[contains(@class,'%s')]"),
+ NO_DATA_MESSAGE("no-data", "//div[contains(@class,'%s') and text()='No data to display']"),
+ SOFTWARE_VERSION_PROPERTY_CHECKBOX("software_versions", "//checkbox[@data-tests-id='%s']"),
+ SOFTWARE_VERSION_INPUT("value-prop-software_versions", "//input[starts-with(@data-tests-id,'%s')]"),
+ PROPERTY_CHECKBOX("//checkbox[@data-tests-id='%s']"),
+ PROPERTY_SAVE_BTN("properties-save-button", "//button[@data-tests-id='%s']"),
+ PROPERTY_ADD_RIGHT_COLUMN_DIV("right-column", "//div[@class='%s']"),
+ PROPERTY_ADD_BTN("add-btn", "//div[contains(@class,'%s')]"),
+ PROPERTY_ADD_VALUE_COMPLEX_TYPE("//a[contains(@data-tests-id, 'add-to-list-%s')]"),
+ INPUT_PROPERTY_COMPLEX_TYPE_KEY("//input[contains(@data-tests-id, 'value-prop-key-%s')]"),
+ INPUT_PROPERTY_COMPLEX_TYPE_VALUE("//input[contains(@data-tests-id, 'value-prop-%s')]"),
+ INPUT_PROPERTY("//input[@data-tests-id='value-prop-%s']"),
+ SELECT_INPUT_PROPERTY("//select[@data-tests-id='value-prop-%s']"),
+ PROPERTY_TYPES("//*[contains(@data-tests-id, 'propertyType')]"),
+ PROPERTY_NAMES("//*[contains(@data-tests-id, 'propertyName')]");
+
+ @Getter
+ private String id;
+ private final String xpathFormat;
+
+ XpathSelector(final String xpathFormat) {
+ this.xpathFormat = xpathFormat;
+ }
+
+ public String getXpath() {
+ return String.format(xpathFormat, id);
+ }
+
+ public String getXpath(final Object... xpathParams) {
+ return String.format(xpathFormat, xpathParams);
+ }
+ }
+
+}
diff --git a/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml b/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml
index 8c75510a15..ce2436e796 100644
--- a/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml
+++ b/integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml
@@ -44,6 +44,7 @@
<include name="createSubstitutionFilter"/>
<include name="createDirectiveNodeFilterTest"/>
<include name="updateInterfaceOperation"/>
+ <include name="createMetadataForServiceProperty"/>
</methods>
</class>
</classes>