[SDC-29] rebase continue work to align source
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / datatypes / UserManagementTab.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.datatypes;
22
23 import java.util.List;
24
25 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
26 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
27 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
28 import org.openqa.selenium.WebElement;
29
30 import com.aventstack.extentreports.Status;
31
32 public class UserManagementTab {
33
34         public void searchUser(String searchCriterion){
35                 ExtentTestActions.log(Status.INFO, "Searching a user by the value : " + searchCriterion);
36                 WebElement searchBoxWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.SEARCH_BOX.getValue());
37                 searchBoxWebElement.clear();
38                 searchBoxWebElement.sendKeys(searchCriterion);
39                 GeneralUIUtils.ultimateWait();
40         }
41         
42         public void setNewUserBox(String user){
43                 ExtentTestActions.log(Status.INFO, "Inserting userid " + user);
44                 WebElement createNewUserWebElement = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.NEW_USER_FIELD.getValue());
45                 createNewUserWebElement.clear();
46                 createNewUserWebElement.sendKeys(user);
47                 GeneralUIUtils.ultimateWait();
48         }
49         
50         public void selectUserRole(UserRoleEnum userRole){
51                 String role = userRole.name().toLowerCase();
52                 ExtentTestActions.log(Status.INFO, "Selecting role " + userRole.name());
53                 GeneralUIUtils.getSelectList(role, DataTestIdEnum.UserManagementEnum.ROLE_SELECT.getValue());
54         }
55         
56         public void updateUserRole(UserRoleEnum userRole, int rowIndx){
57                 String role = userRole.name().toLowerCase();
58                 ExtentTestActions.log(Status.INFO, "Updating the user role to " + userRole.name());
59                 GeneralUIUtils.getSelectList(role, DataTestIdEnum.UserManagementEnum.UPDATE_ROLE.getValue() + rowIndx);
60         }
61         
62         public void clickCreateButton(){
63                 ExtentTestActions.log(Status.INFO, "Clicking on 'Create' button.");
64                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.CREATE_BUTTON.getValue());
65         }
66         
67         public WebElement getRow(int index){
68                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.ROW_TABLE.getValue() + index);
69         }
70         
71         public WebElement getFirstName(int index){
72                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.FIRST_NAME.getValue() + index);
73         }
74         
75         public WebElement getLastName(int index){
76                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.LAST_NAME.getValue() + index);
77         }
78         
79         public WebElement getUserId(int index){
80                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.USER_ID.getValue() + index);
81         }
82         
83         public WebElement getEmail(int index){
84                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.EMAIL.getValue() + index);
85         }
86         
87         public WebElement getRole(int index){
88                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.ROLE.getValue() + index);
89         }
90         
91         public WebElement getLastActive(int index){
92                 return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.UserManagementEnum.LAST_ACTIVE.getValue() + index);
93         }
94         
95         public void updateUser(int index){
96                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.UPDATE_USER_BUTTON.getValue() + index);
97         }
98         
99         public void deleteUser(int index){
100                 ExtentTestActions.log(Status.INFO, "Deleting the user in row " + (index + 1));
101                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.DELETE_USER.getValue() + index);
102                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue());
103         }
104         
105         public void saveAfterUpdateUser(int index){
106                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.UserManagementEnum.SAVE_USER.getValue() + index);
107         }
108         
109         public List<WebElement> getAllRowsDisplayed(){
110                 return GeneralUIUtils.getWebElementsListByContainTestID(DataTestIdEnum.UserManagementEnum.ROW_TABLE.getValue());
111         }
112         
113         
114 }