[SDC-29] rebase continue work to align source
[sdc.git] / ui-ci-dev / src / main / java / org / openecomp / sdc / uici / tests / execute / service / ServiceInputsTests.java
1 package org.openecomp.sdc.uici.tests.execute.service;
2
3 import static org.testng.AssertJUnit.assertTrue;
4 import static org.testng.AssertJUnit.assertFalse;
5
6 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
7 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
8 import org.openecomp.sdc.uici.tests.datatypes.CanvasElement;
9 import org.openecomp.sdc.uici.tests.datatypes.CanvasManager;
10 import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum;
11 import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.BreadcrumbsButtonsEnum;
12 import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.InputsEnum;
13 import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.ModalItems;
14 import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest;
15 import org.openecomp.sdc.uici.tests.utilities.FileHandling;
16 import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils;
17 import org.openecomp.sdc.uici.tests.utilities.ResourceUIUtils;
18 import org.openecomp.sdc.uici.tests.utilities.ServiceUIUtils;
19 import org.openecomp.sdc.uici.tests.verificator.ServiceVerificator;
20 import org.testng.annotations.Test;
21
22 public class ServiceInputsTests extends SetupCDTest {
23         
24         public String serviceName = "";
25
26         @Test
27         private void testSelectingInputAndAddingItToTheService() {
28                 ServiceInputsTestsSetUp();      
29                 
30                 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
31                 assertTrue(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));
32         }
33         
34         @Test
35         private void testDeletingAnInputFromTheService() {
36                 ServiceInputsTestsSetUp();
37                 
38                 // clicking on the delete input button and accepting the delete
39                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.DELETE_INPUT.getValue()).click();
40                 GeneralUIUtils.getWebElementWaitForClickable(ModalItems.OK.getValue()).click(); 
41                 
42                 assertFalse(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
43                 assertFalse(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));              
44         }
45         
46         @Test
47         private void testCheckingInTheServiceAndButtonsAreDisabled() throws Exception {
48                 ServiceInputsTestsSetUp();
49                 
50                 // Checking in the service and accessing it again in the home
51                 GeneralUIUtils.checkIn();
52                 GeneralUIUtils.closeNotificatin();
53                 GeneralUIUtils.findComponentAndClick(serviceName);
54                 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INPUTS);
55                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.VF_INSTANCE.getValue()).click();
56                 
57                 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
58                 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.SECOND_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
59                 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.DELETE_INPUT.getValue()).getAttribute("class").contains("disabled"));
60         }
61         
62         @Test
63         private void testInputsSanity() throws Exception {
64                 ServiceInputsTestsSetUp();              
65                 
66                 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
67                 assertTrue(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));
68                 
69                 // clicking on the delete input button and accepting the delete
70                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.DELETE_INPUT.getValue()).click();
71                 GeneralUIUtils.getWebElementWaitForClickable(ModalItems.OK.getValue()).click(); 
72                 
73                 assertFalse(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
74                 assertFalse(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));
75                 
76                 // adding the input to the service again
77                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).click();
78                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.ADD_INPUTS_BUTTON.getValue()).click();
79                 
80                 // Checking in the service and accessing it again in the home
81                 GeneralUIUtils.checkIn();
82                 GeneralUIUtils.closeNotificatin();
83                 GeneralUIUtils.findComponentAndClick(serviceName);
84                 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INPUTS);
85                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.VF_INSTANCE.getValue()).click();
86                 
87                 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
88                 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.SECOND_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
89         }
90         
91         private void ServiceInputsTestsSetUp() {
92                 // create vf
93                 String filePath = FileHandling.getResourcesFilesPath();
94                 String fileName = "service_with_inputs.csar";
95                 ResourceReqDetails importVfREsourceInUI = ResourceUIUtils.importVfInUIWithoutCheckin(getUser(), filePath, fileName);
96                 GeneralUIUtils.waitForLoader();
97                 GeneralUIUtils.closeNotificatin();
98                 GeneralUIUtils.checkIn();
99                 GeneralUIUtils.closeNotificatin();
100                 
101                 // create service
102                 ServiceReqDetails createServiceInUI = ServiceUIUtils.createServiceInUI(getUser());
103                 ServiceVerificator.verifyServiceCreated(createServiceInUI, getUser());
104                 serviceName = createServiceInUI.getName();
105                 
106                 // go to composition
107                 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION);
108                 
109                 // drag vf into canvas
110                 CanvasManager canvasManager = CanvasManager.getCanvasManager();
111                 CanvasElement canvasElement = canvasManager.createElementOnCanvas(importVfREsourceInUI.getName());
112                 canvasManager.selectElementFromCanvas(canvasElement);
113                 GeneralUIUtils.waitForLoader();
114                 
115                 // moving to inputs view
116                 GeneralUIUtils.getWebElementWaitForClickable(BreadcrumbsButtonsEnum.COMPONENT.getValue()).click();
117                 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INPUTS);
118                 
119                 // adding the input to the service
120                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.VF_INSTANCE.getValue()).click();
121                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).click();
122                 GeneralUIUtils.getWebElementWaitForClickable(InputsEnum.ADD_INPUTS_BUTTON.getValue()).click();
123         }       
124 }