2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.dao.api.ActionStatus;
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.be.model.LifecycleStateEnum;
27 import org.openecomp.sdc.ci.tests.datatypes.*;
28 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
29 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
30 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
32 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
33 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
34 import org.openecomp.sdc.ci.tests.pages.*;
35 import org.openecomp.sdc.ci.tests.utilities.*;
36 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
37 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
38 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
39 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
40 import org.openqa.selenium.By;
41 import org.openqa.selenium.WebElement;
42 import org.testng.AssertJUnit;
43 import org.testng.annotations.BeforeClass;
44 import org.testng.annotations.BeforeMethod;
45 import org.testng.annotations.Test;
47 import java.util.List;
49 import static org.testng.Assert.assertTrue;
51 public class PNF extends SetupCDTest {
53 private String filePath;
55 public void beforeClass(){
56 filePath = FileHandling.getFilePath("");
60 public void beforeTest(){
61 System.out.println("File repository is : " + filePath);
62 getExtendTest().log(Status.INFO, "File repository is : " + filePath);
66 public void updatePNF() throws Exception {
68 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
71 ResourceReqDetails updatedResource = new ResourceReqDetails();
72 updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + pnfMetaData.getName());
73 updatedResource.setDescription("kuku");
74 updatedResource.setVendorName("updatedVendor");
75 updatedResource.setVendorRelease("updatedRelease");
76 updatedResource.setContactId("ab0001");
77 updatedResource.setCategories(pnfMetaData.getCategories());
78 updatedResource.setVersion("0.1");
79 updatedResource.setResourceType(ResourceTypeEnum.VF.getValue());
80 List<String> newTags = pnfMetaData.getTags();
81 newTags.remove(pnfMetaData.getName());
82 newTags.add(updatedResource.getName());
83 updatedResource.setTags(newTags);
84 ResourceUIUtils.updateResource(updatedResource, getUser());
86 VfVerificator.verifyVFMetadataInUI(updatedResource);
87 VfVerificator.verifyVFUpdated(updatedResource, getUser());
91 public void addUpdateDeleteInformationalArtifactPNFTest() throws Exception {
92 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
94 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
96 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
97 InformationalArtifactPage.clickAddNewArtifact();
98 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
100 AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1));
102 String newDescription = "new description";
103 InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel());
104 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
105 InformationalArtifactPage.artifactPopup().clickDoneButton();
106 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel());
107 AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
109 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
110 InformationalArtifactPage.clickOK();
111 AssertJUnit.assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0));
115 public void addPropertiesToVfcInstanceInPNFTest() throws Exception {
118 // throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance on Composition screen");
119 SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen");
122 String fileName = "CP02.yml";
123 ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
126 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
127 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
129 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
131 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
132 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
133 CompositionPage.searchForElement(atomicResourceMetaData.getName());
134 CanvasElement cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
136 vfCanvasManager.clickOnCanvaElement(cpElement);
137 CompositionPage.showPropertiesAndAttributesTab();
138 List<WebElement> properties = CompositionPage.getProperties();
139 String propertyValue = "abc123";
140 for (int i = 0; i < 2; i++) {
141 WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label"));
143 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue);
144 PropertiesPage.getPropertyPopup().clickSave();
146 findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value"));
147 SetupCDTest.getExtendTest().log(Status.INFO, "Validating properties");
148 AssertJUnit.assertTrue(findElement.getText().equals(propertyValue));
152 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
157 public void changeInstanceVersionPNFTest() throws Exception{
159 ResourceReqDetails atomicResourceMetaData = null;
160 ResourceReqDetails pnfMetaData = null;
161 CanvasManager vfCanvasManager;
162 CanvasElement cpElement = null;
163 String fileName = "CP03.yml";
165 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
166 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
167 //TODO Andrey should click on certify button
168 ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName());
170 pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser());
171 ResourceUIUtils.createPNF(pnfMetaData, getUser());
172 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
173 vfCanvasManager = CanvasManager.getCanvasManager();
174 CompositionPage.searchForElement(atomicResourceMetaData.getName());
175 cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
177 //TODO Andrey should click on certify button
178 CompositionPage.clickCertifyButton(pnfMetaData.getName());
182 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
183 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
184 AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError));
186 /*reloginWithNewRole(UserRoleEnum.TESTER);
187 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
188 TesterOperationPage.certifyComponent(atomicResourceMetaData.getName());
190 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
191 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
192 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
193 vfCanvasManager = CanvasManager.getCanvasManager();
194 CompositionPage.changeComponentVersion(vfCanvasManager, cpElement, "1.0");
197 VfVerificator.verifyInstanceVersion(pnfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0");
201 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
207 public void verifyToscaArtifactsExistPNFTest() throws Exception{
208 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
210 final int numOfToscaArtifacts = 2;
211 ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
212 AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
214 for(int i = 0; i < numOfToscaArtifacts; i++){
215 String typeFromScreen = ToscaArtifactsPage.getArtifactType(i);
216 AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType()));
218 //TODO Andrey should click on certify button
219 ToscaArtifactsPage.clickCertifyButton(pnfMetaData.getName());
220 pnfMetaData.setVersion("1.0");
221 VfVerificator.verifyToscaArtifactsInfo(pnfMetaData, getUser());
225 public void pnfCertificationTest() throws Exception{
226 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
228 String vfName = pnfMetaData.getName();
230 ResourceGeneralPage.clickCheckinButton(vfName);
231 GeneralUIUtils.findComponentAndClick(vfName);
232 //TODO Andrey should click on certify button
233 ResourceGeneralPage.clickCertifyButton(vfName);
235 /*reloginWithNewRole(UserRoleEnum.TESTER);
236 GeneralUIUtils.findComponentAndClick(vfName);
237 TesterOperationPage.certifyComponent(vfName);*/
239 pnfMetaData.setVersion("1.0");
240 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
242 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
243 GeneralUIUtils.findComponentAndClick(vfName);
244 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
248 public void deletePNFTest() throws Exception{
249 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
251 GeneralPageElements.clickTrashButtonAndConfirm();
253 pnfMetaData.setVersion("0.1");
254 VfVerificator.verifyVfDeleted(pnfMetaData, getUser());
258 public void revertPNFMetadataTest() throws Exception{
259 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
261 ResourceReqDetails pvfRevertDetails = new ResourceReqDetails();
262 pvfRevertDetails.setName("ciUpdatedName");
263 pvfRevertDetails.setDescription("kuku");
264 pvfRevertDetails.setCategories(pnfMetaData.getCategories());
265 pvfRevertDetails.setVendorName("updatedVendor");
266 pvfRevertDetails.setVendorRelease("updatedRelease");
267 ResourceUIUtils.fillResourceGeneralInformationPage(pvfRevertDetails, getUser(), false);
269 GeneralPageElements.clickRevertButton();
271 VfVerificator.verifyVFMetadataInUI(pnfMetaData);
275 public void checkoutPnfTest() throws Exception{
276 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
278 ResourceGeneralPage.clickCheckinButton(pnfMetaData.getName());
279 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
280 GeneralPageElements.clickCheckoutButton();
282 pnfMetaData.setVersion("0.2");
283 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
284 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
285 //TODO Andrey should click on certify button
286 ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName());
288 /*reloginWithNewRole(UserRoleEnum.TESTER);
289 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
290 TesterOperationPage.certifyComponent(pnfMetaData.getName());
292 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
293 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
294 ResourceGeneralPage.clickCheckoutButton();
296 pnfMetaData.setVersion("1.1");
297 pnfMetaData.setUniqueId(null);
298 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
299 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
302 public ResourceReqDetails createPNFWithGenerateName() throws Exception {
303 ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser());
304 ResourceUIUtils.createPNF(pnfMetaData, getUser());
309 public void verifyPNF_UI_Limitations() throws Exception {
310 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
312 SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Artifact Left Side Menu not exist");
313 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("Deployment ArtifactLeftSideMenu"));
314 SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Left Side Menu not exist");
315 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("DeploymentLeftSideMenu"));
319 public void filteringCatalogByPNF() throws Exception {
320 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
322 String pnfName = pnfMetaData.getName();
323 //TODO Andrey should click on certify button
324 ResourceGeneralPage.clickCertifyButton(pnfName);
325 /*reloginWithNewRole(UserRoleEnum.TESTER);
326 GeneralUIUtils.findComponentAndClick(pnfName);
327 TesterOperationPage.certifyComponent(pnfName);*/
329 pnfMetaData.setVersion("1.0");
330 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
332 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
333 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
334 CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf("PNF"));
335 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s found", pnfName));
336 GeneralUIUtils.clickOnElementByTestId(pnfName);
340 public void addPNFtoServiceAndDistribute() throws Exception {
341 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
343 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
344 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
345 CompositionPage.searchForElement("ContrailPort");
346 vfCanvasManager.createElementOnCanvas("ContrailPort");
348 String pnfName = pnfMetaData.getName();
349 //TODO Andrey should click on certify button
350 ResourceGeneralPage.clickCertifyButton(pnfName);
352 /*reloginWithNewRole(UserRoleEnum.TESTER);
353 GeneralUIUtils.findComponentAndClick(pnfName);
354 TesterOperationPage.certifyComponent(pnfName);*/
356 pnfMetaData.setVersion("1.0");
357 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
359 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
360 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
361 ServiceUIUtils.createService(serviceMetadata, getUser());
362 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
363 CanvasManager canvasManager = CanvasManager.getCanvasManager();
364 CompositionPage.searchForElement(pnfName);
365 CanvasElement pnfElement = canvasManager.createElementOnCanvas(pnfName);
366 CanvasElement networkElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_VIRTUAL_NETWORK);
368 canvasManager.linkElements(pnfElement, networkElement);
369 String serviceName = serviceMetadata.getName();
370 ServiceGeneralPage.clickSubmitForTestingButton(serviceName);
371 reloginWithNewRole(UserRoleEnum.TESTER);
372 GeneralUIUtils.findComponentAndClick(serviceName);
373 TesterOperationPage.certifyComponent(serviceName);
375 reloginWithNewRole(UserRoleEnum.GOVERNOR);
376 GeneralUIUtils.findComponentAndClick(serviceName);
377 GovernorOperationPage.approveSerivce(serviceName);
379 reloginWithNewRole(UserRoleEnum.OPS);
380 GeneralUIUtils.findComponentAndClick(serviceName);
381 OpsOperationPage.distributeService();
385 public void checkInfomationArtifactUploadLimitation() throws Exception {
386 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
387 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
388 List<WebElement> webElements = GeneralUIUtils.getWebElementsListBy(By.xpath(DataTestIdEnum.ArtifactPageEnum.ADD_OTHER_ARTIFACT_BUTTON.getValue()));
389 int numberOfElements = webElements.size();
390 String buttonText = webElements.get(0).getText();
391 SetupCDTest.getExtendTest().log(Status.INFO, "Verifying only one button exist: Add Other Artifact");
392 assertTrue(buttonText.equalsIgnoreCase(("Add Other Artifact")));
393 assertTrue(1==numberOfElements, "There should be only one option for uploading artifact in PNF");
397 public void checkNonCPVLObjectsNotExistInComosition() throws Exception {
398 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
399 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
400 String pnfName = pnfMetaData.getName();
401 // Searching for VFC element and make sure it not exist in PNF composition (Only VL/CP are allowed).
402 CompositionPage.searchForElement("BlockStorage");
403 SetupCDTest.getExtendTest().log(Status.INFO, "Verifying Element found");
404 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("BlockStorage"));
408 protected UserRoleEnum getRole() {
409 return UserRoleEnum.DESIGNER;