aboutsummaryrefslogtreecommitdiffstats
path: root/integration-tests/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'integration-tests/src/test/java')
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java41
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddComponentInputFlow.java60
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java52
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java12
4 files changed, 162 insertions, 3 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 2a803ea298..e944ab329a 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
@@ -58,6 +58,7 @@ import org.onap.sdc.frontend.ci.tests.exception.UnzipException;
import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory;
import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
+import org.onap.sdc.frontend.ci.tests.flow.AddComponentInputFlow;
import org.onap.sdc.frontend.ci.tests.flow.AddComponentPropertyFlow;
import org.onap.sdc.frontend.ci.tests.flow.AddNodeToCompositionFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateDirectiveNodeFilterFlow;
@@ -108,6 +109,7 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
private ComponentPage componentPage;
private Map<String, String> propertiesToBeAddedMap;
private ResourceCreatePage resourceCreatePage;
+ private Map<String, String> inputsToBeAddedMap;
private final List<ServiceDependencyProperty> substitutionFilterProperties = new ArrayList<>();
private final String interfaceName = "Standard";
private final String interfaceOperationName = "create";
@@ -321,6 +323,13 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
verifyToscaTemplateHasDeclareInput(downloadToscaTemplate());
}
+ @Test(dependsOnMethods = "createBaseService")
+ public void addComponentInputs() throws Exception {
+ inputsToBeAddedMap = loadInputsToAdd();
+ addInput(inputsToBeAddedMap);
+ verifyToscaTemplateAddInput(downloadToscaTemplate());
+ }
+
private void checkMetadata(final Map<String, Object> map, final ResourceCreateData createdData) {
final Map<String, Object> metadata = getMapEntry(map, "metadata");
@@ -602,6 +611,17 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
}
/**
+ * Adds a input to the base service
+ * @param inputMap map of inputs to be added
+ */
+ private void addInput(final Map<String, String> inputMap) {
+ componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
+ componentPage.isLoaded();
+ final AddComponentInputFlow addComponentInputFlow = new AddComponentInputFlow(webDriver, inputMap);
+ addComponentInputFlow.run(componentPage.goToPropertiesAssignment());
+ }
+
+ /**
* Edits a property to add a value
* @param propertyMap map of properties to be edited
*/
@@ -790,6 +810,19 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
.filter(s -> (s.contains("resourceSubtype") || s.contains("property1"))).count());
}
+ private void verifyToscaTemplateAddInput(Map<?, ?> yaml) {
+ final Map<String, String> inputMap = loadInputsToAdd();
+ assertNotNull(yaml, "No contents in TOSCA Template");
+ final Map<String, Object> toscaYaml = (Map<String, Object>) yaml;
+ final Map<String, Object> topologyTemplateTosca = getMapEntry(toscaYaml, "topology_template");
+ assertThat(String.format("'%s' should contain a topology_template entry", toscaYaml), topologyTemplateTosca,
+ notNullValue());
+ final Map<String, Object> inputsTosca = getMapEntry(topologyTemplateTosca, "inputs");
+ assertThat(String.format("'%s' should contain a inputs entry", toscaYaml), inputsTosca, notNullValue());
+ assertEquals(3, inputsTosca.keySet().stream()
+ .filter(s -> inputMap.containsKey(s)).count());
+ }
+
private Map<String, Object> getMapEntry(final Map<?, ?> yamlObj, final String entryName) {
try {
return (Map<String, Object>) yamlObj.get(entryName);
@@ -831,6 +864,14 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
return propertyMap;
}
+ private Map<String, String> loadInputsToAdd() {
+ final Map<String, String> inputMap = new HashMap<>();
+ inputMap.put("input1", "string");
+ inputMap.put("input2", "integer");
+ inputMap.put("input3", "boolean");
+ return inputMap;
+ }
+
private void loadSubstitutionFilterProperties() {
final ResourcePropertiesAssignmentPage propertiesPage = componentPage.goToPropertiesAssignment();
propertiesPage.isLoaded();
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddComponentInputFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddComponentInputFlow.java
new file mode 100644
index 0000000000..57c45fe986
--- /dev/null
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddComponentInputFlow.java
@@ -0,0 +1,60 @@
+/*
+ * ============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.flow;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import com.aventstack.extentreports.Status;
+import java.util.Map;
+import java.util.Optional;
+import org.apache.commons.collections4.MapUtils;
+import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
+import org.onap.sdc.frontend.ci.tests.pages.PageObject;
+import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage;
+import org.openqa.selenium.WebDriver;
+
+public class AddComponentInputFlow extends AbstractUiTestFlow {
+
+ private final Map<String, String> inputsMap;
+ private ResourcePropertiesAssignmentPage resourcePropertiesAssignmentPage;
+
+ public AddComponentInputFlow(final WebDriver webDriver, final Map<String, String> inputsMap) {
+ super(webDriver);
+ this.inputsMap = inputsMap;
+ }
+
+ @Override
+ public Optional<ResourcePropertiesAssignmentPage> run(final PageObject... pageObjects) {
+ resourcePropertiesAssignmentPage = findParameter(pageObjects, ResourcePropertiesAssignmentPage.class);
+ if (MapUtils.isEmpty(inputsMap)) {
+ return Optional.of(resourcePropertiesAssignmentPage);
+ }
+ resourcePropertiesAssignmentPage.isLoaded();
+ resourcePropertiesAssignmentPage.selectInputTab();
+ final String inputsNames = String.join(", ", inputsMap.keySet());
+ extendTest.log(Status.INFO, "Adding inputs " + inputsNames);
+ resourcePropertiesAssignmentPage.addInputs(inputsMap);
+ resourcePropertiesAssignmentPage.verifyInputs(inputsMap);
+ ExtentTestActions.takeScreenshot(Status.INFO, "added-inputs", String.format("Inputs added: %s", inputsNames));
+ return Optional.of(this.resourcePropertiesAssignmentPage);
+ }
+
+ @Override
+ public Optional<ResourcePropertiesAssignmentPage> getLandedPage() { return Optional.ofNullable(resourcePropertiesAssignmentPage); }
+}
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 d1b07dc32f..a46e9a9bee 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
@@ -19,7 +19,10 @@
package org.onap.sdc.frontend.ci.tests.pages;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
@@ -78,15 +81,56 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
waitForElementInvisibility(By.xpath(XpathSelector.NO_DATA_MESSAGE.getXpath()));
}
- private void saveInputProperties() {
+ 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()));
}
/**
+ * Adds a input
+ * @param inputsMap the inputs map to be added
+ */
+ public void addInputs(final Map<String, String> inputsMap) {
+ isInputPropertiesTableLoaded();
+ inputsMap.forEach((inputName, inputType) -> {
+ WebElement inputAddButton = findElement(By.xpath(XpathSelector.INPUT_ADD_BTN.getXpath()));
+ assertTrue(inputAddButton.isDisplayed());
+ inputAddButton.click();
+ createInput(inputName, inputType);
+ waitForElementInvisibility(By.xpath(XpathSelector.MODAL_BACKGROUND.getXpath()), 5);
+ ExtentTestActions.takeScreenshot(Status.INFO, "added-input",
+ String.format("Input '%s' was created on component", inputName));
+ });
+ }
+
+ /**
+ * Fills the creation input modal.
+ * @param inputName the input name to be created
+ * @param inputType the input type to be selected
+ */
+ private void createInput(final String inputName, final String inputType) {
+ final AddPropertyModal addInputModal = new AddPropertyModal(webDriver);
+ addInputModal.isLoaded();
+ addInputModal.fillPropertyForm(inputName, inputType);
+ addInputModal.clickOnCreate();
+ }
+
+ /**
+ * 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 ) {
+ 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(),
+ this.getInputPropertyNames().toString()));
+ }
+ }
+
+ /**
* Checks if a input exists.
- * @param inputName the property name
+ * @param inputName the input name
* @return the value of the input
*/
public boolean isInputPresent(final String inputName) {
@@ -114,7 +158,9 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
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"));
+ INPUT_PROPERTY_METADATA_KEY_VALUE_PAIR(INPUT_PROPERTY_TABLE_ROW.getXpath().concat("//input")),
+ INPUT_ADD_BTN("//div[contains(@class,'add-btn')]"),
+ MODAL_BACKGROUND("//div[@class='modal-background']");
@Getter
private final String xpath;
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 4db048be09..12ac5e492a 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
@@ -90,10 +90,22 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
resourcePropertiesAssignmentTab.saveProperties();
}
+ public void saveInputs() {
+ resourcePropertiesAssignmentInputTab.saveInputProperties();
+ }
+
public void addProperties(final Map<String, String> propertiesMap) {
resourcePropertiesAssignmentTab.addProperties(propertiesMap);
}
+ public void addInputs(final Map<String, String> inputsMap) {
+ resourcePropertiesAssignmentInputTab.addInputs(inputsMap);
+ }
+
+ public void verifyInputs(final Map<String, String> inputsMap) {
+ resourcePropertiesAssignmentInputTab.verifyInputs(inputsMap);
+ }
+
public Map<String, String> getPropertyNamesAndTypes() {
return resourcePropertiesAssignmentTab.getPropertyNamesAndTypes();
}