1 package org.openecomp.sdc.uici.tests.execute.vfc;
3 import static org.testng.AssertJUnit.assertTrue;
6 import java.util.function.Function;
7 import java.util.function.Supplier;
9 import org.apache.commons.collections.CollectionUtils;
10 import org.apache.http.HttpStatus;
11 import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum;
12 import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum;
13 import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest;
14 import org.openecomp.sdc.uici.tests.utilities.FileHandling;
15 import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils;
16 import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils;
17 import org.openecomp.sdc.uici.tests.utilities.RestCDUtils;
18 import org.openecomp.sdc.uici.tests.verificator.VfVerificator;
19 import org.openqa.selenium.WebElement;
20 import org.openqa.selenium.support.ui.Select;
21 import org.testng.annotations.Test;
23 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
24 import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
26 public class VfcBasicTests extends SetupCDTest {
29 public void testRequirementsAndCapabilitiesSectionOfVfc() {
30 String filePath = FileHandling.getResourcesFilesPath();
31 String fileName = "mycompute.yml";
32 ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
33 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.REQUIREMENTS_AND_CAPABILITIES);
34 // all expected requirements
35 assertTrue("Not all expected requirements are displayed.",
36 GeneralUIUtils.isElementPresent("dependency") && GeneralUIUtils.isElementPresent("local_storage"));
37 // filter requirements
38 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ReqAndCapabilitiesSection.SEARCH_BOX.getValue())
40 Supplier<Boolean> supplier = () -> !GeneralUIUtils.isElementPresent("local_storage");
41 Function<Boolean, Boolean> resultVerifier = isNotPresent -> isNotPresent;
42 Boolean isFilteredRowNotPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier);
43 assertTrue("The new property was not inserted to the properties table.", isFilteredRowNotPresent);
44 assertTrue("Filter problem.", GeneralUIUtils.isElementPresent("dependency") && isFilteredRowNotPresent);
46 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ReqAndCapabilitiesSection.CAP_TAB.getValue()).click();
47 GeneralUIUtils.getWebElementWaitForVisible("endpoint").click();
48 GeneralUIUtils.getWebElementWaitForVisible("initiator").click();
49 supplier = () -> GeneralUIUtils.isElementPresent(DataTestIdEnum.PropertyForm.FORM_CONTAINER.getValue());
50 resultVerifier = isPresent -> isPresent;
51 Boolean isPopupOpen = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier);
52 assertTrue("The update property popup was not opened.", isPopupOpen);
56 public void testCreatePropertyTypeListForVfc() {
57 String filePath = FileHandling.getResourcesFilesPath();
58 String fileName = "VFCWithAttributes.yml";
59 ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
60 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.PROPERTIES);
61 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertiesSection.ADD_BUTTON.getValue()).click();
63 String newPropName = "listProperty";
64 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.NAME_FIELD.getValue())
65 .sendKeys(newPropName);
66 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DESCRIPTION_FIELD.getValue())
68 Select typeField = new Select(
69 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.TYPE_FIELD.getValue()));
70 typeField.selectByVisibleText("list");
71 Select schemaTypeField = new Select(
72 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SCHEMA_FIELD.getValue()));
73 schemaTypeField.selectByVisibleText("string");
74 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.LIST_TYPE_DEFAULT_VAL_FIELD.getValue())
76 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.ADD_ITEM_TO_LIST_BUTTON.getValue())
78 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.LIST_TYPE_DEFAULT_VAL_FIELD.getValue())
80 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.ADD_ITEM_TO_LIST_BUTTON.getValue())
83 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SAVE_BUTTON.getValue()).click();
84 Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newPropName);
85 Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent;
86 Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier);
87 assertTrue("The new property was not inserted to the properties table.", isPresent);
91 public void testCreatePropertyTypeMapForVfc() {
92 String filePath = FileHandling.getResourcesFilesPath();
93 String fileName = "VFCWithAttributes.yml";
94 ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
95 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.PROPERTIES);
96 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertiesSection.ADD_BUTTON.getValue()).click();
98 String newPropName = "mapProperty";
99 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.NAME_FIELD.getValue())
100 .sendKeys(newPropName);
101 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DESCRIPTION_FIELD.getValue())
103 Select typeField = new Select(
104 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.TYPE_FIELD.getValue()));
105 typeField.selectByVisibleText("map");
106 Select schemaTypeField = new Select(
107 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SCHEMA_FIELD.getValue()));
108 schemaTypeField.selectByVisibleText("string");
109 // insert item to map
111 .getWebElementWaitForVisible(
112 DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_KEY_FIELD_FOR_FIRST_ITEM.getValue())
115 .getWebElementWaitForVisible(
116 DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_VALUE_FIELD_FOR_FIRST_ITEM.getValue())
118 // insert item to map
119 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.ADD_ITEM_TO_MAP_BUTTON.getValue())
122 .getWebElementWaitForVisible(
123 DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_KEY_FIELD_FOR_SECOND_ITEM.getValue())
126 .getWebElementWaitForVisible(
127 DataTestIdEnum.PropertyForm.MAP_TYPE_DEFAULT_VAL_VALUE_FIELD_FOR_SECOND_ITEM.getValue())
129 // delete item from map
131 .getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DELETE_FIRST_ITEM_FROM_MAP_BUTTON.getValue())
134 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SAVE_BUTTON.getValue()).click();
135 Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newPropName);
136 Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent;
137 Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier);
138 assertTrue("The new property was not inserted to the properties table.", isPresent);
142 public void testCreatePropertyTypeDTForVfc() {
143 String filePath = FileHandling.getResourcesFilesPath();
144 String fileName = "VFCWithAttributes.yml";
145 ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
146 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.PROPERTIES);
147 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertiesSection.ADD_BUTTON.getValue()).click();
149 String newPropName = "dt";
150 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.NAME_FIELD.getValue())
151 .sendKeys(newPropName);
152 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.DESCRIPTION_FIELD.getValue())
154 Select typeField = new Select(
155 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.TYPE_FIELD.getValue()));
156 typeField.selectByValue("org.openecomp.datatypes.heat.contrail.network.rule.PortPairs");
158 .getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.START_PORT_FIELD_FOR_PORT_PAIRS_DT.getValue())
161 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.PropertyForm.SAVE_BUTTON.getValue()).click();
162 Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newPropName);
163 Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent;
164 Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier);
165 assertTrue("The new property was not inserted to the properties table.", isPresent);
169 public void testViewAttributesTabForVfc() {
170 String filePath = FileHandling.getResourcesFilesPath();
171 String fileName = "VFCWithAttributes.yml";
172 ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
173 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES);
175 List<WebElement> attributesRows = GeneralUIUtils
176 .getWebElementsListWaitForVisible(DataTestIdEnum.AttributesSection.TABLE_ROWS.getValue());
177 assertTrue("There is not any row in the table.", !CollectionUtils.isEmpty(attributesRows));
178 // display editable buttons
179 assertTrue("The Add button is not dispaly.",
180 GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.ADD_BUTTON.getValue()));
181 assertTrue("The Edit button is not dispaly for 'network' attribute.", GeneralUIUtils
182 .isElementPresent(DataTestIdEnum.AttributesSection.EDIT_BUTTON_FOR_NETWORK_ATTR.getValue()));
183 assertTrue("The Remove button is not dispaly for 'network' attribute.", GeneralUIUtils
184 .isElementPresent(DataTestIdEnum.AttributesSection.DELETE_BUTTON_FOR_NETWORK_ATTR.getValue()));
186 GeneralUIUtils.checkIn();
188 GeneralUIUtils.getWebElementWaitForVisible(importVfcResourceInUI.getName()).click();
189 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES);
190 // the editable buttons disappear
191 assertTrue("The Add button is not dispaly.",
192 !GeneralUIUtils.isElementPresent(DataTestIdEnum.AttributesSection.ADD_BUTTON.getValue()));
193 assertTrue("The Edit button is not dispaly for 'network' attribute.", !GeneralUIUtils
194 .isElementPresent(DataTestIdEnum.AttributesSection.EDIT_BUTTON_FOR_NETWORK_ATTR.getValue()));
195 assertTrue("The Remove button is not dispaly for 'network' attribute.", !GeneralUIUtils
196 .isElementPresent(DataTestIdEnum.AttributesSection.DELETE_BUTTON_FOR_NETWORK_ATTR.getValue()));
200 public void testCreateAttributeForVfc() {
201 String filePath = FileHandling.getResourcesFilesPath();
202 String fileName = "VFCWithAttributes.yml";
203 ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
204 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES);
205 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributesSection.ADD_BUTTON.getValue()).click();
207 String newAttrName = "attr";
208 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.NAME_FIELD.getValue())
209 .sendKeys(newAttrName);
210 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DESCRIPTION_FIELD.getValue())
212 Select typeField = new Select(
213 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.TYPE_FIELD.getValue()));
214 typeField.selectByVisibleText("integer");
215 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DEFAULT_VAL_FIELD.getValue())
218 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DONE_BUTTON.getValue()).click();
219 Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent(newAttrName);
220 Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent;
221 Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier);
222 assertTrue("The new attribute was not inserted to the attributes table.", isPresent);
226 public void testUpdateTypeForAttributeOfVfc() {
227 String filePath = FileHandling.getResourcesFilesPath();
228 String fileName = "VFCWithAttributes.yml";
229 ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
230 VfVerificator.verifyResourceIsCreated(importVfcResourceInUI);
231 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES);
233 .getWebElementWaitForVisible(DataTestIdEnum.AttributesSection.EDIT_BUTTON_FOR_NETWORK_ATTR.getValue())
236 Select typeField = new Select(
237 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.TYPE_FIELD.getValue()));
238 typeField.selectByVisibleText("float");
240 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.AttributeForm.DONE_BUTTON.getValue()).click();
241 Supplier<Boolean> supplier = () -> GeneralUIUtils.isElementPresent("float");
242 Function<Boolean, Boolean> resultVerifier = isPresent -> isPresent;
243 Boolean isPresent = FunctionalInterfaces.retryMethodOnResult(supplier, resultVerifier);
244 assertTrue("The attribute type was not updated.", isPresent);
248 public void testDeleteAttributeForVfc() {
249 String filePath = FileHandling.getResourcesFilesPath();
250 String fileName = "VFCWithAttributes.yml";
251 ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
252 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.ATTRIBUTES);
254 .getWebElementWaitForVisible(DataTestIdEnum.AttributesSection.DELETE_BUTTON_FOR_NETWORK_ATTR.getValue())
256 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.OK.getValue()).click();
257 GeneralUIUtils.waitForLoader();
258 Boolean retryResult = FunctionalInterfaces
259 .retryMethodOnResult(() -> !GeneralUIUtils.isElementPresent("networks"), boolResult -> boolResult);
260 assertTrue("The attribute is shown in the attributes table.", retryResult);
264 public void testImportVfc() {
265 String filePath = FileHandling.getResourcesFilesPath();
266 String fileName = "CP.yml";
267 ResourceReqDetails importVfcResourceInUI = ResourceUIUtils.importVfcInUI(getUser(), filePath, fileName);
268 assertTrue(RestCDUtils.getResource(importVfcResourceInUI).getErrorCode() == HttpStatus.SC_OK);