2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.US;
23 import java.util.Arrays;
24 import java.util.HashMap;
25 import java.util.List;
28 import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
29 import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
30 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
32 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
33 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
34 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
35 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
36 import org.openecomp.sdc.ci.tests.pages.InputsPage;
37 import org.openecomp.sdc.ci.tests.pages.PropertyPopup;
38 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
39 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
40 import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils;
41 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
42 import org.openqa.selenium.By;
43 import org.openqa.selenium.WebElement;
44 import org.testng.Assert;
45 import org.testng.TestException;
46 import org.testng.annotations.BeforeMethod;
47 import org.testng.annotations.Test;
49 public class Inputs extends SetupCDTest {
51 private static final String DESCRIPTION = "kuku";
52 private static final String ARTIFACT_LABEL = "artifact3";
53 private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate";
54 private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact";
55 private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml";
56 private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml";
57 private String filePath;
60 public void beforeTest(){
61 filePath = FileHandling.getFilePath("");
64 // TODO: There is defect that imported VFC checkin not appear in service until refresh
65 // TODO: add support for CP (there is no normative CP's with complex properties which can be selected - import one) - importVFCWithComplexProperty.yml
67 // Delete Input declared from VLi/CPi in service level - Deleting an Input that was declared from Complex property.
69 public void deletingAnInputThatWasDeclaredFromComplexProperty() throws Exception{
70 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
71 ServiceUIUtils.createService(serviceMetadata, getUser());
73 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
74 CanvasManager canvasManager = CanvasManager.getCanvasManager();
75 Map<String, List<String>> resourceInstanceToProperty = new HashMap<>();
76 CompositionPage.searchForElement("ExtVL");
77 CanvasElement computeElement = canvasManager.createElementOnCanvas("ExtVL");
78 canvasManager.clickOnCanvaElement(computeElement);
79 resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), Arrays.asList("network_homing", "instance_node_target"));
81 // CompositionPage.searchForElement("ExtCP");
82 // computeElement = canvasManager.createElementOnCanvas("ExtCP");
83 // canvasManager.clickOnCanvaElement(computeElement);
84 // resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "order");
86 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
87 DeploymentArtifactPage.getLeftMenu().moveToInputsScreen();
90 for(String element: resourceInstanceToProperty.keySet()) {
91 String propertyName = resourceInstanceToProperty.get(element).get(0);
92 String innerPropertyName = resourceInstanceToProperty.get(element).get(1);
93 String dataTestIdPropertyCheckbox = DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + propertyName;
95 GeneralUIUtils.clickOnElementByText(element);
96 GeneralUIUtils.ultimateWait();
98 InputsPage.clickOnProperty(propertyName);
100 PropertyPopup propertyPopup = new PropertyPopup();
101 propertyPopup.selectPropertyRadioButton(innerPropertyName);
102 propertyPopup.clickSave();
104 InputsPage.clickOnAddInputButton();
106 // Verify that input checkbox selected
107 verifyPropertyCheckBoxSelected(dataTestIdPropertyCheckbox);
109 InputsPage.deleteServiceInput(element, propertyName + "_" + innerPropertyName);
111 // Trying to find deleted service input
113 InputsPage.getServiceInput(element, propertyName + "_" + innerPropertyName);
115 } catch(TestException e){
116 System.out.println("Verfied that service input deleted");
119 // Verify that input checkbox not selected
120 verifyPropertyCheckBoxNotSelected(dataTestIdPropertyCheckbox);
122 GeneralUIUtils.clickOnElementByText(element);
123 GeneralUIUtils.ultimateWait();
130 // Delete inputs who come from CP/VL properties
132 public void deleteInputsWhoComeFromCpVlProperties() throws Exception{
133 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
134 ServiceUIUtils.createService(serviceMetadata, getUser());
136 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
137 CanvasManager canvasManager = CanvasManager.getCanvasManager();
138 Map<String, String> resourceInstanceToProperty = new HashMap<>();
139 CompositionPage.searchForElement("ExtVL");
140 CanvasElement computeElement = canvasManager.createElementOnCanvas("ExtVL");
141 canvasManager.clickOnCanvaElement(computeElement);
142 resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "network_role");
144 CompositionPage.searchForElement("ExtCP");
145 computeElement = canvasManager.createElementOnCanvas("ExtCP");
146 canvasManager.clickOnCanvaElement(computeElement);
147 resourceInstanceToProperty.put(CompositionPage.getSelectedInstanceName(), "order");
149 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
150 DeploymentArtifactPage.getLeftMenu().moveToInputsScreen();
153 for(String element: resourceInstanceToProperty.keySet()) {
154 GeneralUIUtils.clickOnElementByText(element);
155 GeneralUIUtils.ultimateWait();
157 WebElement webElementByTestID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element));
158 InputsPage.clickOnVFInputCheckbox(webElementByTestID);
160 InputsPage.clickOnAddInputButton();
162 // Verify that input checkbox selected
163 verifyPropertyCheckBoxSelected(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element));
165 InputsPage.deleteServiceInput(element, resourceInstanceToProperty.get(element));
167 // Trying to find deleted service input
169 InputsPage.getServiceInput(element, resourceInstanceToProperty.get(element));
171 } catch(TestException e){
172 System.out.println("Verfied that service input deleted");
175 // Verify that input checkbox not selected
176 verifyPropertyCheckBoxNotSelected(DataTestIdEnum.InputsScreenService.RESOURCE_INSTANCE_PROPERTY_CHECKBOX.getValue() + resourceInstanceToProperty.get(element));
178 GeneralUIUtils.clickOnElementByText(element);
179 GeneralUIUtils.ultimateWait();
190 public String verifyPropertyCheckBox(String dataTestId) {
191 WebElement webElementByTestID = GeneralUIUtils.getWebElementByTestID(dataTestId);
192 webElementByTestID = webElementByTestID.findElement(By.className("tlv-checkbox-i"));
193 if(webElementByTestID.getAttribute("checked") == null) {
199 public void verifyPropertyCheckBoxSelected(String dataTestId) {
200 if(!verifyPropertyCheckBox(dataTestId).equals("true")) {
201 Assert.assertEquals(true, false, "Expected that checkbox will be selected.");
205 public void verifyPropertyCheckBoxNotSelected(String dataTestId) {
206 if(!verifyPropertyCheckBox(dataTestId).equals("false")) {
207 Assert.assertEquals(false, true, "Expected that checkbox will not be selected.");
211 public String getNormalizedName(String notNormalizedName) {
212 String normalizedName = notNormalizedName.toLowerCase();
213 normalizedName = normalizedName.replaceAll(" ", "");
215 return normalizedName;
222 protected UserRoleEnum getRole() {
223 return UserRoleEnum.DESIGNER;