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.DataTestIdEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
27 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
29 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
30 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
31 import org.openecomp.sdc.ci.tests.pages.DeploymentPage;
32 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
33 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
34 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
35 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
36 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
37 import org.openecomp.sdc.ci.tests.verificator.DeploymentViewVerificator;
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 String filePath;
54 public void beforeTest(){
55 filePath = FileHandling.getFilePath("");
58 @DataProvider(name = "CSAR_VF_Files", parallel = false)
59 public Object[][] createDataX() {
60 return new Object[][] {{"vSeGWNew.csar"}, {"vSeGWNewDoubleMembers.csar"}, {"vSeGWNewSingleModule.csar"}};
64 @Test(dataProvider = "CSAR_VF_Files")
65 public void deploymentScreenDCAEAssetImportCSARTest(String baseFileName) throws Exception{
68 // getExtendTest().setDescription(baseFileName);
70 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
71 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
73 ResourceGeneralPage.getLeftMenu().moveToDeploymentViewScreen();
74 List<WebElement> moduleRowsFromTable = GeneralUIUtils.getElementsByCSS(DataTestIdEnum.DeploymentScreen.MODULES.getValue());
75 DeploymentViewVerificator verificator = new DeploymentViewVerificator(filePath + baseFileName);
76 verificator.verifyDeploymentPageModules(moduleRowsFromTable);
77 for(WebElement moduleRow : moduleRowsFromTable){
78 String moduleRowText = moduleRow.getText();
79 verificator.verifyDeploymentPageSubElements(moduleRowText.split("\\.\\.")[1]);
80 DeploymentPage.updateModuleName(moduleRowText, "updatedName");
81 String updatedModuleName = DeploymentPage.reconstructModuleName(moduleRowText.split("\\.\\."), "updatedName");
82 verificator.verifyComponentNameChanged( moduleRowText, updatedModuleName);
84 GeneralUIUtils.clickOnElementByText(updatedModuleName);
89 public void deploymentScreenDCAEAssetUpdateWithNewGroupCSAR_TC1368223_Test() throws Exception{
90 String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
91 String updateFileName = "baseUpdateFlowVF_NEW.csar";
93 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
94 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2));
95 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
97 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
98 metaDataFromUI.put("base_ldsa", new HashMap<String, String> (){ {put("version", "0");
99 put("moduleID", "primary");}});
101 // add new group, base_ldsa
102 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
103 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", 3));
104 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
106 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
107 DeploymentViewVerificator.validateModuleNameUpadate();
111 public void deploymentScreenDCAEAssetDeleteGroupFromCSAR_TC1368281_Test() throws Exception{
112 String baseFileName = "baseUpdateFlowVF_NEW.csar";
113 String updateFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
115 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
116 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 3));
117 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
119 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
121 // remove group base_ldsa
122 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
123 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be removed", 2));
124 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
126 // validate that group was removed
127 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
129 Map<String, HashMap<String, String>> metaDataFromUI2 = DeploymentPage.collectMetaDataFromUI();
130 metaDataFromUI2.put("base_ldsa", new HashMap<String, String> (){ {put("version", "0");
131 put("moduleID", "primary");}});
133 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
134 // add group base_ldsa
135 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group should be added", 3));
136 ResourceUIUtils.updateVfWithCsar(filePath, baseFileName);
138 // validate that group was added
139 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI2, new DeploymentViewVerificator(filePath + baseFileName));
140 DeploymentViewVerificator.validateModuleNameUpadate();
144 public void deploymentScreenDCAEAssetUpdateWithNewGroupWithoutMembersCSAR_TC1368280_Test() throws Exception{
146 String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
147 String updateFileName = "baseUpdateAddGroupNoMembersUpdateFlow_NEW.csar";
148 String updateFileName2 = "baseUpdateFlowVF_NEW.csar";
150 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
151 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2));
152 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
154 // add new group without members, base_ldsa
155 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group without members", 3));
156 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
158 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
160 // validate that group was added and no members exist
161 DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + updateFileName));
163 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
164 // add group base_ldsa with members
165 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now, base_ldsa group with members", 3));
166 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName2);
168 // validate that member was added to base_ldsa group
169 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName2));
170 DeploymentViewVerificator.validateModuleNameUpadate();
174 public void deploymentScreenDCAEAssetImportCSARWithArtifactSection_TC1368282_1_Test() throws Exception{
175 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
177 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
178 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3));
179 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
181 DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + baseFileName));
182 DeploymentViewVerificator.validateModuleNameUpadate();
186 public void deploymentScreenDCAEAssetImportCSARRemoveArtifact_TC1368282_2_Test() throws Exception{
187 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
188 String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
190 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
191 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3));
192 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
194 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
196 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
197 // remove artifact from every group
198 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 3 artifacts in every group"));
199 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
201 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
202 DeploymentViewVerificator.validateModuleNameUpadate();
206 public void deploymentScreenDCAEAssetImportCSARAddArtifact_TC1368282_3_Test() throws Exception{
207 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
208 String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
210 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
211 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 3 artifacts in every group ", 3));
212 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, updateFileName, getUser());
214 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
216 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
217 // add artifact to every group
218 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be 4 artifacts in every group"));
219 ResourceUIUtils.updateVfWithCsar(filePath, baseFileName);
221 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + baseFileName));
222 DeploymentViewVerificator.validateModuleNameUpadate();
226 public void deploymentScreenDCAEAssetImportCSARMixArtifacts_TC1368282_4_Test() throws Exception{
227 String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
228 String updateFileName = "baseUpdateMixedArtifacts_NEW.csar";
230 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
231 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups, should be 4 artifacts in every group ", 3));
232 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
234 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
236 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
237 //mix artifacts between groups
238 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, mixing between artifacts and groups", 3));
239 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
241 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator());
242 DeploymentViewVerificator.validateModuleNameUpadate();
246 public void deploymentScreenDCAEAssetUpdateVFModule_TC1296437_Test() throws Exception{
247 String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
248 String updateFileName = "baseUpdateFlowVF_NEW.csar";
250 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
251 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating resource with %s groups ", 2));
252 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
253 // SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating %s group version, should be %s ", moduleRowText, metaDataFromUI.get(moduleRowText.split("\\.\\.")[1])));
255 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
256 metaDataFromUI.put("base_ldsa", new HashMap<String, String> (){ {put("version", "0");
257 put("moduleID", "primary");}});
259 DeploymentViewVerificator.validateEditPopover();
261 ResourceGeneralPage.getLeftMenu().moveToGeneralScreen();
262 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Updating VF with new file, should be %s groups now", 3));
263 ResourceUIUtils.updateVfWithCsar(filePath, updateFileName);
265 assertTrue(resourceMetaData.getName().equals(ResourceGeneralPage.getNameText()));
266 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
267 DeploymentViewVerificator.validateModuleNameUpadate();
272 protected UserRoleEnum getRole() {
273 return UserRoleEnum.DESIGNER;