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.execute.sanity;
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
25 import org.openecomp.sdc.ci.tests.datatypes.*;
26 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.CatalogPageLeftPanelSubCategoryCheckbox;
27 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
28 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
29 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
30 import org.openecomp.sdc.ci.tests.utilities.*;
31 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
32 import org.openecomp.sdc.ci.tests.verificator.CatalogVerificator;
33 import org.openqa.selenium.WebElement;
34 import org.testng.annotations.BeforeMethod;
35 import org.testng.annotations.DataProvider;
36 import org.testng.annotations.Test;
38 import java.util.Arrays;
39 import java.util.List;
41 import static org.testng.AssertJUnit.assertTrue;
43 @Test(singleThreaded = true)
44 public class CatalogLeftPanelTest extends SetupCDTest{
46 private String filePath;
48 public void beforeTest(){
49 filePath = FileHandling.getFilePath("");
52 public static String[] resourceTypes = Arrays.stream(ResourceTypeEnum.class.getEnumConstants()).
53 map(ResourceTypeEnum::name).toArray(String[]::new);
55 public static String[] catalogTypes = {"RESOURCE", "SERVICE"};
57 public static Object[][] provideData(String[] arObj) {
58 Object[][] arObject = new Object[arObj.length][];
61 for (Object obj : arObj) {
62 arObject[index++] = new Object[]{obj};
67 @DataProvider(name = "Resource_Type_List")
68 private static final Object[][] resourceTypeList(){
69 // Extract names of constants from enum as array of Strings
70 ResourceTypeEnum[] resourceEnums = {ResourceTypeEnum.CP, ResourceTypeEnum.VF, ResourceTypeEnum.VFC, ResourceTypeEnum.VL};
71 String[] resourcesForTest = Arrays.stream(resourceEnums).map(ResourceTypeEnum::name).toArray(String[]::new);
72 return provideData(resourcesForTest);
75 @DataProvider(name = "Type_List")
76 private static final Object[][] typeList(){
77 // Extract names of constants from enum as array of Strings
78 Object[][] arObject = new Object[catalogTypes.length][];
80 for (String catalogType : catalogTypes) {
81 if (catalogType.equals("RESOURCE")){
82 arObject[index++] = new Object[]{catalogType, resourceTypes};
84 arObject[index++] = new Object[]{catalogType, new String[] {catalogType}};
90 @DataProvider(name = "Status_List")
91 private static final Object[][] statusList(){
92 CheckBoxStatusEnum[] checkboxes = {CheckBoxStatusEnum.CERTIFIED,
93 CheckBoxStatusEnum.IN_DESIGN,
94 CheckBoxStatusEnum.DISTRIBUTED,
95 CheckBoxStatusEnum.IN_TESTING,
96 CheckBoxStatusEnum.READY_FOR_TESTING};
97 Object[][] arObject = new Object[checkboxes.length][];
99 for (CheckBoxStatusEnum checkbox: checkboxes) {
100 if (checkbox.equals(CheckBoxStatusEnum.CERTIFIED)){
101 arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CERTIFIED, LifeCycleStateEnum.DISTRIBUTED, LifeCycleStateEnum.WAITING_FOR_DISTRIBUTION) };
102 } else if (checkbox.equals(CheckBoxStatusEnum.IN_DESIGN)) {
103 arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.CHECKIN, LifeCycleStateEnum.CHECKOUT)};
104 } else if (checkbox.equals(CheckBoxStatusEnum.DISTRIBUTED)) {
105 arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.DISTRIBUTED)};
106 } else if (checkbox.equals(CheckBoxStatusEnum.IN_TESTING)) {
107 arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.IN_TESTING)};
108 } else if (checkbox.equals(CheckBoxStatusEnum.READY_FOR_TESTING)) {
109 arObject[index++] = new Object[]{checkbox, Arrays.asList(LifeCycleStateEnum.READY_FOR_TESTING)};
115 // filter by Type Resource in catalog
116 @Test(dataProvider = "Type_List")
117 public void filterByType(String catalogType, String[] classValues ) throws Exception {
119 // getExtendTest().setDescription(catalogType);
121 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
122 CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(catalogType));
124 CatalogVerificator.validateType(TypesEnum.valueOf(catalogType));
127 @Test(dataProvider = "Resource_Type_List")
128 public void filterByResourceType(String resourceType) throws Exception {
129 setLog(resourceType);
130 // getExtendTest().setDescription(resourceType);
132 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
133 CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf(resourceType));
135 CatalogVerificator.validateType(TypesEnum.valueOf(resourceType));
138 @Test(dataProvider = "Status_List")
139 public void filterByStatus(CheckBoxStatusEnum statusCheckbox, List<LifeCycleStateEnum> lifecycleStates) throws Exception{
140 setLog(statusCheckbox.name());
141 // getExtendTest().setDescription(statusCheckbox.name());
143 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
144 CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.CATEGORIES);
145 CatalogUIUtilitis.catalogFilterStatusChecBox(statusCheckbox);
147 CatalogVerificator.validateStatus(lifecycleStates, statusCheckbox.name());
151 public void filterByUpperCategory() throws Exception{
152 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
153 CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE);
155 WebElement categorieCheckbox = CatalogUIUtilitis.clickOnUpperCategoryCheckbox();
157 CatalogVerificator.validateCategory(categorieCheckbox.getAttribute("textContent").trim());
161 public void filterByGenericDtabaseSubCategory() throws Exception{
162 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
163 CatalogUIUtilitis.clickOnLeftPanelElement(DataTestIdEnum.CatalogPageLeftPanelFilterTitle.TYPE);
165 WebElement checkboxElement = GeneralUIUtils.getElementsByCSS(CatalogPageLeftPanelSubCategoryCheckbox.DATABASE.getValue()).get(0);
166 String checkboxElementName = checkboxElement.getAttribute("textContent").trim();
167 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on %s subcategory ...", checkboxElementName));
168 GeneralUIUtils.clickOnAreaJS(checkboxElement);
169 CatalogVerificator.validateSubCategory("Generic", checkboxElementName);
173 public void lastUpdatedService() throws Exception{
175 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
176 ServiceUIUtils.createService(serviceMetadata, getUser());
178 ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName());
179 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
180 List<WebElement> cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue());
181 String firstElementName = cardElements.get(0).getAttribute("textContent").trim();
182 assertTrue(String.format("Wrong element name, Exepected : %s , Actual: %s", serviceMetadata.getName(), firstElementName), serviceMetadata.getName().equals(firstElementName));
186 public void lastUpdatedResource() throws Exception{
188 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
189 ResourceUIUtils.createVF(vfMetaData, getUser());
191 ResourceGeneralPage.clickCheckinButton(vfMetaData.getName());
192 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
193 List<WebElement> cardElements = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DashboardCardEnum.INFO_NAME.getValue());
194 String firstElementName = cardElements.get(0).getAttribute("textContent").trim();
195 assertTrue(String.format("Wrong element name, Exepected : %s , Actual: %s", vfMetaData.getName(), firstElementName), vfMetaData.getName().equals(firstElementName));
199 public void fromCatalogCheckout() throws Exception{
201 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
202 ResourceUIUtils.createVF(vfMetaData, getUser());
204 ResourceGeneralPage.clickCheckinButton(vfMetaData.getName());
205 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
206 GeneralUIUtils.findComponentAndClickInCatalog(vfMetaData.getName());
207 ResourceGeneralPage.clickCheckoutButton();
208 ResourceGeneralPage.clickCheckinButton(vfMetaData.getName());
212 protected UserRoleEnum getRole() {
213 return UserRoleEnum.DESIGNER;