summaryrefslogtreecommitdiffstats
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/CreateServiceSubstitutionFilterTest.java138
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java100
-rw-r--r--integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateSubstitutionFilterFlow.java (renamed from integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateSubtitutionFilterFlow.java)28
3 files changed, 104 insertions, 162 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/CreateServiceSubstitutionFilterTest.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/CreateServiceSubstitutionFilterTest.java
deleted file mode 100644
index c49c2dc447..0000000000
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/CreateServiceSubstitutionFilterTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * ============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.execute.sanity;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.sdc.backend.ci.tests.datatypes.enums.ServiceInstantiationType;
-import org.onap.sdc.frontend.ci.tests.datatypes.LogicalOperator;
-import org.onap.sdc.frontend.ci.tests.datatypes.ServiceCreateData;
-import org.onap.sdc.frontend.ci.tests.datatypes.ServiceDependencyProperty;
-import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory;
-import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
-import org.onap.sdc.frontend.ci.tests.flow.CreateServiceFlow;
-import org.onap.sdc.frontend.ci.tests.flow.CreateSubtitutionFilterFlow;
-import org.onap.sdc.frontend.ci.tests.flow.DownloadToscaTemplateFlow;
-import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage;
-import org.onap.sdc.frontend.ci.tests.pages.ServiceComponentPage;
-import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage;
-import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage;
-import org.onap.sdc.frontend.ci.tests.pages.home.HomePage;
-import org.onap.sdc.frontend.ci.tests.utilities.FileHandling;
-import org.openqa.selenium.WebDriver;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class CreateServiceSubstitutionFilterTest extends SetupCDTest {
- private final String serviceName = "CreateServiceSubstitutionFilterTest";
- private final String stringValue = "Test";
- private final String booleanValue = "TRUE";
- private final LogicalOperator operator = LogicalOperator.EQUALS;
- private final List<ServiceDependencyProperty> substitutionFilterProperties = new ArrayList<ServiceDependencyProperty>();
- private final ServiceCreateData serviceCreateData = loadServiceCreateData();
-
- private WebDriver webDriver;
-
- @BeforeClass
- public void classSetup() {
- webDriver = DriverFactory.getDriver();
- }
-
- @Test
- public void createSubsitutionFilter() throws Exception {
- new CreateServiceFlow(webDriver, serviceCreateData).run(new HomePage(webDriver));
-
- ServiceComponentPage serviceComponentPage = new ServiceComponentPage(webDriver);
- serviceComponentPage.isLoaded();
-
- loadSubstitutionFilterProperties(serviceComponentPage);
- final CompositionPage compositionPage = serviceComponentPage.goToComposition();
-
- substitutionFilterProperties.forEach(substitutionFilterProperty -> {
- final CreateSubtitutionFilterFlow createSubtitutionFilterFlow = new CreateSubtitutionFilterFlow(webDriver, substitutionFilterProperty);
- createSubtitutionFilterFlow.run();
- });
-
- serviceComponentPage = compositionPage.goToServiceGeneral();
- serviceComponentPage.isLoaded();
-
- verifyToscaTemplateYaml(serviceComponentPage, false);
- }
-
- private ServiceCreateData loadServiceCreateData() {
- ServiceCreateData serviceCreateData = new ServiceCreateData();
- serviceCreateData.setRandomName(serviceName);
- serviceCreateData.setDescription(serviceName);
- serviceCreateData.setCategory("Network Service");
- serviceCreateData.setInstantiationType(ServiceInstantiationType.A_LA_CARTE);
- return serviceCreateData;
- }
-
- private void loadSubstitutionFilterProperties(final ServiceComponentPage serviceComponentPage) {
- final ResourcePropertiesAssignmentPage propertiesPage = serviceComponentPage.goToPropertiesAssignment();
- propertiesPage.isLoaded();
- final Map<String, String> propertyNamesAndTypes = propertiesPage.getPropertyNamesAndTypes();
- propertyNamesAndTypes.forEach((name, type)
- -> substitutionFilterProperties.add(new ServiceDependencyProperty(name, getPropertyValueByType(type), operator)));
- }
-
- private void verifyToscaTemplateYaml(final ServiceComponentPage serviceComponentPage, final boolean delete) throws Exception {
- final DownloadToscaTemplateFlow downloadCsarTemplateFlow = new DownloadToscaTemplateFlow(webDriver);
- final ToscaArtifactsPage toscaArtifactsPage = (ToscaArtifactsPage) downloadCsarTemplateFlow.run(serviceComponentPage).get();
- final Map<?, ?> yaml = FileHandling.parseYamlFile(getConfig().getDownloadAutomationFolder()
- .concat(java.io.File.separator).concat(toscaArtifactsPage.getDownloadedArtifactList().get(0)));
- verifyToscaTemplateHasSubstitutionFilter(yaml);
- }
-
- private void verifyToscaTemplateHasSubstitutionFilter(final Map<?, ?> yaml) {
- assertNotNull(yaml, "No contents in TOSCA Template");
- final List<?> substitutionFilters = (List<?>) getSubstitutionFilterFromYaml(yaml).get("properties");
- substitutionFilterProperties.forEach(substitutionFilterProperty -> {
- final Map<?, ?> substitutionFilter = (Map<?, ?>) substitutionFilters.stream()
- .filter(subFilter -> ((Map<?, ?>) subFilter).containsKey(substitutionFilterProperty.getName())).findAny().get();
- assertTrue(substitutionFilter.containsKey(substitutionFilterProperty.getName()), "Added substitution filter not found in TOSCA Template");
-
- final Map<?, ?> substitutionFilterValue = (Map<?, ?>) ((List<?>) substitutionFilter.get(substitutionFilterProperty.getName())).get(0);
- assertTrue(substitutionFilterValue.containsValue(convertValue(substitutionFilterProperty.getValue()))
- , "Invalid value for added substitution filters found in TOSCA Template");
- assertTrue(substitutionFilterValue.containsKey(substitutionFilterProperty.getLogicalOperator().getName())
- , "Invalid logical operator for added substitution filters found in TOSCA Template");
- });
- }
-
- private Map<?,?> getSubstitutionFilterFromYaml(final Map<?,?> yaml) {
- final Map<?, ?> topology = (Map<?, ?>) yaml.get("topology_template");
- final Map<?, ?> substitutionMappings = (Map<?, ?>) topology.get("substitution_mappings");
- return (Map<?, ?>) substitutionMappings.get("substitution_filter");
- }
-
- private Object convertValue(String value) {
- return booleanValue.equals(value) ? Boolean.parseBoolean(value) : value;
- }
-
- private String getPropertyValueByType(String type) {
- return "string".equals(type) ? stringValue : booleanValue;
- }
-}
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 967a97b9e9..578edbe0d6 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
@@ -47,7 +47,9 @@ import org.onap.sdc.backend.ci.tests.datatypes.enums.ComponentType;
import org.onap.sdc.backend.ci.tests.datatypes.enums.ResourceCategoryEnum;
import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory;
import org.onap.sdc.frontend.ci.tests.datatypes.ComponentData;
+import org.onap.sdc.frontend.ci.tests.datatypes.LogicalOperator;
import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData;
+import org.onap.sdc.frontend.ci.tests.datatypes.ServiceDependencyProperty;
import org.onap.sdc.frontend.ci.tests.datatypes.composition.RelationshipInformation;
import org.onap.sdc.frontend.ci.tests.exception.UnzipException;
import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory;
@@ -55,16 +57,18 @@ 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.AddComponentPropertyFlow;
import org.onap.sdc.frontend.ci.tests.flow.AddNodeToCompositionFlow;
+import org.onap.sdc.frontend.ci.tests.flow.CreateSubstitutionFilterFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateVfFlow;
import org.onap.sdc.frontend.ci.tests.flow.CreateVfcFlow;
import org.onap.sdc.frontend.ci.tests.flow.DownloadCsarArtifactFlow;
+import org.onap.sdc.frontend.ci.tests.flow.DownloadToscaTemplateFlow;
import org.onap.sdc.frontend.ci.tests.flow.EditComponentPropertiesFlow;
import org.onap.sdc.frontend.ci.tests.flow.composition.CreateRelationshipFlow;
import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException;
import org.onap.sdc.frontend.ci.tests.pages.AttributesOutputsPage;
import org.onap.sdc.frontend.ci.tests.pages.ComponentPage;
import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage;
-import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent;
+import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesAssignmentPage;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage;
import org.onap.sdc.frontend.ci.tests.pages.home.HomePage;
@@ -82,7 +86,6 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceTemplateDesignUiTests.class);
private WebDriver webDriver;
- private TopNavComponent topNavComponent;
private HomePage homePage;
private List<ResourceCreateData> vfcs = new ArrayList<>();
private ResourceCreateData vfResourceCreateData;
@@ -91,11 +94,11 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
private AddNodeToCompositionFlow addNodeToCompositionFlow;
private ComponentPage componentPage;
private Map<String, String> propertiesToBeAddedMap;
+ private final List<ServiceDependencyProperty> substitutionFilterProperties = new ArrayList<>();
@BeforeMethod
public void init() {
webDriver = DriverFactory.getDriver();
- topNavComponent = new TopNavComponent(webDriver);
homePage = new HomePage(webDriver);
}
@@ -177,13 +180,26 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
attributesOutputsPage.clickOnOutputsTab();
ExtentTestActions.addScreenshot(Status.INFO, "OutputsTab", "The Output's list : ");
- attributesOutputsPage.certifyComponent();
- attributesOutputsPage.isLoaded();
-
Map<String, Object> yamlObject = downloadToscaArtifact(attributesOutputsPage);
checkMetadata(yamlObject, vfResourceCreateData);
checkTopologyTemplate(yamlObject);
+ }
+
+ @Test(dependsOnMethods = "addComponentProperty")
+ public void createSubstitutionFilter() throws Exception {
+ componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
+ componentPage.isLoaded();
+ loadSubstitutionFilterProperties();
+ final CompositionPage compositionPage = componentPage.goToComposition();
+ compositionPage.isLoaded();
+ substitutionFilterProperties.forEach(substitutionFilterProperty -> {
+ final CreateSubstitutionFilterFlow createSubstitutionFilterFlow = new CreateSubstitutionFilterFlow(webDriver, substitutionFilterProperty);
+ createSubstitutionFilterFlow.run(compositionPage);
+ });
+ componentPage = compositionPage.goToGeneral();
+ componentPage.isLoaded();
+ verifyToscaTemplateHasSubstitutionFilter(downloadToscaTemplate());
}
private void checkMetadata(final Map<String, Object> map, final ResourceCreateData createdData) {
@@ -219,7 +235,6 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
final Map<String, Object> attributes = getMapEntry(substitutionMappings, "attributes");
assertThat(attributes, not(anEmptyMap()));
assertEquals(2, attributes.keySet().stream().filter(s -> (s.contains("_attr_1") || s.contains("_attr_3")) && !s.contains("_attr_2")).count());
-
}
private Map<String, Object> downloadToscaArtifact(final ComponentPage resourceCreatePage) throws UnzipException {
@@ -547,4 +562,75 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
propertyMap.put("property6", 500);
return propertyMap;
}
+
+ private void loadSubstitutionFilterProperties() {
+ final ResourcePropertiesAssignmentPage propertiesPage = componentPage.goToPropertiesAssignment();
+ propertiesPage.isLoaded();
+ ExtentTestActions.takeScreenshot(Status.INFO, "propertiesAssigment",
+ String.format("The %s Properties Assignment Page is loaded", vfResourceCreateData.getName()));
+ Map<String, String> propertyNamesAndTypes = propertiesPage.getPropertyNamesAndTypes();
+ assertThat(String.format("The Component '%s' should have properties", vfResourceCreateData.getName()), propertyNamesAndTypes,
+ not(anEmptyMap()));
+ propertyNamesAndTypes.forEach((name, type)
+ -> substitutionFilterProperties.add(new ServiceDependencyProperty(name, getPropertyValueByType(type), LogicalOperator.EQUALS)));
+ }
+
+ private String getPropertyValueByType(final String type) {
+ switch (type) {
+ case "string":
+ return "IntegrationTest";
+ case "integer":
+ return "202";
+ case "size":
+ return "500";
+ case "boolean":
+ return "TRUE";
+ case "list":
+ return "[value1, value2]";
+ case "map":
+ return "MyKey: MyValue";
+ default:
+ throw new UnsupportedOperationException("Not yet implemented for " + type);
+ }
+ }
+
+ /**
+ * Downloads Tosca Template file
+ * @return the tosca template yaml file
+ * @throws Exception
+ */
+ private Map<?, ?> downloadToscaTemplate() throws Exception {
+ final DownloadToscaTemplateFlow downloadToscaTemplateFlow = new DownloadToscaTemplateFlow(webDriver);
+ final ToscaArtifactsPage toscaArtifactsPage = (ToscaArtifactsPage) downloadToscaTemplateFlow.run(componentPage).get();
+ return FileHandling.parseYamlFile(getConfig().getDownloadAutomationFolder()
+ .concat(java.io.File.separator).concat(toscaArtifactsPage.getDownloadedArtifactList().get(0)));
+ }
+
+ private void verifyToscaTemplateHasSubstitutionFilter(final Map<?, ?> yaml) {
+ assertNotNull(yaml, "No contents in TOSCA Template");
+ final List<?> substitutionFilters = (List<?>) getSubstitutionFilterFromYaml(yaml).get("properties");
+ substitutionFilterProperties.forEach(substitutionFilterProperty -> {
+ final Map<?, ?> substitutionFilterMap = (Map<?, ?>) substitutionFilters.stream()
+ .filter(subFilter -> ((Map<?, ?>) subFilter).containsKey(substitutionFilterProperty.getName())).findAny().get();
+ assertThat("Added substitution filter not found in TOSCA Template",
+ substitutionFilterMap.containsKey(substitutionFilterProperty.getName()));
+ final Map<?, ?> substitutionFilterValue = (Map<?, ?>) ((List<?>) substitutionFilterMap.get(substitutionFilterProperty.getName())).get(0);
+ assertThat("Substitution Filter Value should not be empty", substitutionFilterMap, not(anEmptyMap()));
+ final String expectedSubstitutionPropertyValue = substitutionFilterProperty.getValue();
+ final String actualSubstitutionPropertyValue = substitutionFilterValue.values().stream().findFirst().get() instanceof Map
+ ? substitutionFilterValue.values().stream().findFirst().get().toString().replace("=", ": ")
+ .replaceAll("\\{(.*?)\\}", "$1").trim()
+ : substitutionFilterValue.values().stream().findFirst().get().toString();
+ assertThat("Invalid value for added substitution filters found in TOSCA Template",
+ expectedSubstitutionPropertyValue.equalsIgnoreCase(actualSubstitutionPropertyValue));
+ assertThat("Invalid logical operator for added substitution filters found in TOSCA Template",
+ substitutionFilterValue.containsKey(substitutionFilterProperty.getLogicalOperator().getName()));
+ });
+ }
+
+ private Map<?, ?> getSubstitutionFilterFromYaml(final Map<?, ?> yaml) {
+ final Map<?, ?> topology = (Map<?, ?>) yaml.get("topology_template");
+ final Map<?, ?> substitutionMappings = (Map<?, ?>) topology.get("substitution_mappings");
+ return (Map<?, ?>) substitutionMappings.get("substitution_filter");
+ }
}
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateSubtitutionFilterFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateSubstitutionFilterFlow.java
index c293d1cc5f..06131ae839 100644
--- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateSubtitutionFilterFlow.java
+++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateSubstitutionFilterFlow.java
@@ -21,9 +21,10 @@ package org.onap.sdc.frontend.ci.tests.flow;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import com.aventstack.extentreports.Status;
import java.util.Optional;
-
import org.onap.sdc.frontend.ci.tests.datatypes.ServiceDependencyProperty;
+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.ServiceDependenciesEditor;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent;
@@ -32,14 +33,12 @@ import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionSubstitutionFilterTab;
import org.openqa.selenium.WebDriver;
-import com.aventstack.extentreports.Status;
-
-public class CreateSubtitutionFilterFlow extends AbstractUiTestFlow {
+public class CreateSubstitutionFilterFlow extends AbstractUiTestFlow {
private CompositionPage compositionPage;
private final ServiceDependencyProperty substitutionFilterProperty;
- public CreateSubtitutionFilterFlow(final WebDriver webDriver, final ServiceDependencyProperty substitutionFilterProperty) {
+ public CreateSubstitutionFilterFlow(final WebDriver webDriver, final ServiceDependencyProperty substitutionFilterProperty) {
super(webDriver);
this.substitutionFilterProperty = substitutionFilterProperty;
}
@@ -47,14 +46,13 @@ public class CreateSubtitutionFilterFlow extends AbstractUiTestFlow {
@Override
public Optional<PageObject> run(final PageObject... pageObjects) {
extendTest.log(Status.INFO, "Creating substitution filter");
-
- compositionPage = getCompositionPage(pageObjects);
- compositionPage.isLoaded();
+ compositionPage = findParameter(pageObjects, CompositionPage.class);
final CompositionDetailSideBarComponent sideBar = compositionPage.getDetailSideBar();
sideBar.isLoaded();
- final CompositionSubstitutionFilterTab compositionSubstitutionFilterTab = (CompositionSubstitutionFilterTab) sideBar.selectTab(CompositionDetailTabName.SUBSTITUTION_FILTER);
+ final CompositionSubstitutionFilterTab compositionSubstitutionFilterTab = (CompositionSubstitutionFilterTab) sideBar
+ .selectTab(CompositionDetailTabName.SUBSTITUTION_FILTER);
compositionSubstitutionFilterTab.isLoaded();
final ServiceDependenciesEditor compositionSubstitutionDependenciesEditor = compositionSubstitutionFilterTab.clickAddSubstitutionFilter();
@@ -62,7 +60,10 @@ public class CreateSubtitutionFilterFlow extends AbstractUiTestFlow {
compositionSubstitutionDependenciesEditor.addProperty(substitutionFilterProperty);
compositionSubstitutionFilterTab.isLoaded();
- assertTrue(compositionSubstitutionFilterTab.isSubstitutionFilterPresent(substitutionFilterProperty.getName()), "Created substitution filter is not present");
+ assertTrue(compositionSubstitutionFilterTab.isSubstitutionFilterPresent(substitutionFilterProperty.getName()),
+ "Created substitution filter is not present");
+ ExtentTestActions.takeScreenshot(Status.INFO, "AddSubstitutionFilter",
+ String.format("Substitution filter '%s' successfully created", substitutionFilterProperty));
return Optional.of(compositionPage);
}
@@ -71,11 +72,4 @@ public class CreateSubtitutionFilterFlow extends AbstractUiTestFlow {
public Optional<? extends PageObject> getLandedPage() {
return Optional.ofNullable(compositionPage);
}
-
- private CompositionPage getCompositionPage(final PageObject... pageObjects) {
- return getParameter(pageObjects, CompositionPage.class)
- .orElseGet(() -> {
- return new CompositionPage(webDriver);
- });
- }
}