re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / CustomizationUUID.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.*;
26 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
27 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
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.*;
32 import org.openecomp.sdc.ci.tests.utilities.*;
33 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
34 import org.openecomp.sdc.ci.tests.verificator.CustomizationUUIDVerificator;
35 import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
36 import org.openqa.selenium.By;
37 import org.openqa.selenium.WebElement;
38 import org.testng.AssertJUnit;
39 import org.testng.annotations.BeforeMethod;
40 import org.testng.annotations.Test;
41
42 import java.util.ArrayList;
43 import java.util.List;
44
45 public class CustomizationUUID extends SetupCDTest {
46         
47         private static final String DESCRIPTION = "kuku";
48         private static final String ARTIFACT_LABEL = "artifact3";
49         private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate";
50         private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact";
51         private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml";
52         private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml";
53         private String filePath;
54         
55         @BeforeMethod
56         public void beforeTest(){
57                 filePath = FileHandling.getFilePath("");
58         }
59         
60         @Test
61         public void uniqueCustomizationUUIDforeachVFi() throws Exception {
62                 
63                 
64                 ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState();
65                 
66         /*      reloginWithNewRole(UserRoleEnum.TESTER);
67                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
68                 TesterOperationPage.certifyComponent(vfMetaData.getName());
69
70                 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
71                 
72                 List customizationUUIDs = new ArrayList<String>();
73                 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
74                 ServiceUIUtils.createService(serviceMetadata, getUser());
75                                         
76                 
77                 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
78                 CanvasManager canvasManager = CanvasManager.getCanvasManager();
79                 CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager);
80                 CanvasElement VFiElement2 = addElemntToCanvas(vfMetaData, canvasManager);
81                 CanvasElement VFiElement3 = addElemntToCanvas(vfMetaData, canvasManager);
82                 
83                 
84                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
85         
86                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
87                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
88                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement2);
89                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement3);
90                 
91                 ServiceGeneralPage.clickCheckoutButton();
92                 canvasManager = CanvasManager.getCanvasManager();
93                 CanvasElement VFiElement4 = addElemntToCanvas(vfMetaData, canvasManager);
94                 CanvasElement VFiElement5 = addElemntToCanvas(vfMetaData, canvasManager);
95                 CanvasElement VFiElement6 = addElemntToCanvas(vfMetaData, canvasManager);
96                 
97                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
98                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
99                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement4);
100                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement5);
101                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement6);
102                 
103                 CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs);
104                         
105
106                 }
107
108
109         @Test
110         public void uniqueCustomizationUUIDafterArtifactCRUDofVFi() throws Exception {
111                 
112                 
113                 ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState();
114                 
115                 /*reloginWithNewRole(UserRoleEnum.TESTER);
116                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
117                 TesterOperationPage.certifyComponent(vfMetaData.getName());
118
119                 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
120                 
121                 List customizationUUIDs = new ArrayList<>();
122                 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
123                 ServiceUIUtils.createService(serviceMetadata, getUser());
124                                         
125                 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
126                 CanvasManager canvasManager = CanvasManager.getCanvasManager();
127                 CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager);
128                         
129                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
130                 
131                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
132                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
133                 
134                 //add artifact to VFI
135                 
136                 ServiceGeneralPage.clickCheckoutButton();
137                 canvasManager = CanvasManager.getCanvasManager();
138         
139                 ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL,ArtifactTypeEnum.SNMP_POLL.getType());
140                 
141                 canvasManager.clickOnCanvaElement(VFiElement1);
142                 CompositionPage.showDeploymentArtifactTab();
143                 CompositionPage.clickAddArtifactButton();
144                 ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
145                 
146                 
147                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
148                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
149                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
150                 
151                 
152                 //delete VFI artifacts
153                 
154                 ServiceGeneralPage.clickCheckoutButton();
155                 canvasManager = CanvasManager.getCanvasManager();
156                 canvasManager.clickOnCanvaElement(VFiElement1);
157                 CompositionPage.showDeploymentArtifactTab();
158                 List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
159                 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue() + ARTIFACT_LABEL);
160                 SetupCDTest.getExtendTest().log(Status.INFO, "Going to delete "  +  HEAT_FILE_YAML_NAME + " artifact" + " and check if deleted");
161                 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + ARTIFACT_LABEL);
162                 GeneralPageElements.clickOKButton();
163                 
164                 
165                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
166                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
167                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
168                 
169                                 
170                 CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs);
171                 
172                 }
173
174         
175         @Test
176         public void uniqueCustomizationUUIDchangeVFiVersion() throws Exception {
177                 
178                 
179                 ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState();
180                 
181                 /*reloginWithNewRole(UserRoleEnum.TESTER);
182                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
183                 TesterOperationPage.certifyComponent(vfMetaData.getName());
184
185                 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
186                 
187                 List customizationUUIDs = new ArrayList<>();
188                 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
189                 ServiceUIUtils.createService(serviceMetadata, getUser());
190                                         
191                 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
192                 CanvasManager canvasManager = CanvasManager.getCanvasManager();
193                 CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager);
194                         
195                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
196                 
197                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
198                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
199                 
200                 //change VF version
201                 HomePage.navigateToHomePage();
202                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
203                 ResourceGeneralPage.clickCheckoutButton();
204                 //TODO Andrey should click on certify button
205                 ResourceGeneralPage.clickCertifyButton(vfMetaData.getName());
206                 /*reloginWithNewRole(UserRoleEnum.TESTER);
207                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
208                 TesterOperationPage.certifyComponent(vfMetaData.getName());
209                 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
210                 
211                 //update VFI version
212                 
213                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
214                 ServiceGeneralPage.clickCheckoutButton();
215                 canvasManager = CanvasManager.getCanvasManager();
216                 canvasManager.clickOnCanvaElement(VFiElement1);
217                 CompositionPage.changeComponentVersion(canvasManager, VFiElement1, "2.0");
218                 
219                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
220                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
221                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
222                 
223                 CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs);
224                 
225                 }
226         
227         
228         @Test
229         public void uniqueCustomizationUUIDaddRelation() throws Exception {
230                 
231                 
232                 ResourceReqDetails vfMetaData = createNewResourceWithArtifactCertifyState();
233                 
234                 /*reloginWithNewRole(UserRoleEnum.TESTER);
235                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
236                 TesterOperationPage.certifyComponent(vfMetaData.getName());
237
238                 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
239                 
240                 List customizationUUIDs = new ArrayList<>();
241                 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
242                 ServiceUIUtils.createService(serviceMetadata, getUser());
243                                         
244                 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
245                 CanvasManager canvasManager = CanvasManager.getCanvasManager();
246                 CanvasElement VFiElement1 = addElemntToCanvas(vfMetaData, canvasManager);
247                         
248                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
249                 
250                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
251                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
252                 
253                 //change VF version
254                 HomePage.navigateToHomePage();
255                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
256                 ResourceGeneralPage.clickCheckoutButton();
257                 //TODO Andrey should click on certify button
258                 ResourceGeneralPage.clickCertifyButton(vfMetaData.getName());
259                 /*reloginWithNewRole(UserRoleEnum.TESTER);
260                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
261                 TesterOperationPage.certifyComponent(vfMetaData.getName());
262                 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
263                 
264                 //update VFI version
265                 
266                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
267                 ServiceGeneralPage.clickCheckoutButton();
268                 canvasManager = CanvasManager.getCanvasManager();
269 //              CompositionPage.searchForElement(NormativeTypesEnum.PORT.getFolderName());
270                 CanvasElement contrailPortElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_PORT);
271                 canvasManager.linkElements(contrailPortElement, VFiElement1);
272                 
273                 canvasManager.clickOnCanvaElement(VFiElement1);
274                 
275                 
276                 ServiceGeneralPage.clickCheckinButton(serviceMetadata.getName());
277                 canvasManager = findServiceAndNavigateToCanvas(serviceMetadata);
278                 addCanvasElementToList(customizationUUIDs, canvasManager, VFiElement1);
279                 
280                 CustomizationUUIDVerificator.validateCustomizationUUIDuniqueness(customizationUUIDs);
281                 
282                 }
283         
284         
285         
286         public CanvasManager findServiceAndNavigateToCanvas(ServiceReqDetails serviceMetadata) throws Exception {
287                 CanvasManager canvasManager;
288                 GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
289                 ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
290                 canvasManager = CanvasManager.getCanvasManager();
291                 return canvasManager;
292         }
293
294         public ResourceReqDetails createNewResourceWithArtifactCertifyState() throws Exception {
295                 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
296                 ResourceUIUtils.createVF(vfMetaData, getUser());
297
298                 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
299
300                 List<ArtifactInfo> deploymentArtifactList = new ArrayList<>();
301                 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
302                 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
303                 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
304                         DeploymentArtifactPage.clickAddNewArtifact();
305                         ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
306                 }
307                 AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
308                 
309                 String newDescription = "new description";
310                 DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel());
311                 DeploymentArtifactPage.artifactPopup().insertDescription(newDescription);
312                 DeploymentArtifactPage.artifactPopup().clickDoneButton();
313                 String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
314                 AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
315                 
316                 DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
317                 DeploymentArtifactPage.clickOK();
318                 
319                 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
320                 
321 //              ResourceReqDetails vfcCompute = ElementFactory.getDefaultResource(NormativeTypesEnum.COMPUTE);
322                 CompositionPage.searchForElement(NormativeTypesEnum.COMPUTE.name());
323                 CanvasManager canvasManagerVF = CanvasManager.getCanvasManager();
324                 CanvasElement VFiElement1 = canvasManagerVF.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
325
326                 //TODO Andrey should click on certify button
327                 ResourceGeneralPage.clickCertifyButton(vfMetaData.getName());
328                 return vfMetaData;
329         }
330
331         public void addCanvasElementToList(List customizationUUIDs, CanvasManager canvasManager, CanvasElement VFiElement1)
332                         throws Exception {
333                 canvasManager.clickOnCanvaElement(VFiElement1);
334                 WebElement VFi1customizationUUID = CompositionPage.getCustomizationUUID();
335                 customizationUUIDs.add(VFi1customizationUUID.getText());
336         }
337
338         public CanvasElement addElemntToCanvas(ResourceReqDetails vfMetaData, CanvasManager canvasManager)
339                         throws Exception {
340                 CompositionPage.searchForElement(vfMetaData.getName());
341                 CanvasElement VFiElement1 = canvasManager.createElementOnCanvas(vfMetaData.getName());
342                 return VFiElement1;
343         }
344         
345                 public static void changeDeleteAndValidateVersionOnGeneralPage(String previousVersion, String currentVersion, String serviceName) throws Exception{
346                 GeneralPageElements.selectVersion("V" + previousVersion);
347                 ServiceVerificator.verifyVersionUI(previousVersion);
348                 GeneralUIUtils.clickJSOnElementByText("latest version");
349                 ServiceVerificator.verifyVersionUI(currentVersion);
350                 GeneralPageElements.clickTrashButtonAndConfirm();
351                 GeneralUIUtils.findComponentAndClick(serviceName);
352                 ServiceVerificator.verifyVersionUI(previousVersion);            
353         }       
354
355         @Override
356         protected UserRoleEnum getRole() {
357                 return UserRoleEnum.DESIGNER;
358         }
359
360 }