a75240d2b219f08175399f4b5a7218f492de1548
[sdc.git] /
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.execute.resourceui;
22
23 import static org.testng.AssertJUnit.assertTrue;
24
25 import java.util.List;
26
27 import org.openecomp.sdc.ci.tests.datatypes.BreadCrumbsButtonsEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
29 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
30 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
31 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
32 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
33 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
34 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
35 import org.openqa.selenium.WebElement;
36 import org.testng.annotations.BeforeMethod;
37 import org.testng.annotations.Test;
38
39 public class ChangeLifeCycleStatFromCatalogTest extends SetupCDTest {
40
41         public ChangeLifeCycleStatFromCatalogTest() {
42                 // TODO Auto-generated constructor stub
43         }
44
45         // This test check the status filter .
46
47         private ResourceReqDetails resourceDetails;
48
49         @BeforeMethod
50         public void beforTest() {
51                 resourceDetails = ElementFactory.getDefaultResource();
52         }
53
54         @Test
55         public void checkInFromCatalog() throws InterruptedException {
56                 GeneralUIUtils.clickSaveIcon();
57                 GeneralUIUtils.clickASDCLogo();
58                 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
59                 GeneralUIUtils.catalogSearchBox(resourceDetails.getName());
60                 List<WebElement> assets = GeneralUIUtils.getWorkspaceElements();
61                 if (assets.isEmpty()) {
62                         System.out.println("error elements not found.");
63                 } else {
64                         for (WebElement webElement : assets) {
65                                 webElement.click();
66                                 GeneralUIUtils.checkIn();
67                                 GeneralUIUtils.getWebElementWaitForVisible(resourceDetails.getName()).click();
68                                 Thread.sleep(2000);
69                                 System.out.println(ResourceUIUtils.lifeCycleStateUI());
70                                 System.out.println(LifeCycleStateEnum.CHECKIN.getValue());
71                                 assertTrue(ResourceUIUtils.lifeCycleStateUI().contentEquals(LifeCycleStateEnum.CHECKIN.getValue()));
72
73                         }
74                 }
75
76         }
77
78         @Test
79         public void checkOutFromCatalog() throws Exception {
80                 GeneralUIUtils.clickSaveIcon();
81                 GeneralUIUtils.clickASDCLogo();
82                 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
83                 GeneralUIUtils.catalogSearchBox(resourceDetails.getName());
84                 List<WebElement> assets = GeneralUIUtils.getWorkspaceElements();
85                 if (assets.isEmpty()) {
86                         System.out.println("error elements not found.");
87                 } else {
88                         for (WebElement webElement : assets) {
89                                 webElement.click();
90                                 GeneralUIUtils.checkinCheckout(resourceDetails.getName());
91                                 assertTrue(ResourceUIUtils.lifeCycleStateUI().contentEquals(LifeCycleStateEnum.CHECKOUT.getValue()));
92
93                         }
94                 }
95
96         }
97
98         @Override
99         protected UserRoleEnum getRole() {
100                 return UserRoleEnum.DESIGNER;
101         }
102
103 }