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.utilities;
23 import java.util.HashMap;
26 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
27 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
28 import org.openecomp.sdc.ci.tests.pages.PropertiesPage;
29 import org.openqa.selenium.WebElement;
31 import com.aventstack.extentreports.Status;
33 public class PropertiesUIUtils {
35 // public static void addPropertByType(String type,String name,String
36 // defaultValue,String description) throws Exception{
38 // ResourceUIUtils.defineNewSelectList(type);
39 // ResourceUIUtils.definePropertyName(name);
40 // ResourceUIUtils.defineDefaultValueByType(defaultValue);
41 // ResourceUIUtils.defineDescription(description);
42 // Thread.sleep(2000);
43 // ResourceUIUtils.clickButton("Add");
45 public static Map<String, String> addProperties(String name, String itemType, String defaultValue,
46 String description, String schemaType) throws Exception {
47 Map<String, String> propertyvalues = new HashMap<String, String>();
48 GeneralUIUtils.getSelectList(itemType, "propertyType");
49 ResourceUIUtils.definePropertyName(name);
50 if (itemType == "boolean") {
51 ResourceUIUtils.defineBoolenDefaultValue(defaultValue);
52 GeneralUIUtils.setWebElementByTestId("description","description");
54 GeneralUIUtils.getWebElementByTestID("Add").click();
56 } else if (itemType == "list" || itemType == "map") {
57 GeneralUIUtils.getSelectList(schemaType, "schemaType");
59 if (!(itemType == "boolean")) {
60 ResourceUIUtils.defineDefaultValueByType(defaultValue);
61 GeneralUIUtils.setWebElementByTestId("description", "des");
62 GeneralUIUtils.getWebElementByTestID("Add").click();
66 propertyvalues.put("type", itemType);
67 propertyvalues.put("defaultValue", defaultValue);
68 propertyvalues.put("description", description);
69 propertyvalues.put("name", name);
71 return propertyvalues;
74 public static void vlidateProperties(Map<String, String> propertyValues) throws InterruptedException {
75 WebElement name = GeneralUIUtils.getWebElementByTestID(propertyValues.get("name"));
76 name.getText().equalsIgnoreCase(propertyValues.get("name"));
77 WebElement defaultValue = GeneralUIUtils.getWebElementByTestID(propertyValues.get("name"));
78 defaultValue.getText().equalsIgnoreCase(propertyValues.get("defaultValue"));
79 WebElement type = GeneralUIUtils.getWebElementByTestID(propertyValues.get("type"));
80 type.getText().equalsIgnoreCase(propertyValues.get("type"));
83 public static void addNewProperty(PropertyTypeEnum property) {
84 GeneralUIUtils.ultimateWait();
85 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Adding new %s property", property.name()));
86 PropertiesPage.clickAddPropertyArtifact();
87 PropertiesPage.getPropertyPopup().insertPropertyName(property.getName());
88 PropertiesPage.getPropertyPopup().selectPropertyType(property.getType());
89 PropertiesPage.getPropertyPopup().insertPropertyDescription(property.getDescription());
90 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(property.getValue());
91 PropertiesPage.getPropertyPopup().clickSave();
94 public static void updateProperty(PropertyTypeEnum property) {
95 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating property: %s", property.name()));
96 PropertiesPage.clickOnProperty(property.getName());
97 PropertiesPage.getPropertyPopup().insertPropertyDescription(property.getDescription());
98 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(property.getValue());
99 PropertiesPage.getPropertyPopup().clickSave();
102 public static void changePropertyDefaultValueInComposition(String propertyName, String defaultValue) {
103 GeneralUIUtils.clickOnElementByTestId(propertyName);
104 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(defaultValue);
105 PropertiesPage.getPropertyPopup().clickSave();