[SDC-29] rebase continue work to align source
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / pages / ResourceGeneralPage.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.pages;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
27 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
28 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
29 import org.openqa.selenium.Keys;
30 import org.openqa.selenium.WebElement;
31
32
33 public class ResourceGeneralPage extends GeneralPageElements {
34
35         public ResourceGeneralPage() {
36                 super();
37         }
38
39         public static WebElement getNameField() {
40                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.RESOURCE_NAME.getValue());
41         }
42
43         public static WebElement getDescriptionField() {
44                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.DESCRIPTION.getValue());
45         }
46
47         public static String getCategoryDataTestsIdAttribute() {
48                 return DataTestIdEnum.ResourceMetadataEnum.CATEGORY.getValue();
49         }
50
51         public static WebElement getVendorNameField() {
52                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_NAME.getValue());
53         }
54
55         public static WebElement getVendorReleaseField() {
56                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.VENDOR_RELEASE.getValue());
57         }
58
59         public static WebElement getTagsField() {
60                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS.getValue());
61         }
62
63         public static WebElement getContactIdField() {
64                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ResourceMetadataEnum.CONTACT_ID.getValue());
65         }
66
67         /***************************************************************/
68
69         public static String getNameText() {
70                 return getNameField().getAttribute("value");
71         }
72
73         public static void defineName(String resourceName) {
74                 WebElement resourceNameTextbox = getNameField();
75                 resourceNameTextbox.clear();
76                 resourceNameTextbox.sendKeys(resourceName);
77         }
78         
79         public static void defineNameWithPaste() {
80                 defineTextBoxWithPaste(getNameField());
81         }
82
83         public static String getDescriptionText() {
84                 return getDescriptionField().getAttribute("value");
85         }
86
87         public static void defineDescription(String description) {
88                 WebElement descriptionTextbox = getDescriptionField();
89                 descriptionTextbox.clear();
90                 descriptionTextbox.sendKeys(description);
91         }
92         
93         public static void defineDescriptionWithPaste() {
94                 defineTextBoxWithPaste(getDescriptionField());
95         }
96
97         public static String getVendorNameText() {
98                 return getVendorNameField().getAttribute("value");
99         }
100
101         public static void defineVendorName(String vendorName) {
102                 WebElement vendorNameTextbox = getVendorNameField();
103                 vendorNameTextbox.clear();
104                 vendorNameTextbox.sendKeys(vendorName);
105         }
106         
107         public static void defineVendorNameWithPaste() {
108                 defineTextBoxWithPaste(getVendorNameField());
109         }
110
111         public static String getVendorReleaseText() {
112                 return getVendorReleaseField().getAttribute("value");
113         }
114
115         public static void defineVendorRelease(String vendorRelease) {
116                 WebElement vendorReleaseTextbox = getVendorReleaseField();
117                 vendorReleaseTextbox.clear();
118                 vendorReleaseTextbox.sendKeys(vendorRelease);
119         }
120         
121         public static void defineVendorReleaseWithPaste() {
122                 defineTextBoxWithPaste(getVendorReleaseField());
123         }
124
125         public static void defineTag(String resourceTags) {
126                 WebElement tagTextbox = getTagsField();
127                 tagTextbox.clear();
128                 tagTextbox.sendKeys(resourceTags);
129                 tagTextbox.sendKeys(Keys.ENTER);
130         }
131
132         public static void defineTagsList(ComponentReqDetails component, String[] tags) {
133                 List<String> taglist = new ArrayList<String>();
134                 WebElement resourceTagsTextbox = getTagsField();
135                 for (String tag : tags) {
136                         resourceTagsTextbox.clear();
137                         resourceTagsTextbox.sendKeys(tag);
138                         GeneralUIUtils.sleep(500);
139                         resourceTagsTextbox.sendKeys(Keys.ENTER);
140                         taglist.add(tag);
141                 }
142                 component.getTags().addAll(taglist);
143         }
144         
145         public static void defineTagsListWithPaste() {
146                 List<String> taglist = new ArrayList<String>();
147                 WebElement resourceTagsTextbox = getTagsField();
148                 defineTextBoxWithPaste(resourceTagsTextbox);
149                 resourceTagsTextbox.sendKeys(Keys.ENTER);
150         }
151
152         public static void defineCategory(String category) {
153                 GeneralUIUtils.getSelectList(category, getCategoryDataTestsIdAttribute());
154         }
155
156         public static String getContactIdText() {
157                 return getContactIdField().getAttribute("value");
158         }
159
160         public static void defineContactId(String userId) {
161                 WebElement contactIdTextbox = getContactIdField();
162                 contactIdTextbox.clear();
163                 contactIdTextbox.sendKeys(userId);
164                 GeneralUIUtils.waitForLoader();
165         }
166         
167         public static List<WebElement> getElementsFromTagsTable(){
168                 return GeneralUIUtils.getWebElementsListByTestID(DataTestIdEnum.ResourceMetadataEnum.TAGS_TABLE.getValue());
169         }
170         
171         public static void defineTextBoxWithPaste(WebElement textBox) {
172                 textBox.clear();
173                 textBox.sendKeys(Keys.CONTROL + "v");
174                 GeneralUIUtils.ultimateWait();
175         }
176         
177 }