aboutsummaryrefslogtreecommitdiffstats
path: root/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages
diff options
context:
space:
mode:
Diffstat (limited to 'integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages')
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java74
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java22
2 files changed, 74 insertions, 22 deletions
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
index a46e9a9bee..75f54167ba 100644
--- 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
@@ -20,28 +20,35 @@
package org.onap.sdc.frontend.ci.tests.pages;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.onap.sdc.frontend.ci.tests.pages.PropertyNameBuilder.buildInputField;
+import com.aventstack.extentreports.Status;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-
+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 com.aventstack.extentreports.Status;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
+import org.openqa.selenium.support.ui.Select;
/**
* Handles the Resource Properties Assignment Input Tab UI actions
*/
public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
+ private LoaderHelper loaderHelper;
+ private NotificationComponent notificationComponent;
+
public ResourcePropertiesAssignmentInputTab(final WebDriver webDriver) {
super(webDriver);
+ notificationComponent = new NotificationComponent(webDriver);
+ loaderHelper = new LoaderHelper(webDriver);
}
@Override
@@ -61,8 +68,9 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
/**
* 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 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) {
@@ -83,12 +91,13 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
public 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()));
+ loaderHelper.waitForLoaderInvisibility(20);
+ notificationComponent.waitForNotification(NotificationType.SUCCESS, 20);
}
/**
- * Adds a input
+ * Adds an input
+ *
* @param inputsMap the inputs map to be added
*/
public void addInputs(final Map<String, String> inputsMap) {
@@ -106,6 +115,7 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
/**
* Fills the creation input modal.
+ *
* @param inputName the input name to be created
* @param inputType the input type to be selected
*/
@@ -118,9 +128,10 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
/**
* Verifies if the added input is displayed on the UI.
+ *
* @param inputsMap the input name to be found
*/
- public void verifyInputs(final Map<String, String> inputsMap ) {
+ public void verifyInputs(final Map<String, String> inputsMap) {
for (Map.Entry<String, String> input : inputsMap.entrySet()) {
assertTrue(this.getInputPropertyNames().contains(input.getKey()),
String.format("%s Input should be listed but found %s", input.getKey(),
@@ -129,7 +140,8 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
}
/**
- * Checks if a input exists.
+ * Checks if an input exists.
+ *
* @param inputName the input name
* @return the value of the input
*/
@@ -143,6 +155,40 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
return true;
}
+ public void setInputValue(final String inputName, final Object value) {
+ if (value == null) {
+ return;
+ }
+
+ if (value instanceof String) {
+ setStringInputValue(inputName, (String) value);
+ return;
+ }
+
+ if (value instanceof Integer) {
+ setStringInputValue(inputName, ((Integer) value).toString());
+ return;
+ }
+
+ if (value instanceof Boolean) {
+ setBooleanPropertyValue(inputName, ((Boolean) value).toString());
+ return;
+ }
+
+ throw new UnsupportedOperationException("Cannot set input value of type: " + value.getClass());
+ }
+
+ private void setStringInputValue(final String inputName, final String value) {
+ isInputPropertiesTableLoaded();
+ findElement(By.xpath(XpathSelector.INPUT_VALUE.formatXpath(buildInputField(inputName)))).sendKeys(value);
+ }
+
+ private void setBooleanPropertyValue(final String inputName, final String value) {
+ isInputPropertiesTableLoaded();
+ new Select(findElement(By.xpath(XpathSelector.INPUT_VALUE_BOOLEAN.formatXpath(buildInputField(inputName)))))
+ .selectByVisibleText(value.toUpperCase());
+ }
+
/**
* Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
*/
@@ -160,6 +206,8 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
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")),
INPUT_ADD_BTN("//div[contains(@class,'add-btn')]"),
+ INPUT_VALUE("//input[contains(@class,'value-input') and @data-tests-id='%s']"),
+ INPUT_VALUE_BOOLEAN("//select[@data-tests-id='%s']"),
MODAL_BACKGROUND("//div[@class='modal-background']");
@Getter
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 cb4345c7cc..81c46a7907 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
@@ -45,8 +45,8 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
@Override
public void isLoaded() {
super.isLoaded();
- waitForElementVisibility((By.xpath(XpathSelector.MAIN_DIV.getXpath())));
- waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()));
+ waitForElementVisibility(XpathSelector.MAIN_DIV.getXpath());
+ waitForElementVisibility(XpathSelector.TITLE_DIV.getXpath());
resourcePropertiesAssignmentTab.isLoaded();
}
@@ -54,7 +54,7 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
* Select the Properties Tab to be displayed
*/
public void selectPropertiesTab() {
- findElement(By.xpath(XpathSelector.PROPERTIES_TAB.getXpath())).click();
+ findElement(XpathSelector.PROPERTIES_TAB.getXpath()).click();
resourcePropertiesAssignmentTab.isLoaded();
}
@@ -62,7 +62,7 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
* Select the Input Tab to be displayed
*/
public void selectInputTab() {
- findElement(By.xpath(XpathSelector.INPUT_TAB.getXpath())).click();
+ findElement(XpathSelector.INPUT_TAB.getXpath()).click();
resourcePropertiesAssignmentInputTab.isLoaded();
}
@@ -74,6 +74,10 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
resourcePropertiesAssignmentTab.setPropertyValue(propertyName, value);
}
+ public void setInputValue(final String inputName, final Object value) {
+ resourcePropertiesAssignmentInputTab.setInputValue(inputName, value);
+ }
+
/**
* Retrieves a property value.
*
@@ -130,23 +134,23 @@ public class ResourcePropertiesAssignmentPage extends ComponentPage {
/**
* select property
*/
- public void selectProperty(String propertyName){
+ public void selectProperty(String propertyName) {
resourcePropertiesAssignmentTab.selectProperty(propertyName);
}
- public void loadComponentInstanceProperties(final String instanceName){
+ public void loadComponentInstanceProperties(final String instanceName) {
resourcePropertiesAssignmentTab.loadComponentInstanceProperties(instanceName);
}
- public void clickOnDeclareInput(){
+ public void clickOnDeclareInput() {
resourcePropertiesAssignmentTab.clickOnDeclareInput();
}
- public void loadCompositionTab(){
+ public void loadCompositionTab() {
resourcePropertiesAssignmentTab.loadCompositionTab();
}
- public void clickInputTab(String propertyName){
+ public void clickInputTab(String propertyName) {
waitForElementVisibility(By.xpath(XpathSelector.DECLARE_NOTIFIFICATION.getXpath()));
ExtentTestActions.takeScreenshot(Status.INFO, "Declare-Input", String.format("Added declared input for property %s", propertyName));
selectInputTab();