1 package org.openecomp.sdc.uici.tests.execute.service;
3 import static org.testng.AssertJUnit.assertTrue;
4 import static org.testng.AssertJUnit.assertFalse;
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;
22 public class ServiceInputsTests extends SetupCDTest {
24 public String serviceName = "";
27 private void testSelectingInputAndAddingItToTheService() {
28 ServiceInputsTestsSetUp();
30 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
31 assertTrue(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));
35 private void testDeletingAnInputFromTheService() {
36 ServiceInputsTestsSetUp();
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();
42 assertFalse(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
43 assertFalse(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));
47 private void testCheckingInTheServiceAndButtonsAreDisabled() throws Exception {
48 ServiceInputsTestsSetUp();
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();
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"));
63 private void testInputsSanity() throws Exception {
64 ServiceInputsTestsSetUp();
66 assertTrue(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
67 assertTrue(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));
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();
73 assertFalse(GeneralUIUtils.getWebElementWaitForVisible(InputsEnum.FIRST_INPUT_CHECKBOX.getValue()).getAttribute("class").contains("disabled"));
74 assertFalse(GeneralUIUtils.isElementPresent(InputsEnum.SERVICE_INPUT.getValue()));
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();
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();
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"));
91 private void ServiceInputsTestsSetUp() {
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();
102 ServiceReqDetails createServiceInUI = ServiceUIUtils.createServiceInUI(getUser());
103 ServiceVerificator.verifyServiceCreated(createServiceInUI, getUser());
104 serviceName = createServiceInUI.getName();
107 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.COMPOSITION);
109 // drag vf into canvas
110 CanvasManager canvasManager = CanvasManager.getCanvasManager();
111 CanvasElement canvasElement = canvasManager.createElementOnCanvas(importVfREsourceInUI.getName());
112 canvasManager.selectElementFromCanvas(canvasElement);
113 GeneralUIUtils.waitForLoader();
115 // moving to inputs view
116 GeneralUIUtils.getWebElementWaitForClickable(BreadcrumbsButtonsEnum.COMPONENT.getValue()).click();
117 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.INPUTS);
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();