From c2fa1b7e8d43a236219d1f6ad2831de1af296cb4 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Thu, 13 Jan 2022 14:33:25 +0000 Subject: View Interface definition on VFC Add Interface support to VFC view UI Issue-ID: SDC-3850 Signed-off-by: aribeiro Change-Id: Icd195c939af39d40ae8c617e740323dd3e70fc15 --- .../ci/tests/execute/sanity/ImportVfcUiTest.java | 40 +++++- .../sanity/ServiceTemplateDesignUiTests.java | 16 +-- .../ci/tests/flow/InterfaceDefinitionFlow.java | 56 ++++++++ .../sdc/frontend/ci/tests/pages/ComponentPage.java | 5 + .../ci/tests/pages/ResourceLeftSideMenu.java | 14 +- .../CompositionInterfaceOperationsModal.java | 149 --------------------- .../CompositionInterfaceOperationsTab.java | 6 +- .../InterfaceDefinitionOperationsModal.java | 148 ++++++++++++++++++++ .../workspace/InterfaceDefinitionPage.java | 96 +++++++++++++ 9 files changed, 363 insertions(+), 167 deletions(-) create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/InterfaceDefinitionFlow.java delete mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsModal.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionOperationsModal.java create mode 100644 integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionPage.java (limited to 'integration-tests/src/test/java/org') diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ImportVfcUiTest.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ImportVfcUiTest.java index 834732b6f2..bac613861b 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ImportVfcUiTest.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ImportVfcUiTest.java @@ -47,6 +47,7 @@ import org.onap.sdc.frontend.ci.tests.flow.AddNodeToCompositionFlow; 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.InterfaceDefinitionFlow; import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException; import org.onap.sdc.frontend.ci.tests.pages.AttributeModal; import org.onap.sdc.frontend.ci.tests.pages.AttributesPage; @@ -55,9 +56,10 @@ import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent.CompositionDetailTabName; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInformationTab; -import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInterfaceOperationsModal; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInterfaceOperationsTab; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionOperationsModal; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionPage; 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; @@ -115,6 +117,10 @@ public class ImportVfcUiTest extends SetupCDTest { yamlObject = downloadToscaArtifact(componentPage); checkMetadata(yamlObject, vfcCreateData); checkNodeTypes(yamlObject); + + componentPage = viewInterfaceDefinitionFromVFC(componentPage); + componentPage.isLoaded(); + homePage.getTopNavComponent().clickOnHome(); // TC - Import VFC with interface inputs @@ -135,6 +141,23 @@ public class ImportVfcUiTest extends SetupCDTest { } + private ComponentPage viewInterfaceDefinitionFromVFC(final ComponentPage componentPage) { + final InterfaceDefinitionFlow interfaceDefinitionFlow = new InterfaceDefinitionFlow(webDriver); + interfaceDefinitionFlow.run(componentPage); + final InterfaceDefinitionPage interfaceDefinitionPage = interfaceDefinitionFlow.getLandedPage() + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return InterfaceDefinitionPage")); + final var OPERATION_NAME = "create"; + assertTrue(interfaceDefinitionPage.isInterfaceDefinitionOperationPresent(OPERATION_NAME)); + final InterfaceDefinitionOperationsModal interfaceDefinitionOperationsModal = interfaceDefinitionPage.clickOnInterfaceDefinitionOperation( + OPERATION_NAME); + interfaceDefinitionOperationsModal.isLoaded(); + ExtentTestActions + .takeScreenshot(Status.INFO, "clickOnOInterfaceOperation", "Interface Definition Operation Modal opened"); + checkInterfaceDefinitionData(interfaceDefinitionOperationsModal); + interfaceDefinitionOperationsModal.clickOnCancel(); + return interfaceDefinitionPage; + } + @Test public void importVfcWithModel() { final String fileName = "VFC-For-Model.yaml"; @@ -146,6 +169,13 @@ public class ImportVfcUiTest extends SetupCDTest { componentPage.isLoaded(); } + private void checkInterfaceDefinitionData(final InterfaceDefinitionOperationsModal interfaceDefinitionOperationsModal) { + assertTrue(interfaceDefinitionOperationsModal.getDescription().isEmpty()); + assertEquals(interfaceDefinitionOperationsModal.getImplementationName(), "path/to/my/implementation.sh"); + assertEquals(interfaceDefinitionOperationsModal.getInputName(), "first"); + assertEquals(interfaceDefinitionOperationsModal.getInputValue(), "1234"); + } + private ComponentPage manageAttributes(final ComponentPage componentPage) { final AttributesPage attributesPage = componentPage.goToAttributes(); attributesPage.isLoaded(); @@ -189,7 +219,7 @@ public class ImportVfcUiTest extends SetupCDTest { compositionInterfaceOperationsTab.isLoaded(); ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab", "Composition Interface Operations Tab opened"); assertTrue(compositionInterfaceOperationsTab.isOperationPresent("create")); - CompositionInterfaceOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab.clickOnOperation("create"); + InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab.clickOnOperation("create"); compositionInterfaceOperationsModal.isLoaded(); ExtentTestActions .takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab.clickOnOperation", "Composition Interface Operations Modal opened"); @@ -198,7 +228,7 @@ public class ImportVfcUiTest extends SetupCDTest { compositionInterfaceOperationsModal.addInput(); ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsModal.addInput", "Adding Input"); - final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData = new CompositionInterfaceOperationsModal.InterfaceOperationsData + final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData = new InterfaceDefinitionOperationsModal.InterfaceOperationsData ("This is CREATE operation", "fullPath/to/my/newImplementation.sh", "second", "9876"); compositionInterfaceOperationsModal.updateInterfaceOperation(interfaceOperationsData); compositionInterfaceOperationsTab.isLoaded(); @@ -370,8 +400,8 @@ public class ImportVfcUiTest extends SetupCDTest { } - private void checkCompositionInterfaceOperations(final CompositionInterfaceOperationsModal compositionInterfaceOperationsModal, - final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) { + private void checkCompositionInterfaceOperations(final InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal, + final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) { assertEquals(interfaceOperationsData.getDescription(), compositionInterfaceOperationsModal.getDescription()); assertEquals(interfaceOperationsData.getImplementationName(), compositionInterfaceOperationsModal.getImplementationName()); assertEquals(interfaceOperationsData.getInputName(), compositionInterfaceOperationsModal.getInputName()); 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 8bec8353ef..a2dbd5729e 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 @@ -78,7 +78,7 @@ import org.onap.sdc.frontend.ci.tests.pages.ResourcePropertiesPage; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent.CompositionDetailTabName; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInformationTab; -import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInterfaceOperationsModal; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionOperationsModal; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInterfaceOperationsTab; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardInterfaceOperation.InterfaceOperationsData; @@ -247,8 +247,8 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { compositionPage.isLoaded(); ExtentTestActions.addScreenshot(Status.INFO, "select-VFC-node", "Selecting Node on composition"); compositionPage.selectNode(vfcs.get(1).getName()); - final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData = - new CompositionInterfaceOperationsModal.InterfaceOperationsData("IT for updating an Interface Operation", + final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData = + new InterfaceDefinitionOperationsModal.InterfaceOperationsData("IT for updating an Interface Operation", "MyIntegrationTestImplementationName", "My_IT_InputName", "My_IT_InputValue"); updateInterfaceOperation(compositionPage, interfaceOperationsData); componentPage = compositionPage.goToGeneral(); @@ -374,7 +374,7 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { * @throws IOException */ private void updateInterfaceOperation(final CompositionPage compositionPage, - final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) throws IOException { + final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) throws IOException { final CompositionDetailSideBarComponent detailSideBar = compositionPage.getDetailSideBar(); detailSideBar.isLoaded(); final CompositionInterfaceOperationsTab compositionInterfaceOperationsTab = @@ -383,7 +383,7 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab", "Composition Interface Operations Tab loaded"); assertTrue(compositionInterfaceOperationsTab.isOperationPresent(interfaceOperationName)); - final CompositionInterfaceOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab + final InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab .clickOnOperation(interfaceOperationName); compositionInterfaceOperationsModal.isLoaded(); ExtentTestActions.takeScreenshot(Status.INFO, "update-interface-operation-modal", "Loading Interface Operations Modal"); @@ -405,13 +405,13 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { * @param interfaceOperationsData The Updated Interface Definition */ private void validateUpdatedInterfaceOperation(final CompositionDetailSideBarComponent detailSideBar, - final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) { + final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) { final CompositionInterfaceOperationsTab compositionInterfaceOperationsTab = (CompositionInterfaceOperationsTab) detailSideBar .selectTab(CompositionDetailTabName.INTERFACE_OPERATIONS); compositionInterfaceOperationsTab.isLoaded(); assertTrue(compositionInterfaceOperationsTab.isOperationPresent(interfaceOperationName)); assertTrue(compositionInterfaceOperationsTab.isDescriptionPresent()); - final CompositionInterfaceOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab + final InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab .clickOnOperation(interfaceOperationName); compositionInterfaceOperationsModal.isLoaded(); ExtentTestActions.takeScreenshot(Status.INFO, "validate-updated-interface-operation", @@ -428,7 +428,7 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { } private void verifyToscaTemplateHasUpdatedInterfaceOperation(final Map toscaTemplateYaml, - final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) { + final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) { assertNotNull(toscaTemplateYaml, "No contents in TOSCA Template"); final Map topologyTemplateTosca = getMapEntry((Map) toscaTemplateYaml, "topology_template"); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/InterfaceDefinitionFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/InterfaceDefinitionFlow.java new file mode 100644 index 0000000000..a0955ff800 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/InterfaceDefinitionFlow.java @@ -0,0 +1,56 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 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 com.aventstack.extentreports.Status; +import java.util.Optional; +import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; +import org.onap.sdc.frontend.ci.tests.pages.PageObject; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionPage; +import org.openqa.selenium.WebDriver; + +/** + * UI Flow for managing an Interface Definition from a component + */ +public class InterfaceDefinitionFlow extends AbstractUiTestFlow { + + private InterfaceDefinitionPage interfaceDefinitionPage; + + public InterfaceDefinitionFlow(final WebDriver webDriver) { + super(webDriver); + } + + @Override + public Optional run(final PageObject... pageObjects) { + extendTest.log(Status.INFO, "Downloading Tosca CSAR generated"); + final ComponentPage componentPage = findParameter(pageObjects, ComponentPage.class); + componentPage.isLoaded(); + interfaceDefinitionPage = componentPage.goToInterfaceDefinition(); + interfaceDefinitionPage.isLoaded(); + ExtentTestActions.takeScreenshot(Status.INFO, "interface-definition-page", "Interface Definition page loaded"); + return Optional.of(interfaceDefinitionPage); + } + + @Override + public Optional getLandedPage() { + return Optional.ofNullable(interfaceDefinitionPage); + } +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java index ada3410318..f690cca3f5 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java @@ -20,6 +20,7 @@ package org.onap.sdc.frontend.ci.tests.pages; import org.onap.sdc.frontend.ci.tests.datatypes.LifeCycleStateEnum; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionPage; 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.LoaderHelper; @@ -59,6 +60,10 @@ public class ComponentPage extends AbstractPageObject { return resourceLeftSideMenu.clickOnToscaArtifactsMenuItem(); } + public InterfaceDefinitionPage goToInterfaceDefinition() { + return resourceLeftSideMenu.clickOnInterfaceDefinitionMenuItem(); + } + public CompositionPage goToComposition() { return resourceLeftSideMenu.clickOnCompositionMenuItem(); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java index f0a973910f..68a447eadf 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceLeftSideMenu.java @@ -22,6 +22,7 @@ package org.onap.sdc.frontend.ci.tests.pages; import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionPage; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; @@ -94,6 +95,16 @@ public class ResourceLeftSideMenu extends AbstractPageObject { return new ToscaArtifactsPage(webDriver); } + /** + * Clicks on the Interface Definition menu item. + * + * @return the next page object + */ + public InterfaceDefinitionPage clickOnInterfaceDefinitionMenuItem() { + wrappingElement.findElement(By.xpath(XpathSelector.INTERFACE_DEFINITION_MENU.getXpath())).click(); + return new InterfaceDefinitionPage(webDriver); + } + /** * Clicks on the 'General' menu item. * @@ -127,7 +138,8 @@ public class ResourceLeftSideMenu extends AbstractPageObject { GENERAL_MENU("GeneralLeftSideMenu", "//*[@data-tests-id='%s']"), COMPOSITION_MENU("CompositionLeftSideMenu", "//*[@data-tests-id='%s']"), REQUIREMENT_CAPABILITY_MENU("Req. & CapabilitiesLeftSideMenu", "//*[@data-tests-id='%s']"), - TOSCA_ARTIFACTS_MENU("TOSCA ArtifactsLeftSideMenu", "//*[@data-tests-id='%s']"); + TOSCA_ARTIFACTS_MENU("TOSCA ArtifactsLeftSideMenu", "//*[@data-tests-id='%s']"), + INTERFACE_DEFINITION_MENU("InterfacesLeftSideMenu", "//*[@data-tests-id='%s']"); @Getter private final String id; diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsModal.java deleted file mode 100644 index 8fac69c944..0000000000 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsModal.java +++ /dev/null @@ -1,149 +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.pages.component.workspace; - -import com.aventstack.extentreports.Status; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; -import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; - -/** - * Represents the Composition Interface Operations Modal. - */ -public class CompositionInterfaceOperationsModal extends AbstractPageObject { - - public CompositionInterfaceOperationsModal(final WebDriver webDriver) { - super(webDriver); - } - - @Override - public void isLoaded() { - waitForElementVisibility(By.xpath(XpathSelector.TITLE_SPAN.getXPath())); - waitForElementVisibility(By.xpath(XpathSelector.INTERFACE_NAME_LABEL.getXPath())); - waitForElementVisibility(By.xpath(XpathSelector.OPERATION_NAME_LABEL.getXPath())); - waitForElementVisibility(By.xpath(XpathSelector.INPUT_NAME_SPAN.getXPath())); - waitForElementVisibility(By.xpath(XpathSelector.INPUT_VALUE_SPAN.getXPath())); - - waitToBeClickable(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath())); - waitToBeClickable(By.xpath(XpathSelector.SAVE_BTN.getXPath())); - waitToBeClickable(By.xpath(XpathSelector.CANCEL_BTN.getXPath())); - } - - public void clickOnSave() { - waitToBeClickable(By.xpath(XpathSelector.SAVE_BTN.getXPath())).click(); - } - - public void clickOnCancel() { - waitToBeClickable(By.xpath(XpathSelector.CANCEL_BTN.getXPath())).click(); - } - - public void clickOnDelete() { - waitToBeClickable(By.xpath(XpathSelector.DELETE_BTN.getXPath())).click(); - } - - public void updateInterfaceOperation(final InterfaceOperationsData interfaceOperationsData) { - fillDescription(interfaceOperationsData.getDescription()); - fillImplementationName(interfaceOperationsData.getImplementationName()); - fillInputName(interfaceOperationsData.getInputName()); - fillInputValue(interfaceOperationsData.getInputValue()); - clickOnSave(); - } - - private void fillDescription(final String description) { - setInputField(By.xpath(XpathSelector.INTERFACE_OPERATION_DESCRIPTION_INPUT.getXPath()), description); - } - - private void fillImplementationName(final String implementationName) { - setInputField(By.xpath(XpathSelector.INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT.getXPath()), implementationName); - } - - private void fillInputName(final String inputName) { - setInputField(By.xpath(XpathSelector.FIELD_INPUT_NAME_INPUT.getXPath()), inputName); - } - - private void fillInputValue(final String inputValue) { - setInputField(By.xpath(XpathSelector.FIELD_INPUT_VALUE_INPUT.getXPath()), inputValue); - } - - private void setInputField(final By locator, final String value) { - if (value == null) { - return; - } - final WebElement webElement = findElement(locator); - webElement.clear(); - webElement.sendKeys(value); - ExtentTestActions.takeScreenshot(Status.INFO, value, value); - } - - public void addInput() { - waitToBeClickable(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath())).click(); - } - - public String getDescription() { - return findElement(By.xpath(XpathSelector.INTERFACE_OPERATION_DESCRIPTION_INPUT.getXPath())).getAttribute("value"); - } - - public String getImplementationName() { - return findElement(By.xpath(XpathSelector.INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT.getXPath())).getAttribute("value"); - } - - public String getInputName() { - return findElement(By.xpath(XpathSelector.FIELD_INPUT_NAME_INPUT.getXPath())).getAttribute("value"); - } - - public String getInputValue() { - return findElement(By.xpath(XpathSelector.FIELD_INPUT_VALUE_INPUT.getXPath())).getAttribute("value"); - } - - @Getter - @AllArgsConstructor - public static class InterfaceOperationsData { - - private final String description; - private final String implementationName; - private final String inputName; - private final String inputValue; - } - - @AllArgsConstructor - private enum XpathSelector { - TITLE_SPAN("//span[@class='title' and contains(text(), 'Edit Operation')]"), - ADD_INPUT_BTN("//a[contains(@class,'add-param-link add-btn') and contains(text(), 'Add Input')]"), - DELETE_BTN("//svg-icon[@name='trash-o']"), - SAVE_BTN("//button[@data-tests-id='Save']"), - CANCEL_BTN("//button[@data-tests-id='Cancel']"), - INTERFACE_NAME_LABEL("//label[contains(@class,'sdc-input') and contains(text(), 'Interface Name')]"), - OPERATION_NAME_LABEL("//label[contains(@class,'sdc-input') and contains(text(), 'Operation Name')]"), - INTERFACE_OPERATION_DESCRIPTION_INPUT("//input[@data-tests-id='interface-operation-description']"), - INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT("//input[@data-tests-id='interface-operation-implementation-name']"), - INPUT_NAME_SPAN("//span[contains(@class,'field-input-name') and contains(text(), 'Name')]"), - INPUT_VALUE_SPAN("//span[contains(@class,'field-input-value') and contains(text(), 'Value')]"), - FIELD_INPUT_NAME_INPUT("//input[@data-tests-id='interface-operation-input-name']"), - FIELD_INPUT_VALUE_INPUT("//input[@data-tests-id='interface-operation-input-value']"); - - @Getter - private final String xPath; - - } -} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsTab.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsTab.java index c67293939e..60a732afd5 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsTab.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionInterfaceOperationsTab.java @@ -19,8 +19,6 @@ package org.onap.sdc.frontend.ci.tests.pages.component.workspace; -import static org.junit.jupiter.api.Assertions.assertNotNull; - import lombok.AllArgsConstructor; import lombok.Getter; import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; @@ -66,10 +64,10 @@ public class CompositionInterfaceOperationsTab extends AbstractPageObject { } } - public CompositionInterfaceOperationsModal clickOnOperation(final String operationName) { + public InterfaceDefinitionOperationsModal clickOnOperation(final String operationName) { final WebElement webElementInterfaceRow = webElement.findElement(By.xpath(XpathSelector.INTERFACE_ROW.getXPath())); webElementInterfaceRow.findElement(By.xpath(XpathSelector.FIELD_NAME_SPAN.getXPath(operationName))).click(); - return new CompositionInterfaceOperationsModal(webDriver); + return new InterfaceDefinitionOperationsModal(webDriver); } @AllArgsConstructor diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionOperationsModal.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionOperationsModal.java new file mode 100644 index 0000000000..cb2ee3d282 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionOperationsModal.java @@ -0,0 +1,148 @@ +/* + * ============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.component.workspace; + +import com.aventstack.extentreports.Status; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +/** + * Represents the Composition Interface Operations Modal. + */ +public class InterfaceDefinitionOperationsModal extends AbstractPageObject { + + public InterfaceDefinitionOperationsModal(final WebDriver webDriver) { + super(webDriver); + } + + @Override + public void isLoaded() { + waitForElementVisibility(By.xpath(XpathSelector.TITLE_SPAN.getXPath())); + waitForElementVisibility(By.xpath(XpathSelector.INTERFACE_NAME_LABEL.getXPath())); + waitForElementVisibility(By.xpath(XpathSelector.OPERATION_NAME_LABEL.getXPath())); + waitForElementVisibility(By.xpath(XpathSelector.INPUT_NAME_SPAN.getXPath())); + waitForElementVisibility(By.xpath(XpathSelector.INPUT_VALUE_SPAN.getXPath())); + waitForElementVisibility(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath())); + waitForElementVisibility(By.xpath(XpathSelector.SAVE_BTN.getXPath())); + waitToBeClickable(By.xpath(XpathSelector.CANCEL_BTN.getXPath())); + } + + public void clickOnSave() { + waitToBeClickable(By.xpath(XpathSelector.SAVE_BTN.getXPath())).click(); + } + + public void clickOnCancel() { + waitToBeClickable(By.xpath(XpathSelector.CANCEL_BTN.getXPath())).click(); + } + + public void clickOnDelete() { + waitToBeClickable(By.xpath(XpathSelector.DELETE_BTN.getXPath())).click(); + } + + public void updateInterfaceOperation(final InterfaceOperationsData interfaceOperationsData) { + fillDescription(interfaceOperationsData.getDescription()); + fillImplementationName(interfaceOperationsData.getImplementationName()); + fillInputName(interfaceOperationsData.getInputName()); + fillInputValue(interfaceOperationsData.getInputValue()); + clickOnSave(); + } + + private void fillDescription(final String description) { + setInputField(By.xpath(XpathSelector.INTERFACE_OPERATION_DESCRIPTION_INPUT.getXPath()), description); + } + + private void fillImplementationName(final String implementationName) { + setInputField(By.xpath(XpathSelector.INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT.getXPath()), implementationName); + } + + private void fillInputName(final String inputName) { + setInputField(By.xpath(XpathSelector.FIELD_INPUT_NAME_INPUT.getXPath()), inputName); + } + + private void fillInputValue(final String inputValue) { + setInputField(By.xpath(XpathSelector.FIELD_INPUT_VALUE_INPUT.getXPath()), inputValue); + } + + private void setInputField(final By locator, final String value) { + if (value == null) { + return; + } + final WebElement webElement = findElement(locator); + webElement.clear(); + webElement.sendKeys(value); + ExtentTestActions.takeScreenshot(Status.INFO, value, value); + } + + public void addInput() { + waitToBeClickable(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath())).click(); + } + + public String getDescription() { + return findElement(By.xpath(XpathSelector.INTERFACE_OPERATION_DESCRIPTION_INPUT.getXPath())).getAttribute("value"); + } + + public String getImplementationName() { + return findElement(By.xpath(XpathSelector.INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT.getXPath())).getAttribute("value"); + } + + public String getInputName() { + return findElement(By.xpath(XpathSelector.FIELD_INPUT_NAME_INPUT.getXPath())).getAttribute("value"); + } + + public String getInputValue() { + return findElement(By.xpath(XpathSelector.FIELD_INPUT_VALUE_INPUT.getXPath())).getAttribute("value"); + } + + @Getter + @AllArgsConstructor + public static class InterfaceOperationsData { + + private final String description; + private final String implementationName; + private final String inputName; + private final String inputValue; + } + + @AllArgsConstructor + private enum XpathSelector { + TITLE_SPAN("//span[@class='title' and contains(text(), 'Edit Operation')]"), + ADD_INPUT_BTN("//a[contains(@class,'add-param-link add-btn') and contains(text(), 'Add Input')]"), + DELETE_BTN("//svg-icon[@name='trash-o']"), + SAVE_BTN("//button[@data-tests-id='Save']"), + CANCEL_BTN("//button[@data-tests-id='Cancel']"), + INTERFACE_NAME_LABEL("//label[contains(@class,'sdc-input') and contains(text(), 'Interface Name')]"), + OPERATION_NAME_LABEL("//label[contains(@class,'sdc-input') and contains(text(), 'Operation Name')]"), + INTERFACE_OPERATION_DESCRIPTION_INPUT("//input[@data-tests-id='interface-operation-description']"), + INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT("//input[@data-tests-id='interface-operation-implementation-name']"), + INPUT_NAME_SPAN("//span[contains(@class,'field-input-name') and contains(text(), 'Name')]"), + INPUT_VALUE_SPAN("//span[contains(@class,'field-input-value') and contains(text(), 'Value')]"), + FIELD_INPUT_NAME_INPUT("//input[@data-tests-id='interface-operation-input-name']"), + FIELD_INPUT_VALUE_INPUT("//input[@data-tests-id='interface-operation-input-value']"); + + @Getter + private final String xPath; + + } +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionPage.java new file mode 100644 index 0000000000..a40878ac14 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/InterfaceDefinitionPage.java @@ -0,0 +1,96 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2022 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.component.workspace; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +public class InterfaceDefinitionPage extends ComponentPage { + + private WebElement wrappingElement; + + public InterfaceDefinitionPage(final WebDriver webDriver) { + super(webDriver); + } + + @Override + public void isLoaded() { + wrappingElement = waitForElementVisibility(By.xpath(XpathSelector.MAIN_DIV.getXpath()), 5); + waitForElementVisibility(By.xpath(XpathSelector.TITLE_DIV.getXpath()), 5); + waitForElementVisibility(By.xpath(XpathSelector.INTERFACE_NAME_SPAN.getXpath()), 5); + } + + public boolean isInterfaceDefinitionOperationPresent(final String operationName) { + try { + final WebElement webElementInterfaceRow = wrappingElement.findElement( + By.xpath(InterfaceDefinitionPage.XpathSelector.INTERFACE_ROW.getXpath())); + webElementInterfaceRow.findElement(By.xpath(InterfaceDefinitionPage.XpathSelector.FIELD_NAME_SPAN.getXpath(operationName))); + } catch (final Exception e) { + return false; + } + return true; + } + + public InterfaceDefinitionOperationsModal clickOnInterfaceDefinitionOperation(final String operationName) { + final WebElement webElementInterfaceRow = wrappingElement.findElement( + By.xpath(InterfaceDefinitionPage.XpathSelector.INTERFACE_ROW.getXpath())); + webElementInterfaceRow.findElement(By.xpath(InterfaceDefinitionPage.XpathSelector.FIELD_NAME_SPAN.getXpath(operationName))).click(); + return new InterfaceDefinitionOperationsModal(webDriver); + } + + /** + * 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']"), + TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'Interfaces')]"), + INTERFACE_NAME_SPAN("//span[@class='interface-name']"), + + INTERFACE_OPERATIONS("//div[@class='interface-operations']"), + OPERATION_LIST("//div[@class='operation-list']"), + EXPAND_COLLAPSE("//div[@class='expand-collapse']"), + INTERFACE_ACCORDION("//div[@class='interface-accordion']"), + INTERFACE_ROW("//div[contains(@class,'interface-row')]"), + FIELD_NAME_SPAN("//span[contains(@class,'field-name') and contains(text(), '%s')]"), + FIELD_DESCRIPTION_SPAN("//span[contains(@class,'field-description')]"); + + @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 String... params) { + return String.format(xpathFormat, params); + } + + } +} -- cgit 1.2.3-korg