[SDC-29] rebase continue work to align source
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / pages / TesterOperationPage.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 org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
24 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
25 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
26
27 import com.aventstack.extentreports.Status;
28
29 public class TesterOperationPage {
30
31         public TesterOperationPage() {
32                 super();
33         }
34
35         public static void certifyComponent(String componentName) throws Exception{
36                 clickStartTestingButton();
37                 clickAccpetCertificationButton(componentName);
38         }
39
40         public static void clickAccpetCertificationButton(String componentName) throws Exception {
41                 ExtentTestActions.log(Status.INFO, "Accepting certifiction of " + componentName);
42                 String actionDuration = GeneralUIUtils.getActionDuration(() ->
43                 {
44                         try {
45                                 clickAccpetCertificationButtonWithoutDuration(componentName);
46                         } catch (Exception e) {
47                                 e.printStackTrace();
48                         }
49                 });
50                 ExtentTestActions.log(Status.INFO, componentName + " is certifed", actionDuration);
51
52         }
53         
54         public static void clickStartTestingButton() throws Exception{
55                 ExtentTestActions.log(Status.INFO, "Starting to test");
56                 String actionDuration = GeneralUIUtils.getActionDuration(() -> {
57                         try {
58                                 clickStartTestingButtonWithoutDuration();
59                         } catch (Exception e) {
60                                 e.printStackTrace();
61                         }
62                 });
63                 ExtentTestActions.log(Status.INFO, "Ready for certification", actionDuration);
64         }
65         
66         
67         private static void certifyComponentWithoutDuration(String componentName) throws Exception {
68                 clickStartTestingButtonWithoutDuration();
69                 clickAccpetCertificationButtonWithoutDuration(componentName);
70         }
71         
72         
73         private static void clickAccpetCertificationButtonWithoutDuration(String componentName) throws Exception {
74                 try{
75                         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue());
76                         GeneralUIUtils.ultimateWait();
77                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.ACCEP_TESTING_MESSAGE.getValue()).sendKeys(componentName + " tested successfuly");
78                         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ModalItems.OK.getValue());
79                         GeneralUIUtils.ultimateWait();
80                         GeneralUIUtils.sleep(2000);
81                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue());
82                 }
83                 catch (Exception e){
84                         throw new Exception("Accepting certification of " + componentName + " falied");
85                 }
86         }
87         
88         private static void clickStartTestingButtonWithoutDuration() throws Exception {
89                 try{
90                         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.LifeCyleChangeButtons.START_TESTING.getValue());
91 //                      GeneralUIUtils.ultimateWait();
92                         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.LifeCyleChangeButtons.ACCEPT.getValue());
93 //                      GeneralUIUtils.ultimateWait();
94 //                      GeneralUIUtils.sleep(1000);
95                 }
96                 catch (Exception e){
97                         throw new Exception("Start testing falied");
98                 }
99         }
100
101 }