<a
class="add-param-link add-btn"
*ngIf="!enableAddOperation"
+ data-tests-id="addInterfaceOperation"
(click)="addOperation()">{{ 'OPERATION_ADD1' | translate }}</a>
</div>
<div id="operation-list-container" class="operation-list-container">
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.CompositionPage;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardInterfaceOperation.InterfaceOperationsData;
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;
private AddNodeToCompositionFlow addNodeToCompositionFlow;
private ComponentPage componentPage;
private Map<String, String> propertiesToBeAddedMap;
+ private ResourceCreatePage resourceCreatePage;
private final List<ServiceDependencyProperty> substitutionFilterProperties = new ArrayList<>();
+ private final String interfaceName = "Standard";
+ private final String interfaceOperationName = "create";
+ private final String implementationName = "IntegrationTest";
+ private final String inputName = "InputName1";
+ private final String inputValue = "InputValue1";
@BeforeMethod
public void init() {
}
@Test(dependsOnMethods = "importAndCertifyVfc")
- public void createBaseService() throws UnzipException {
+ public void createBaseService() {
final CreateVfFlow createVfFlow = createVF();
- addNodeToCompositionFlow = addNodeToCompositionAndCreateRelationship(createVfFlow);
- final CompositionPage compositionPage = addNodeToCompositionFlow.getLandedPage()
- .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return CompositionPage"));
- compositionPage.isLoaded();
- componentPage = compositionPage.goToGeneral();
- componentPage.isLoaded();
- downloadAndVerifyCsarPackageAfterBaseServiceCreation(componentPage);
+ resourceCreatePage = createVfFlow.getLandedPage()
+ .orElseThrow(() -> new UiTestFlowRuntimeException("Expecting a ResourceCreatePage"));
+ resourceCreatePage.isLoaded();
}
@Test(dependsOnMethods = "createBaseService")
}
@Test(dependsOnMethods = "createBaseService")
+ public void addRelationshipTemplate() throws UnzipException {
+ homePage.isLoaded();
+ resourceCreatePage = (ResourceCreatePage) homePage.clickOnComponent(vfResourceCreateData.getName());
+ resourceCreatePage.isLoaded();
+ addNodeToCompositionFlow = addNodeToCompositionAndCreateRelationship();
+ final CompositionPage compositionPage = addNodeToCompositionFlow.getLandedPage()
+ .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return CompositionPage"));
+ compositionPage.isLoaded();
+ componentPage = compositionPage.goToGeneral();
+ componentPage.isLoaded();
+ downloadAndVerifyCsarPackage(componentPage);
+ }
+
+ @Test(dependsOnMethods = "addRelationshipTemplate")
public void addOutputsToVF_test() throws UnzipException, IOException {
homePage.isLoaded();
final ComponentPage resourceCreatePage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
checkTopologyTemplate(yamlObject);
}
-
@Test(dependsOnMethods = "addComponentProperty")
public void createSubstitutionFilter() throws Exception {
componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
return vfcCreateData;
}
- private AddNodeToCompositionFlow addNodeToCompositionAndCreateRelationship(final CreateVfFlow createVfFlow) {
- final ResourceCreatePage resourceCreatePage = createVfFlow.getLandedPage()
- .orElseThrow(() -> new UiTestFlowRuntimeException("Expecting a ResourceCreatePage"));
- resourceCreatePage.isLoaded();
+ private AddNodeToCompositionFlow addNodeToCompositionAndCreateRelationship() {
assertThat(vfcs, hasSize(2));
final ComponentData parentComponent = new ComponentData();
parentComponent.setName(vfResourceCreateData.getName());
networkFunction.setName(vfcs.get(0).getName());
networkFunction.setVersion("1.0");
networkFunction.setComponentType(ComponentType.RESOURCE);
- CompositionPage compositionPage = resourceCreatePage.goToComposition();
+ final CompositionPage compositionPage = resourceCreatePage.goToComposition();
compositionPage.isLoaded();
AddNodeToCompositionFlow addNodeToCompositionFlow = addNodeToComposition(parentComponent, networkFunction, compositionPage);
networkFunctionInstance = addNodeToCompositionFlow.getCreatedComponentInstance()
final String fromCapability, final String toComponentInstanceName, final String toRequirement) {
final RelationshipInformation relationshipInformation =
new RelationshipInformation(fromComponentInstanceName, fromCapability, toComponentInstanceName, toRequirement);
- CreateRelationshipFlow createRelationshipFlow = new CreateRelationshipFlow(webDriver, relationshipInformation);
+ final CreateRelationshipFlow createRelationshipFlow = new CreateRelationshipFlow(webDriver, relationshipInformation,
+ new InterfaceOperationsData(interfaceName, interfaceOperationName, implementationName, inputName, inputValue));
createRelationshipFlow.run(compositionPage).orElseThrow(() -> new UiTestFlowRuntimeException("Expecting a CompositionPage instance"));
ExtentTestActions.takeScreenshot(Status.INFO, "relationship",
String.format("Relationship from networkFunctionInstance '%s' to networkServiceInstanceResource '%s' was created",
* @param componentPage the component page
* @throws UnzipException
*/
- private void downloadAndVerifyCsarPackageAfterBaseServiceCreation(final ComponentPage componentPage) throws UnzipException {
+ private void downloadAndVerifyCsarPackage(final ComponentPage componentPage) throws UnzipException {
checkCsarPackage(downloadCsarPackage(componentPage));
}
.anyMatch(vfc -> s.startsWith(vfc.getName()))).collect(Collectors.toList());
assertThat(String.format("'%s' should contain the node type definitions for the added VFCs '%s'", nodeTemplatesTosca, vfcs),
nodeTemplateFound, hasSize(vfcs.size()));
+ verifyRelationshipTemplate(topologyTemplateTosca, generatedTemplateFile);
+ }
+
+ private void verifyRelationshipTemplate(final Map<String, Object> topologyTemplateToscaMap, final String generatedTemplateFile) {
+ final Map<String, Object> relationshipTemplateMap = getMapEntry(topologyTemplateToscaMap, "relationship_templates");
+ assertThat(String.format("'%s' should contain a topology_template entry", generatedTemplateFile), relationshipTemplateMap,
+ is(notNullValue()));
+ final String result = Arrays.asList(relationshipTemplateMap.values()).toString();
+ assertThat(String.format("'%s' should contain a DependsOn relationship", relationshipTemplateMap),
+ result.contains("tosca.relationships.DependsOn"), is(true));
+ assertThat(String.format("'%s' should contain interfaces entry", relationshipTemplateMap), result.contains("interfaces"), is(true));
+ assertThat(String.format("'%s' should contain a Interface Name entry '%s'", relationshipTemplateMap, interfaceName),
+ result.contains(interfaceName), is(true));
+ 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));
+ 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));
+ assertThat(String.format("'%s' should contain Input Value '%s'", relationshipTemplateMap, inputValue), result.contains(inputValue),
+ is(true));
}
private void verifyNodesRelationship(final Map<String, byte[]> expectedFilesFromZipMap, final String virtualFunctionName,
package org.onap.sdc.frontend.ci.tests.flow.composition;
import com.aventstack.extentreports.Status;
+import java.util.Objects;
import java.util.Optional;
import org.onap.sdc.frontend.ci.tests.datatypes.composition.RelationshipInformation;
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.component.workspace.CompositionPage;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardComponent;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardInterfaceOperation;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardInterfaceOperation.InterfaceOperationsData;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.RelationshipWizardRequirementCapabilityComponent;
import org.openqa.selenium.WebDriver;
private final RelationshipInformation relationshipInformation;
private CompositionPage compositionPage;
+ private InterfaceOperationsData interfaceOperationsData;
public CreateRelationshipFlow(final WebDriver webDriver, final RelationshipInformation relationshipInformation) {
super(webDriver);
this.relationshipInformation = relationshipInformation;
}
+ public CreateRelationshipFlow(final WebDriver webDriver, final RelationshipInformation relationshipInformation,
+ final InterfaceOperationsData interfaceOperationsData) {
+ super(webDriver);
+ this.relationshipInformation = relationshipInformation;
+ this.interfaceOperationsData = interfaceOperationsData;
+ }
+
@Override
public Optional<? extends PageObject> run(final PageObject... pageObjects) {
compositionPage = findParameter(pageObjects, CompositionPage.class);
String.format("Selected requirement '%s'", relationshipInformation.getToRequirement()));
relationshipWizardComponent.clickOnNext();
relationshipWizardComponent.clickOnNext();
+ relationshipWizardComponent.clickOnAddOperation();
+ if (Objects.nonNull(interfaceOperationsData)) {
+ addInterfaceOperationAndInput(interfaceOperationsData);
+ }
relationshipWizardComponent.clickOnFinish();
compositionPage.isLoaded();
ExtentTestActions.takeScreenshot(Status.INFO, "relationship-created",
return Optional.of(compositionPage);
}
+ /**
+ * Adds an Interface Operation and Input to the relationship template
+ * @param interfaceOperationsData the Interface Operation data
+ */
+ private void addInterfaceOperationAndInput(final InterfaceOperationsData interfaceOperationsData) {
+ ExtentTestActions.takeScreenshot(Status.INFO, "add-interface-operation",
+ String.format("Adding Interface Operation on node '%s'", relationshipInformation.getFromNode()));
+ final RelationshipWizardInterfaceOperation relationshipWizardInterfaceOperation = new RelationshipWizardInterfaceOperation(webDriver);
+ relationshipWizardInterfaceOperation.isLoaded();
+ relationshipWizardInterfaceOperation.addInterfaceOperation(interfaceOperationsData);
+ ExtentTestActions.takeScreenshot(Status.INFO, "added-interface-operation",
+ String.format("Interface Operation added on node '%s'", relationshipInformation.getFromNode()));
+ }
+
@Override
public Optional<CompositionPage> getLandedPage() {
return Optional.of(compositionPage);
waitToBeClickable(XpathSelector.FINISH_BUTTON.getXpath()).click();
}
+ public void clickOnAddOperation() {
+ waitToBeClickable(XpathSelector.ADD_OPERATION_BUTTON.getXpath()).click();
+ }
+
/**
* Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
*/
CANCEL_BUTTON(WIZARD_FOOTER.getXpath() + "//button[text()='Cancel']"),
NEXT_BUTTON(WIZARD_FOOTER.getXpath() + "//div[contains(@class, 'white-arrow-next')]/.."),
BACK_BUTTON(WIZARD_FOOTER.getXpath() + "//div[contains(@class, 'blue-arrow-back')]/.."),
- FINISH_BUTTON(WIZARD_FOOTER.getXpath() + "//button[contains(text(), 'Finish')]");
+ FINISH_BUTTON(WIZARD_FOOTER.getXpath() + "//button[contains(text(), 'Finish')]"),
+ ADD_OPERATION_BUTTON("//a[contains(@class,'add-param-link add-btn') and contains(text(), 'Add Operation')]");
@Getter
private final String xpath;
--- /dev/null
+/*
+ * ============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 relationship wizard dialog that is used to add interface operations to a node.
+ */
+public class RelationshipWizardInterfaceOperation extends AbstractPageObject {
+
+ public RelationshipWizardInterfaceOperation(final WebDriver webDriver) {
+ super(webDriver);
+ }
+
+ @Override
+ public void isLoaded() {
+ waitToBeClickable(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath()));
+ }
+
+ public void addInterfaceOperation(final InterfaceOperationsData interfaceOperationsData) {
+ selectInterfaceName(interfaceOperationsData.getInterfaceName());
+ selectOperationName(interfaceOperationsData.getOperationName());
+ fillImplementationName(interfaceOperationsData.getImplementation());
+ addInput();
+ fillInputName(interfaceOperationsData.getInputName());
+ fillInputValue(interfaceOperationsData.getInputValue());
+ saveInterfaceOperationAndInput();
+ }
+
+ private void selectInterfaceName(final String interfaceName) {
+ waitToBeClickable(By.xpath(XpathSelector.INTERFACE_AND_OPERATION_SVG_ICON.getXPath("interface-name-icon"))).click();
+ findElement(By.xpath(XpathSelector.INTERFACE_AND_OPERATION_DROPDOWN.getXPath(interfaceName))).click();
+ }
+
+ private void selectOperationName(final String interfaceOperationName) {
+ waitToBeClickable(By.xpath(XpathSelector.INTERFACE_AND_OPERATION_SVG_ICON.getXPath("operation-name-icon"))).click();
+ findElement(By.xpath(XpathSelector.INTERFACE_AND_OPERATION_DROPDOWN.getXPath(interfaceOperationName))).click();
+ }
+
+ 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.getXPath()), inputName);
+ }
+
+ private void fillInputValue(final String inputValue) {
+ setInputField(By.xpath(XpathSelector.FIELD_INPUT_VALUE.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);
+ }
+
+ private void addInput() {
+ waitToBeClickable(By.xpath(XpathSelector.ADD_INPUT_BTN.getXPath())).click();
+ }
+
+ private void saveInterfaceOperationAndInput() {
+ waitToBeClickable(By.xpath(XpathSelector.ADD_BTN.getXPath())).click();
+ }
+
+ @Getter
+ @AllArgsConstructor
+ public static class InterfaceOperationsData {
+
+ private final String interfaceName;
+ private final String operationName;
+ private final String implementation;
+ private final String inputName;
+ private final String inputValue;
+ }
+
+ @AllArgsConstructor
+ private enum XpathSelector {
+ INTERFACE_AND_OPERATION_SVG_ICON("//div[@data-tests-id='%s']"),
+ INTERFACE_AND_OPERATION_DROPDOWN("//li[@class='sdc-dropdown__option ng-star-inserted' and contains(text(), '%s')]"),
+ INTERFACE_OPERATION_DESCRIPTION_INPUT("//input[@data-tests-id='interface-operation-description']"),
+ INTERFACE_OPERATION_IMPLEMENTATION_NAME_INPUT("//input[@id='implementationInput']"),
+ ADD_INPUT_BTN("//a[contains(@class,'add-param-link add-btn') and contains(text(), 'Add Input')]"),
+ FIELD_INPUT_NAME("//input[@id='propertyAssignmentNameInput']"),
+ FIELD_INPUT_VALUE("//input[@id='propertyAssignmentValueInput']"),
+ ADD_BTN("//button[@data-tests-id='addBtn']");
+
+ @Getter
+ private String xPath;
+ private final String xpathFormat;
+
+ XpathSelector(final String xpathFormat) {
+ this.xpathFormat = xpathFormat;
+ }
+
+ public String getXPath() {
+ return String.format(xpathFormat, xPath);
+ }
+
+ public String getXPath(final String... xpathParams) {
+ return String.format(xpathFormat, xpathParams);
+ }
+ }
+}
<methods>
<include name="importAndCertifyVfc"/>
<include name="createBaseService"/>
+ <include name="addRelationshipTemplate"/>
<include name="addComponentProperty"/>
<include name="addOutputsToVF_test"/>
<include name="createSubstitutionFilter"/>