From 7ea317f4ffc1ef2e54bed5df9d932d8128638f4b Mon Sep 17 00:00:00 2001 From: aribeiro Date: Mon, 10 May 2021 09:01:24 +0100 Subject: Update Interface Operation UI test Issue-ID: SDC-3582 Signed-off-by: aribeiro Change-Id: I2f5f451d96e520c89b6754ec1982282615115c44 --- .../sanity/ServiceTemplateDesignUiTests.java | 118 ++++++++++++++++++++- .../workspace/CompositionCanvasComponent.java | 2 +- .../CompositionDetailSideBarComponent.java | 4 +- .../CompositionInterfaceOperationsModal.java | 4 +- 4 files changed, 122 insertions(+), 6 deletions(-) (limited to 'integration-tests/src/test/java/org') 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 10176b2a50..79a634e251 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 @@ -23,6 +23,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anEmptyMap; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.emptyString; +import static org.hamcrest.Matchers.equalToIgnoringCase; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -73,6 +74,11 @@ 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.ResourcePropertiesAssignmentPage; 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.CompositionInterfaceOperationsTab; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardInterfaceOperation.InterfaceOperationsData; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; @@ -208,6 +214,24 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { checkTopologyTemplate(yamlObject); } + @Test(dependsOnMethods = "addRelationshipTemplate") + public void updateInterfaceOperation() throws Exception { + homePage.isLoaded(); + componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName()); + componentPage.isLoaded(); + final CompositionPage compositionPage = componentPage.goToComposition(); + 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", + "MyIntegrationTestImplementationName", "My_IT_InputName", "My_IT_InputValue"); + updateInterfaceOperation(compositionPage, interfaceOperationsData); + componentPage = compositionPage.goToGeneral(); + componentPage.isLoaded(); + verifyToscaTemplateHasUpdatedInterfaceOperation(downloadToscaTemplate(), interfaceOperationsData); + } + @Test(dependsOnMethods = "addComponentProperty") public void createSubstitutionFilter() throws Exception { componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName()); @@ -297,6 +321,98 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { assertEquals(2, attributes.keySet().stream().filter(s -> (s.contains("_attr_1") || s.contains("_attr_3")) && !s.contains("_attr_2")).count()); } + /** + * Updates an Interface operation from a selected Node (VFC) + * @param compositionPage the composition page + * @param interfaceOperationsData the interface definition + * @throws IOException + */ + private void updateInterfaceOperation(final CompositionPage compositionPage, + final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) throws IOException { + final CompositionDetailSideBarComponent detailSideBar = compositionPage.getDetailSideBar(); + detailSideBar.isLoaded(); + final CompositionInterfaceOperationsTab compositionInterfaceOperationsTab = + (CompositionInterfaceOperationsTab) detailSideBar.selectTab(CompositionDetailTabName.INTERFACE_OPERATIONS); + compositionInterfaceOperationsTab.isLoaded(); + ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab", + "Composition Interface Operations Tab loaded"); + assertTrue(compositionInterfaceOperationsTab.isOperationPresent(interfaceOperationName)); + final CompositionInterfaceOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab + .clickOnOperation(interfaceOperationName); + compositionInterfaceOperationsModal.isLoaded(); + ExtentTestActions.takeScreenshot(Status.INFO, "update-interface-operation-modal", "Loading Interface Operations Modal"); + compositionInterfaceOperationsModal.addInput(); + compositionInterfaceOperationsModal.updateInterfaceOperation(interfaceOperationsData); + compositionInterfaceOperationsTab.isLoaded(); + ExtentTestActions.addScreenshot(Status.INFO, "updated-interface-operation", + "The Interface operation from the selected Node was successfully updated"); + // Gives time for UI to load the Updated Interface Operation + final CompositionInformationTab compositionInformationTab = + (CompositionInformationTab) detailSideBar.selectTab(CompositionDetailTabName.INFORMATION); + compositionInformationTab.isLoaded(); + validateUpdatedInterfaceOperation(detailSideBar, interfaceOperationsData); + } + + /** + * Validates if the Updated Interface Operation has the expected values + * @param detailSideBar The composition Page + * @param interfaceOperationsData The Updated Interface Definition + */ + private void validateUpdatedInterfaceOperation(final CompositionDetailSideBarComponent detailSideBar, + final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) { + final CompositionInterfaceOperationsTab compositionInterfaceOperationsTab = (CompositionInterfaceOperationsTab) detailSideBar + .selectTab(CompositionDetailTabName.INTERFACE_OPERATIONS); + compositionInterfaceOperationsTab.isLoaded(); + assertTrue(compositionInterfaceOperationsTab.isOperationPresent(interfaceOperationName)); + assertTrue(compositionInterfaceOperationsTab.isDescriptionPresent()); + final CompositionInterfaceOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab + .clickOnOperation(interfaceOperationName); + compositionInterfaceOperationsModal.isLoaded(); + ExtentTestActions.takeScreenshot(Status.INFO, "validate-updated-interface-operation", + "Loading the Interface Operations Modal for validating"); + assertThat("The Interface Operation Description should match", interfaceOperationsData.getDescription(), + equalToIgnoringCase(compositionInterfaceOperationsModal.getDescription())); + assertThat("The Interface Operation Implementation Name should match", interfaceOperationsData.getImplementationName(), + equalToIgnoringCase(compositionInterfaceOperationsModal.getImplementationName())); + assertThat("The Interface Operation Input key should match", interfaceOperationsData.getInputName(), + equalToIgnoringCase(compositionInterfaceOperationsModal.getInputName())); + assertThat("The Interface Operation Input Value should match", interfaceOperationsData.getInputValue(), + equalToIgnoringCase(compositionInterfaceOperationsModal.getInputValue())); + compositionInterfaceOperationsModal.clickOnCancel(); + } + + private void verifyToscaTemplateHasUpdatedInterfaceOperation(final Map toscaTemplateYaml, + final CompositionInterfaceOperationsModal.InterfaceOperationsData interfaceOperationsData) { + + assertNotNull(toscaTemplateYaml, "No contents in TOSCA Template"); + final Map topologyTemplateTosca = getMapEntry((Map) toscaTemplateYaml, "topology_template"); + assertThat("Should contain a topology_template entry", toscaTemplateYaml, is(notNullValue())); + final Map nodeTemplatesTosca = getMapEntry(topologyTemplateTosca, "node_templates"); + assertThat("Should contain a node_templates entry", nodeTemplatesTosca, is(notNullValue())); + final Optional> nodeWithInterfaceOperation = nodeTemplatesTosca.entrySet().stream() + .filter(s -> s.getKey().startsWith(vfcs.get(1).getName())).findFirst(); + assertThat("Should contain a node (VFC)", nodeWithInterfaceOperation.isPresent(), is(true)); + final Map interfacesEntry = (Map) nodeWithInterfaceOperation.get().getValue(); + assertThat("The Interfaces Entry should not be empty", interfacesEntry, not(anEmptyMap())); + final Map interfaceOperations = (Map) interfacesEntry.get("interfaces"); + assertThat("The Interface Entry should have operations", interfaceOperations, not(anEmptyMap())); + final Map interfaceNameMap = (Map) interfaceOperations.get(interfaceName); + assertThat(String.format("'%s' should contain a Interface Name entry '%s'", interfaceNameMap, interfaceName), + interfaceOperations, not(anEmptyMap())); + final Map updatedInterfaceOperation = (Map) interfaceNameMap.get(interfaceOperationName); + assertThat(String.format("'%s' should contain a Interface Operation Name '%s'", updatedInterfaceOperation, interfaceOperationName), + updatedInterfaceOperation, not(anEmptyMap())); + assertThat("The Interface Operation Description should match", + updatedInterfaceOperation.get("description").equals(interfaceOperationsData.getDescription())); + assertThat("The Interface Operation Implementation Name should match", + updatedInterfaceOperation.get("implementation").equals(interfaceOperationsData.getImplementationName())); + final Map updatedInterfaceOperationInput = (Map) updatedInterfaceOperation.get("inputs"); + assertThat("The Interface Operation Input Key should match", + updatedInterfaceOperationInput.containsKey(interfaceOperationsData.getInputName())); + assertThat("The Interface Operation Input Value should match", + updatedInterfaceOperationInput.containsValue(interfaceOperationsData.getInputValue())); + } + private Map downloadToscaArtifact(final ComponentPage resourceCreatePage) throws UnzipException { final DownloadCsarArtifactFlow downloadCsarArtifactFlow = downloadToscaCsar(resourceCreatePage); final ToscaArtifactsPage toscaArtifactsPage = downloadCsarArtifactFlow.getLandedPage() @@ -567,7 +683,7 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest { assertThat(String.format("'%s' should contain a Interface Operation Name '%s'", relationshipTemplateMap, interfaceOperationName), result.contains(interfaceOperationName), is(true)); assertThat(String.format("'%s' should contain Implementation Name '%s'", relationshipTemplateMap, implementationName), - result.contains(interfaceOperationName), is(true)); + result.contains(implementationName), is(true)); assertThat(String.format("'%s' should contain inputs entry", relationshipTemplateMap), result.contains("inputs"), is(true)); assertThat(String.format("'%s' should contain Input Name '%s'", relationshipTemplateMap, inputName), result.contains(inputName), is(true)); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java index 7b8ebf5ed2..1c5793f3bd 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java @@ -123,7 +123,7 @@ public class CompositionCanvasComponent extends AbstractPageObject { public void selectNode(final String elementName) { final Optional canvasElementOptional = canvasElementList.stream() - .filter(canvasNodeElement -> canvasNodeElement.getName().equals(elementName)) + .filter(canvasNodeElement -> canvasNodeElement.getName().startsWith(elementName)) .findFirst(); if (canvasElementOptional.isEmpty()) { throw new CompositionCanvasRuntimeException(String.format("Given element '%s' does not exist on the element list", elementName)); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionDetailSideBarComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionDetailSideBarComponent.java index fc968fcc4f..6cc238ec5c 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionDetailSideBarComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionDetailSideBarComponent.java @@ -20,7 +20,7 @@ package org.onap.sdc.frontend.ci.tests.pages.component.workspace; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.startsWith; import lombok.AllArgsConstructor; import lombok.Getter; @@ -48,7 +48,7 @@ public class CompositionDetailSideBarComponent extends AbstractPageObject { } public void checkComponentIsSelected(final String componentName) { - assertThat("The selected component should be as expected", getSelectedComponentName(), is(componentName)); + assertThat("The selected component should be as expected", getSelectedComponentName(), startsWith(componentName)); } public Dimension getSize() { 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 index 434885c4cb..8fac69c944 100644 --- 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 @@ -59,7 +59,7 @@ public class CompositionInterfaceOperationsModal extends AbstractPageObject { } public void clickOnDelete() { - waitToBeClickable(By.xpath(XpathSelector.DELELE_BTN.getXPath())).click(); + waitToBeClickable(By.xpath(XpathSelector.DELETE_BTN.getXPath())).click(); } public void updateInterfaceOperation(final InterfaceOperationsData interfaceOperationsData) { @@ -130,7 +130,7 @@ public class CompositionInterfaceOperationsModal extends AbstractPageObject { 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')]"), - DELELE_BTN("//svg-icon[@name='trash-o']"), + 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')]"), -- cgit 1.2.3-korg