re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / DeploymentViewTests.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.execute.sanity;
22
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;
42
43 import java.util.HashMap;
44 import java.util.List;
45 import java.util.Map;
46
47 import static org.testng.Assert.assertTrue;
48
49 public class DeploymentViewTests extends SetupCDTest {
50         
51         private String filePath;
52         
53         @BeforeMethod
54         public void beforeTest(){
55                 filePath = FileHandling.getFilePath("");
56         }
57         
58         @DataProvider(name = "CSAR_VF_Files", parallel = false)
59     public Object[][] createDataX() {
60                 return new Object[][] {{"vSeGWNew.csar"}, {"vSeGWNewDoubleMembers.csar"}, {"vSeGWNewSingleModule.csar"}};
61     }
62         
63         
64         @Test(dataProvider = "CSAR_VF_Files")
65         public void deploymentScreenDCAEAssetImportCSARTest(String baseFileName) throws Exception{
66     //          
67                 setLog(baseFileName);           
68 //              getExtendTest().setDescription(baseFileName);
69                 
70                 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
71                 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
72                 
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);
83                         // Close module
84                         GeneralUIUtils.clickOnElementByText(updatedModuleName);
85                 }
86         }
87         
88         @Test
89         public void deploymentScreenDCAEAssetUpdateWithNewGroupCSAR_TC1368223_Test() throws Exception{          
90                 String baseFileName   = "baseUpdateMinusGroupFlowVF_NEW.csar";
91                 String updateFileName = "baseUpdateFlowVF_NEW.csar";
92                 
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());
96                 
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");}});
100                 
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);             
105
106                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));          
107                 DeploymentViewVerificator.validateModuleNameUpadate();
108         };
109         
110         @Test
111         public void deploymentScreenDCAEAssetDeleteGroupFromCSAR_TC1368281_Test() throws Exception{             
112                 String baseFileName   = "baseUpdateFlowVF_NEW.csar";
113                 String updateFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
114                                 
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());
118                 
119                 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
120                 
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);             
125                 
126                 // validate that group was removed
127                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
128                 
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");}});
132                 
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);
137                 
138                 // validate that group was added
139                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI2, new DeploymentViewVerificator(filePath + baseFileName));
140                 DeploymentViewVerificator.validateModuleNameUpadate();
141         }
142         
143         @Test
144         public void deploymentScreenDCAEAssetUpdateWithNewGroupWithoutMembersCSAR_TC1368280_Test() throws Exception{
145                 
146                 String baseFileName    = "baseUpdateMinusGroupFlowVF_NEW.csar";
147                 String updateFileName  = "baseUpdateAddGroupNoMembersUpdateFlow_NEW.csar";
148                 String updateFileName2 = "baseUpdateFlowVF_NEW.csar";
149                 
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());                          
153                 
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);             
157                 
158                 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
159         
160                 // validate that group was added and no members exist
161                 DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + updateFileName));
162             
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);
167                 
168                 // validate that member was added to base_ldsa group
169                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName2));
170                 DeploymentViewVerificator.validateModuleNameUpadate();
171         };
172         
173         @Test
174         public void deploymentScreenDCAEAssetImportCSARWithArtifactSection_TC1368282_1_Test() throws Exception{         
175                 String baseFileName   = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
176                 
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());                                  
180
181                 DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + baseFileName));
182                 DeploymentViewVerificator.validateModuleNameUpadate();
183         };
184         
185         @Test
186         public void deploymentScreenDCAEAssetImportCSARRemoveArtifact_TC1368282_2_Test() throws Exception{              
187                 String baseFileName   = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
188                 String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
189                 
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());
193                 
194                 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
195                 
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);
200
201                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
202                 DeploymentViewVerificator.validateModuleNameUpadate();
203         };
204         
205         @Test
206         public void deploymentScreenDCAEAssetImportCSARAddArtifact_TC1368282_3_Test() throws Exception{         
207                 String baseFileName   = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
208                 String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
209                 
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());
213                 
214                 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
215                 
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);
220
221                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + baseFileName));
222                 DeploymentViewVerificator.validateModuleNameUpadate();
223         };
224         
225         @Test
226         public void deploymentScreenDCAEAssetImportCSARMixArtifacts_TC1368282_4_Test() throws Exception{                
227                 String baseFileName   = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
228                 String updateFileName = "baseUpdateMixedArtifacts_NEW.csar";
229                 
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());
233                 
234                 Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
235                 
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);
240                 
241                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator());
242                 DeploymentViewVerificator.validateModuleNameUpadate();
243         };
244         
245         @Test
246         public void deploymentScreenDCAEAssetUpdateVFModule_TC1296437_Test() throws Exception{
247                 String baseFileName   = "baseUpdateMinusGroupFlowVF_NEW.csar";
248                 String updateFileName = "baseUpdateFlowVF_NEW.csar";
249                 
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])));
254                 
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");}});
258                 
259                 DeploymentViewVerificator.validateEditPopover();
260                 
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);             
264         
265                 assertTrue(resourceMetaData.getName().equals(ResourceGeneralPage.getNameText()));
266                 DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));          
267                 DeploymentViewVerificator.validateModuleNameUpadate();
268         }
269         
270
271         @Override
272         protected UserRoleEnum getRole() {
273                 return UserRoleEnum.DESIGNER;
274         }
275
276 }