f513a49fbf381473823ec5645c45c18dbd93d5be
[sdc.git] /
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.onap.sdc.frontend.ci.tests.execute.sanity;
22
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;
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 static final int EXPECTED_NUMBER_OF_GROUPS = 3;
52     private String filePath;
53
54     @BeforeMethod
55     public void beforeTest() {
56         filePath = FileHandling.getFilePath("");
57     }
58
59     @DataProvider(name = "CSAR_VF_Files", parallel = false)
60     public Object[][] createDataX() {
61         return new Object[][]{{"vSeGWNew.csar"}, {"vSeGWNewDoubleMembers.csar"}, {"vSeGWNewSingleModule.csar"}};
62     }
63
64
65     @Test(dataProvider = "CSAR_VF_Files")
66     public void deploymentScreenDCAEAssetImportCSARTest(String baseFileName) throws Exception {
67         //
68         setLog(baseFileName);
69 //              getExtendTest().setDescription(baseFileName);
70
71         ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
72         ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, baseFileName, getUser());
73
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);
84             // Close module
85             GeneralUIUtils.clickOnElementByText(updatedModuleName);
86         }
87     }
88
89     @Test
90     public void deploymentScreenDCAEAssetUpdateWithNewGroupCSAR_TC1368223_Test() throws Exception {
91         String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
92         String updateFileName = "baseUpdateFlowVF_NEW.csar";
93
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());
97
98         Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
99         metaDataFromUI.put("base_ldsa", new HashMap<String, String>() {
100             {
101                 put("version", "0");
102                 put("moduleID", "primary");
103             }
104         });
105
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);
110
111         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
112         DeploymentViewVerificator.validateModuleNameUpadate();
113     }
114
115     @Test
116     public void deploymentScreenDCAEAssetDeleteGroupFromCSAR_TC1368281_Test() throws Exception {
117         String baseFileName = "baseUpdateFlowVF_NEW.csar";
118         String updateFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
119
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());
123
124         Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
125
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);
130
131         // validate that group was removed
132         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
133
134         Map<String, HashMap<String, String>> metaDataFromUI2 = DeploymentPage.collectMetaDataFromUI();
135         metaDataFromUI2.put("base_ldsa", new HashMap<String, String>() {
136             {
137                 put("version", "0");
138                 put("moduleID", "primary");
139             }
140         });
141
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);
146
147         // validate that group was added
148         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI2, new DeploymentViewVerificator(filePath + baseFileName));
149         DeploymentViewVerificator.validateModuleNameUpadate();
150     }
151
152     @Test
153     public void deploymentScreenDCAEAssetUpdateWithNewGroupWithoutMembersCSAR_TC1368280_Test() throws Exception {
154
155         String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
156         String updateFileName = "baseUpdateAddGroupNoMembersUpdateFlow_NEW.csar";
157         String updateFileName2 = "baseUpdateFlowVF_NEW.csar";
158
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());
162
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);
166
167         Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
168
169         // validate that group was added and no members exist
170         DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + updateFileName));
171
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);
176
177         // validate that member was added to base_ldsa group
178         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName2));
179         DeploymentViewVerificator.validateModuleNameUpadate();
180     }
181
182
183     @Test
184     public void deploymentScreenDCAEAssetImportCSARWithArtifactSection_TC1368282_1_Test() throws Exception {
185         String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
186
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());
190
191         DeploymentViewVerificator.regularDepoymentScreenVerificator(null, new DeploymentViewVerificator(filePath + baseFileName));
192         DeploymentViewVerificator.validateModuleNameUpadate();
193     }
194
195     @Test
196     public void deploymentScreenDCAEAssetImportCSARRemoveArtifact_TC1368282_2_Test() throws Exception {
197         String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
198         String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
199
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());
203
204         Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
205
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);
210
211         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
212         DeploymentViewVerificator.validateModuleNameUpadate();
213     }
214
215     @Test
216     public void deploymentScreenDCAEAssetImportCSARAddArtifact_TC1368282_3_Test() throws Exception {
217         String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
218         String updateFileName = "baseUpdateFlowOneArtifactToGroup_NEW.csar";
219
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());
223
224         Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
225
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);
230
231         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + baseFileName));
232         DeploymentViewVerificator.validateModuleNameUpadate();
233     }
234
235     @Test
236     public void deploymentScreenDCAEAssetImportCSARMixArtifacts_TC1368282_4_Test() throws Exception {
237         String baseFileName = "baseUpdateFlowTwoArtifactsToGroup_NEW.csar";
238         String updateFileName = "baseUpdateMixedArtifacts_NEW.csar";
239
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());
243
244         Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
245
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);
250
251         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator());
252         DeploymentViewVerificator.validateModuleNameUpadate();
253     }
254
255     @Test
256     public void deploymentScreenDCAEAssetUpdateVFModule_TC1296437_Test() throws Exception {
257         String baseFileName = "baseUpdateMinusGroupFlowVF_NEW.csar";
258         String updateFileName = "baseUpdateFlowVF_NEW.csar";
259
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])));
264
265         Map<String, HashMap<String, String>> metaDataFromUI = DeploymentPage.collectMetaDataFromUI();
266         metaDataFromUI.put("base_ldsa", new HashMap<String, String>() {
267             {
268                 put("version", "0");
269                 put("moduleID", "primary");
270             }
271         });
272
273         DeploymentViewVerificator.validateEditPopover();
274
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);
278
279         assertTrue(resourceMetaData.getName().equals(ResourceGeneralPage.getNameText()));
280         DeploymentViewVerificator.regularDepoymentScreenVerificator(metaDataFromUI, new DeploymentViewVerificator(filePath + updateFileName));
281         DeploymentViewVerificator.validateModuleNameUpadate();
282     }
283
284
285     @Override
286     protected UserRoleEnum getRole() {
287         return UserRoleEnum.DESIGNER;
288     }
289
290 }