2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.ci.tests.utilities;
23 import com.aventstack.extentreports.Status;
24 import org.junit.rules.TestName;
25 import org.openecomp.sdc.be.model.User;
26 import org.openecomp.sdc.be.model.category.CategoryDefinition;
27 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
29 import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
30 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
31 import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
32 import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage;
33 import org.openqa.selenium.Keys;
34 import org.openqa.selenium.WebDriver;
35 import org.openqa.selenium.WebElement;
37 import java.util.ArrayList;
38 import java.util.List;
40 public class ServiceUIUtils {
42 protected static WebDriver driver;
44 public ServiceUIUtils(TestName name, String className) {
48 public static void defineTagsList2(List<String> serviceTags) {
49 WebElement serviceTagsTextbox = GeneralUIUtils.getWebElementByTestID("i-sdc-tag-input");
50 for (String tag : serviceTags) {
51 serviceTagsTextbox.clear();
52 serviceTagsTextbox.sendKeys(tag);
53 GeneralUIUtils.waitForAngular();
54 serviceTagsTextbox.sendKeys(Keys.ENTER);
58 public static void fillServiceGeneralPage(ServiceReqDetails service, User user) throws Exception {
59 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Fill in metadata values in general page"));
60 ServiceGeneralPage.defineName(service.getName());
61 ServiceGeneralPage.defineDescription(service.getDescription());
62 ServiceGeneralPage.defineCategory(service.getCategories().get(0).getName());
63 ServiceGeneralPage.defineProjectCode(service.getProjectCode());
64 defineTagsList2(service.getTags());
65 ServiceGeneralPage.defineContactId(service.getContactId());
66 GeneralUIUtils.clickSomewhereOnPage();
69 public static void createService(ServiceReqDetails service, User user) throws Exception {
71 fillServiceGeneralPage(service, user);
72 GeneralPageElements.clickCreateButton();
73 SetupCDTest.getExtendTest().log(Status.INFO, String.format("The service %s was created", service.getName()));
76 public static void setServiceCategory(ServiceReqDetails service, ServiceCategoriesEnum category) {
77 CategoryDefinition categoryDefinition = new CategoryDefinition();
78 categoryDefinition.setName(category.getValue());
79 List<CategoryDefinition> categories = new ArrayList<>();
80 categories.add(categoryDefinition);
81 service.setCategories(categories);
84 public static void createServiceWithDefaultTagAndUserId(ServiceReqDetails service, User user) {
86 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Defining General Page fields"));
87 ServiceGeneralPage.defineName(service.getName());
88 ServiceGeneralPage.defineDescription(service.getDescription());
89 ServiceGeneralPage.defineCategory(service.getCategories().get(0).getName());
90 ServiceGeneralPage.defineProjectCode(service.getProjectCode());
91 ServiceGeneralPage.defineInstantiationType(service.getInstantiationType());
92 GeneralUIUtils.ultimateWait();
93 GeneralPageElements.clickCreateButton();
94 SetupCDTest.getExtendTest().log(Status.INFO, "Done creating service over the UI, "
95 + "about to move into Tosca Artifacts section.");
98 public static void clickAddService() {
99 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking the Add Service button"));
101 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.Dashboard.ADD_AREA.getValue());
102 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
103 GeneralUIUtils.ultimateWait();
104 } catch (Exception e) {
105 SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Exception on catched on Add Service button, retrying ..."));
106 GeneralUIUtils.hoverOnAreaByClassName("w-sdc-dashboard-card-new");
107 GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.Dashboard.BUTTON_ADD_SERVICE.getValue()).click();
108 GeneralUIUtils.ultimateWait();