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.resourceui;
23 import static org.testng.AssertJUnit.assertTrue;
25 import java.io.FileWriter;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.List;
30 import org.openecomp.sdc.ci.tests.datatypes.BreadCrumbsButtonsEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.CatalogFilterTitlesEnum;
32 import org.openecomp.sdc.ci.tests.datatypes.CheckBoxStatusEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.CreateAndImportButtonsEnum;
34 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
35 import org.openecomp.sdc.ci.tests.datatypes.TypesEnum;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
37 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
38 import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis;
39 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
40 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
41 import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
42 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
43 import org.openqa.selenium.By;
44 import org.openqa.selenium.WebElement;
45 import org.testng.annotations.BeforeMethod;
46 import org.testng.annotations.Test;
48 public class CatalogLeftFilterPanelCheckBoxTest extends SetupCDTest {
50 public CatalogLeftFilterPanelCheckBoxTest() {
51 // TODO Auto-generated constructor stub
54 private ResourceReqDetails resourceDetails;
55 FileWriter filwriter = GeneralUIUtils.InitializeprintToTxt("CatalogLeftFilterPanelCheckBoxTest");
58 public void beforTest() {
59 resourceDetails = ElementFactory.getDefaultResource();
62 // filter by Type Resource in catalog
64 public void filterByAssetTypeResource() throws Exception {
65 List<WebElement> elements = null;
66 List<String> validValues = Arrays.asList("VF", "VL", "CP", "VFC");
67 GeneralUIUtils.checkIn();
68 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
69 GeneralUIUtils.catalogFilterTypeChecBox(TypesEnum.RESOURCE);
70 GeneralUIUtils.getWorkspaceElements();
71 elements = GeneralUIUtils.waitForElementsListVisibilityTestMethod("asset-type");
72 for (WebElement webElement : elements) {
73 assertTrue(validValues.contains(webElement.getAttribute("class")));
78 public void filterByResourceTypeVF() throws Exception {
79 List<WebElement> elements = null;
80 List<String> validValues = Arrays.asList("VF");
81 GeneralUIUtils.checkIn();
82 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
83 GeneralUIUtils.catalogFilterTypeChecBox(TypesEnum.VF);
84 GeneralUIUtils.getWorkspaceElements();
85 elements = GeneralUIUtils.waitForElementsListVisibilityTestMethod("asset-type");
86 for (WebElement webElement : elements) {
87 assertTrue(validValues.contains(webElement.getAttribute("class")));
92 public void filterByResourceTypeVFC() throws Exception {
93 List<WebElement> elements = null;
94 List<String> validValues = Arrays.asList("VFC");
95 GeneralUIUtils.checkIn();
96 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
97 GeneralUIUtils.catalogFilterTypeChecBox(TypesEnum.VFC);
98 GeneralUIUtils.getWorkspaceElements();
99 elements = GeneralUIUtils.waitForElementsListVisibilityTestMethod("asset-type");
100 for (WebElement webElement : elements) {
101 assertTrue(validValues.contains(webElement.getAttribute("class")));
106 public void filterByResourceTypeCP() throws Exception {
107 List<WebElement> elements = null;
108 List<String> validValues = Arrays.asList("CP");
109 GeneralUIUtils.checkIn();
110 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
111 GeneralUIUtils.catalogFilterTypeChecBox(TypesEnum.CP);
112 GeneralUIUtils.getWorkspaceElements();
113 elements = GeneralUIUtils.waitForElementsListVisibilityTestMethod("asset-type");
114 for (WebElement webElement : elements) {
115 assertTrue(validValues.contains(webElement.getAttribute("class")));
120 public void filterByResourceTypeVL() throws Exception {
121 List<WebElement> elements = null;
122 List<String> validValues = Arrays.asList("VL");
123 GeneralUIUtils.checkIn();
124 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
125 GeneralUIUtils.catalogFilterTypeChecBox(TypesEnum.VL);
126 GeneralUIUtils.getWorkspaceElements();
127 elements = GeneralUIUtils.waitForElementsListVisibilityTestMethod("asset-type");
128 for (WebElement webElement : elements) {
129 assertTrue(validValues.contains(webElement.getAttribute("class")));
134 // public void filterByProducTType() throws Exception{
135 // List<WebElement> elements = null;
136 // List<String> validValues = Arrays.asList("PRODUCT");
137 // GeneralUIUtils.checkIn();
138 // GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
139 // GeneralUIUtils.catalogFilterTypeChecBox(TypesEnum.PRODUCT);
140 // GeneralUIUtils.getWorkspaceElements();
143 // GeneralUIUtils.getEelementsByClassName1("w-sdc-dashboard-card-avatar");
144 // for (WebElement webElement : elements) {
145 // assertTrue(validValues.contains(webElement.findElement(By.xpath(".//*")).getAttribute("class")));
147 // } catch (Exception e) {
148 // System.out.println("No Elements founds!");
153 public void filterByResourceCategories() throws Exception {
154 List<WebElement> elements = null;
155 List<String> validValues = null;
156 GeneralUIUtils.checkIn();
157 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
159 GeneralUIUtils.minimizeCatalogFilterByTitle(CatalogFilterTitlesEnum.TYPE);
160 List<String> categories = CatalogUIUtilitis.abcd();
161 for (String category : categories) {
162 validValues = CatalogUIUtilitis.getAllSubcategoriesByUniqueId(category);
163 boolean bool = false;
165 GeneralUIUtils.getWebElementWaitForVisible(category).click();
167 } catch (Exception e) {
169 GeneralUIUtils.scrollDown();
171 GeneralUIUtils.getWebElementWaitForVisible(category).click();
173 } catch (Exception e2) {
178 String checkBox = GeneralUIUtils.getWebElementWaitForVisible(category).findElement(By.xpath(".//input"))
179 .getAttribute("class");
180 if (checkBox.contains("ng-not-empty") && validValues != null) {
182 GeneralUIUtils.getWorkspaceElements();
183 elements = GeneralUIUtils.getEelementsBycontainsClassName("sprite-resource-icons");
184 for (WebElement webElement : elements) {
185 String elementUniqueId = webElement.getAttribute("data-tests-id");
186 if (!validValues.contains(elementUniqueId)) {
187 System.out.println("assert error!");
190 GeneralUIUtils.getWebElementWaitForVisible(category).click();
191 } catch (Exception e) {
192 GeneralUIUtils.getWebElementWaitForVisible(category).click();
193 System.out.println("No Elements founds!");
199 @SuppressWarnings("null")
201 public void filterByStatus() throws Exception {
203 List<WebElement> elements = null;
204 List<String> validValues = null;
205 List<ResourceReqDetails> createdComponents = new ArrayList<ResourceReqDetails>();
206 List<String> catalogStatuses = Arrays.asList("IN_DESIGN", "READY_FOR_TESTING", "IN_TESTING", "CERTIFIED",
208 GeneralUIUtils.checkIn();
209 for (int i = 1; i < catalogStatuses.size() - 1; i++) {
210 GeneralUIUtils.sleep(3000);
211 GeneralUIUtils.createAndImportButtons(CreateAndImportButtonsEnum.CREATE_VF, GeneralUIUtils.getDriver());
212 resourceDetails.setName(getRandomComponentName("ResourceCDTest-"));
213 ResourceUIUtils.createResourceInUI(resourceDetails, getUser());
214 GeneralUIUtils.clickSubmitForTest();
215 if (catalogStatuses.get(i) == "IN_TESTING") {
216 GeneralUIUtils.testerUser(true, false, resourceDetails);
217 GeneralUIUtils.sleep(3000);
218 navigateToUrl(getUrl());
221 if (catalogStatuses.get(i) == "CERTIFIED") {
222 GeneralUIUtils.testerUser(true, true, resourceDetails);
223 GeneralUIUtils.sleep(3000);
224 navigateToUrl(getUrl());
226 if (catalogStatuses.get(i) == "DISTRIBUTED") {
227 GeneralUIUtils.testerUser(true, true, resourceDetails);
228 GeneralUIUtils.governorUser(false, true, resourceDetails);
229 GeneralUIUtils.opsUser(true, false, resourceDetails);
230 GeneralUIUtils.sleep(3000);
231 navigateToUrl(getUrl());
234 createdComponents.add(resourceDetails);
236 GeneralUIUtils.clickBreadCrumbs(BreadCrumbsButtonsEnum.CATALOG);
237 // get filters title close.
239 GeneralUIUtils.minimizeCatalogFilterByTitle(CatalogFilterTitlesEnum.TYPE);
240 GeneralUIUtils.minimizeCatalogFilterByTitle(CatalogFilterTitlesEnum.CATEGORIES);
241 for (CheckBoxStatusEnum statusEnum : CheckBoxStatusEnum.values()) {
242 if (catalogStatuses.contains(statusEnum.name().toString())) {
243 validValues = GeneralUIUtils.catalogFilterStatusChecBox(statusEnum);
244 if (GeneralUIUtils.getWorkspaceElements().size() > 0) {
245 String checkBox = GeneralUIUtils.getWebElementByName(statusEnum.getCatalogValue())
246 .getAttribute("class");
247 if (checkBox.contains("ng-not-empty") && validValues != null) {
249 elements = GeneralUIUtils.getEelementsBycontainsClassName("w-sdc-dashboard-card-edit");
250 for (WebElement webElement : elements) {
251 String className = webElement.getAttribute("class");
252 String textCategory = className.substring(className.indexOf(" "));
253 assertTrue(validValues.contains(textCategory.replace(" ", "")));
255 GeneralUIUtils.catalogFilterStatusChecBox(statusEnum);
256 } catch (Exception e) {
257 GeneralUIUtils.catalogFilterStatusChecBox(statusEnum);
258 System.out.println("No Elements founds!");
269 protected UserRoleEnum getRole() {
270 return UserRoleEnum.DESIGNER;