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.onap.sdc.frontend.ci.tests.execute.sanity;
23 import com.aventstack.extentreports.Status;
24 import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum;
25 import org.onap.sdc.backend.ci.tests.datatypes.ResourceReqDetails;
26 import org.onap.sdc.backend.ci.tests.datatypes.enums.NormativeTypesEnum;
27 import org.onap.sdc.backend.ci.tests.datatypes.enums.ResourceCategoryEnum;
28 import org.onap.sdc.frontend.ci.tests.pages.DeploymentPage;
29 import org.onap.sdc.frontend.ci.tests.utilities.FileHandling;
30 import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
31 import org.onap.sdc.frontend.ci.tests.utilities.ResourceUIUtils;
32 import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory;
33 import org.onap.sdc.frontend.ci.tests.verificator.DeploymentViewVerificator;
34 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
35 import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum;
36 import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
37 import org.onap.sdc.frontend.ci.tests.pages.ResourceGeneralPage;
38 import org.openqa.selenium.WebElement;
39 import org.testng.annotations.BeforeMethod;
40 import org.testng.annotations.DataProvider;
41 import org.testng.annotations.Test;
43 import java.util.HashMap;
44 import java.util.List;
47 import static org.testng.Assert.assertTrue;
49 public class DeploymentViewTests extends SetupCDTest {
51 private static final int EXPECTED_NUMBER_OF_GROUPS = 3;
52 private String filePath;
55 public void beforeTest() {
56 filePath = FileHandling.getFilePath("");
59 @DataProvider(name = "CSAR_VF_Files", parallel = false)
60 public Object[][] createDataX() {
61 return new Object[][]{{"vSeGWNew.csar"}, {"vSeGWNewDoubleMembers.csar"}, {"vSeGWNewSingleModule.csar"}};
65 @Test(dataProvider = "CSAR_VF_Files")
66 public void deploymentScreenDCAEAssetImportCSARTest(String baseFileName) throws Exception {
69 // getExtendTest().setDescription(baseFileName);
71 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
72 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
74 ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen();
75 List<WebElement> moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue());
76 DeploymentViewVerificator verificator = new DeploymentViewVerificator(filePath + baseFileName);
77 verificator.verifyDeploymentPageModules(moduleRowsFromTable);
78 for (WebElement moduleRow : moduleRowsFromTable) {
79 String moduleRowText = moduleRow.getText();
80 verificator.verifyDeploymentPageSubElements(moduleRowText.split("\\.\\.")[1]);
81 DeploymentPage.updateModuleName(moduleRowText, "updatedName");
82 String updatedModuleName = DeploymentPage.reconstructModuleName(moduleRowText.split("\\.\\."), "updatedName");
83 verificator.verifyComponentNameChanged(moduleRowText, updatedModuleName);
85 GeneralUIUtils.clickOnElementByText(updatedModuleName);
90 public void deploymentScreenDCAEAssetUpdateWithNewGroupCSAR_TC1368223_Test() throws Exception {
91 String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
92 String updateFileName = "baseUpdateFlowVF_NEW.csar";
94 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
95 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2));
96 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
98 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
99 metaDataFromUI.put("base_ldsa", new HashMap<String, String>() {
102 put("moduleID", "primary");
106 // add new group, base_ldsa
107 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
108 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", EXPECTED_NUMBER_OF_GROUPS));
109 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
111 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
112 DeploymentViewVerificator.validateModuleNameUpadate();
116 public void deploymentScreenDCAEAssetDeleteGroupFromCSAR_TC1368281_Test() throws Exception {
117 String baseFileName = "baseUpdateFlowVF_NEW.csar";
118 String updateFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
120 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
121 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", EXPECTED_NUMBER_OF_GROUPS));
122 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
124 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
126 // remove group base_ldsa
127 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
128 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be removed", 2));
129 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
131 // validate that group was removed
132 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
134 Map<String, HashMap<String, String>> metaDataFromUI2 = DeploymentPage.collectMetaDataFromUI();
135 metaDataFromUI2.put("base_ldsa", new HashMap<String, String>() {
138 put("moduleID", "primary");
142 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
143 // add group base_ldsa
144 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be added", EXPECTED_NUMBER_OF_GROUPS));
145 ResourceUIUtils.updateVfWithCsar(filePath, baseFileName);
147 // validate that group was added
148 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI2, new DeploymentViewVerificator(filePath + baseFileName));
149 DeploymentViewVerificator.validateModuleNameUpadate();
153 public void deploymentScreenDCAEAssetUpdateWithNewGroupWithoutMembersCSAR_TC1368280_Test() throws Exception {
155 String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
156 String updateFileName = "baseUpdateAddGroupNoMembersUpdateFlow_NEW.csar";
157 String updateFileName2 = "baseUpdateFlowVF_NEW.csar";
159 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
160 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2));
161 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
163 // add new group without members, base_ldsa
164 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group without members", EXPECTED_NUMBER_OF_GROUPS));
165 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
167 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
169 // validate that group was added and no members exist
170 DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + updateFileName));
172 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
173 // add group base_ldsa with members
174 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group with members", EXPECTED_NUMBER_OF_GROUPS));
175 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName2);
177 // validate that member was added to base_ldsa group
178 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName2));
179 DeploymentViewVerificator.validateModuleNameUpadate();
184 public void deploymentScreenDCAEAssetImportCSARWithArtifactSection_TC1368282_1_Test() throws Exception {
185 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
187 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
188 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS));
189 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
191 DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + baseFileName));
192 DeploymentViewVerificator.validateModuleNameUpadate();
196 public void deploymentScreenDCAEAssetImportCSARRemoveArtifact_TC1368282_2_Test() throws Exception {
197 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
198 String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
200 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
201 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS));
202 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
204 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
206 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
207 // remove artifact from every group
208 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 3 artifacts in every group"));
209 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
211 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
212 DeploymentViewVerificator.validateModuleNameUpadate();
216 public void deploymentScreenDCAEAssetImportCSARAddArtifact_TC1368282_3_Test() throws Exception {
217 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
218 String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
220 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
221 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 3 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS));
222 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, updateFileName, getUser());
224 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
226 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
227 // add artifact to every group
228 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 4 artifacts in every group"));
229 ResourceUIUtils.updateVfWithCsar(filePath, baseFileName);
231 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + baseFileName));
232 DeploymentViewVerificator.validateModuleNameUpadate();
236 public void deploymentScreenDCAEAssetImportCSARMixArtifacts_TC1368282_4_Test() throws Exception {
237 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
238 String updateFileName = "baseUpdateMixedArtifacts_NEW.csar";
240 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
241 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", EXPECTED_NUMBER_OF_GROUPS));
242 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
244 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
246 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
247 //mix artifacts between groups
248 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, mixing between artifacts and groups", EXPECTED_NUMBER_OF_GROUPS));
249 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
251 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator());
252 DeploymentViewVerificator.validateModuleNameUpadate();
256 public void deploymentScreenDCAEAssetUpdateVFModule_TC1296437_Test() throws Exception {
257 String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
258 String updateFileName = "baseUpdateFlowVF_NEW.csar";
260 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
261 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2));
262 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
263 // SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating %s group version, should be %s ", moduleRowText, metaDataFromUI.get(moduleRowText.split("\\.\\.")[1])));
265 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
266 metaDataFromUI.put("base_ldsa", new HashMap<String, String>() {
269 put("moduleID", "primary");
273 DeploymentViewVerificator.validateEditPopover();
275 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
276 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", EXPECTED_NUMBER_OF_GROUPS));
277 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
279 assertTrue(resourceMetaData.getName().equals(ResourceGeneralPage.getNameText()));
280 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
281 DeploymentViewVerificator.validateModuleNameUpadate();
286 protected UserRoleEnum getRole() {
287 return UserRoleEnum.DESIGNER;