1 package org.openecomp.sdc.ci.tests.execute.sanity;
3 import com.aventstack.extentreports.Status;
4 import org.openecomp.sdc.be.dao.api.ActionStatus;
5 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
6 import org.openecomp.sdc.be.model.LifecycleStateEnum;
7 import org.openecomp.sdc.ci.tests.datatypes.*;
8 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
9 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
10 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
11 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
12 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
13 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
14 import org.openecomp.sdc.ci.tests.pages.*;
15 import org.openecomp.sdc.ci.tests.utilities.*;
16 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
17 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
18 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
19 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.WebElement;
22 import org.testng.AssertJUnit;
23 import org.testng.annotations.BeforeClass;
24 import org.testng.annotations.BeforeMethod;
25 import org.testng.annotations.Test;
27 import java.util.List;
29 import static org.testng.Assert.assertTrue;
31 public class PNF extends SetupCDTest {
33 private String filePath;
35 public void beforeClass(){
36 filePath = FileHandling.getFilePath("");
40 public void beforeTest(){
41 System.out.println("File repository is : " + filePath);
42 getExtendTest().log(Status.INFO, "File repository is : " + filePath);
46 public void updatePNF() throws Exception {
48 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
51 ResourceReqDetails updatedResource = new ResourceReqDetails();
52 updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + pnfMetaData.getName());
53 updatedResource.setDescription("kuku");
54 updatedResource.setVendorName("updatedVendor");
55 updatedResource.setVendorRelease("updatedRelease");
56 updatedResource.setContactId("ab0001");
57 updatedResource.setCategories(pnfMetaData.getCategories());
58 updatedResource.setVersion("0.1");
59 updatedResource.setResourceType(ResourceTypeEnum.VF.getValue());
60 List<String> newTags = pnfMetaData.getTags();
61 newTags.remove(pnfMetaData.getName());
62 newTags.add(updatedResource.getName());
63 updatedResource.setTags(newTags);
64 ResourceUIUtils.updateResource(updatedResource, getUser());
66 VfVerificator.verifyVFMetadataInUI(updatedResource);
67 VfVerificator.verifyVFUpdated(updatedResource, getUser());
71 public void addUpdateDeleteInformationalArtifactPNFTest() throws Exception {
72 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
74 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
76 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
77 InformationalArtifactPage.clickAddNewArtifact();
78 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
80 AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1));
82 String newDescription = "new description";
83 InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel());
84 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
85 InformationalArtifactPage.artifactPopup().clickDoneButton();
86 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel());
87 AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
89 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
90 InformationalArtifactPage.clickOK();
91 AssertJUnit.assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0));
95 public void addPropertiesToVfcInstanceInPNFTest() throws Exception {
98 // throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance on Composition screen");
99 SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance on Composition screen");
102 String fileName = "CP02.yml";
103 ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
106 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
107 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
109 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
111 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
112 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
113 CompositionPage.searchForElement(atomicResourceMetaData.getName());
114 CanvasElement cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
116 vfCanvasManager.clickOnCanvaElement(cpElement);
117 CompositionPage.showPropertiesAndAttributesTab();
118 List<WebElement> properties = CompositionPage.getProperties();
119 String propertyValue = "abc123";
120 for (int i = 0; i < 2; i++) {
121 WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label"));
123 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue);
124 PropertiesPage.getPropertyPopup().clickSave();
126 findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value"));
127 SetupCDTest.getExtendTest().log(Status.INFO, "Validating properties");
128 AssertJUnit.assertTrue(findElement.getText().equals(propertyValue));
132 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
137 public void changeInstanceVersionPNFTest() throws Exception{
139 ResourceReqDetails atomicResourceMetaData = null;
140 ResourceReqDetails pnfMetaData = null;
141 CanvasManager vfCanvasManager;
142 CanvasElement cpElement = null;
143 String fileName = "CP03.yml";
145 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
146 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
147 //TODO Andrey should click on certify button
148 ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName());
150 pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser());
151 ResourceUIUtils.createPNF(pnfMetaData, getUser());
152 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
153 vfCanvasManager = CanvasManager.getCanvasManager();
154 CompositionPage.searchForElement(atomicResourceMetaData.getName());
155 cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
157 //TODO Andrey should click on certify button
158 CompositionPage.clickCertifyButton(pnfMetaData.getName());
162 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
163 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
164 AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError));
166 /*reloginWithNewRole(UserRoleEnum.TESTER);
167 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
168 TesterOperationPage.certifyComponent(atomicResourceMetaData.getName());
170 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
171 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
172 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
173 vfCanvasManager = CanvasManager.getCanvasManager();
174 CompositionPage.changeComponentVersion(vfCanvasManager, cpElement, "1.0");
177 VfVerificator.verifyInstanceVersion(pnfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0");
181 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
187 public void verifyToscaArtifactsExistPNFTest() throws Exception{
188 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
190 final int numOfToscaArtifacts = 2;
191 ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
192 AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
194 for(int i = 0; i < numOfToscaArtifacts; i++){
195 String typeFromScreen = ToscaArtifactsPage.getArtifactType(i);
196 AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType()));
198 //TODO Andrey should click on certify button
199 ToscaArtifactsPage.clickCertifyButton(pnfMetaData.getName());
200 pnfMetaData.setVersion("1.0");
201 VfVerificator.verifyToscaArtifactsInfo(pnfMetaData, getUser());
205 public void pnfCertificationTest() throws Exception{
206 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
208 String vfName = pnfMetaData.getName();
210 ResourceGeneralPage.clickCheckinButton(vfName);
211 GeneralUIUtils.findComponentAndClick(vfName);
212 //TODO Andrey should click on certify button
213 ResourceGeneralPage.clickCertifyButton(vfName);
215 /*reloginWithNewRole(UserRoleEnum.TESTER);
216 GeneralUIUtils.findComponentAndClick(vfName);
217 TesterOperationPage.certifyComponent(vfName);*/
219 pnfMetaData.setVersion("1.0");
220 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
222 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
223 GeneralUIUtils.findComponentAndClick(vfName);
224 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
228 public void deletePNFTest() throws Exception{
229 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
231 GeneralPageElements.clickTrashButtonAndConfirm();
233 pnfMetaData.setVersion("0.1");
234 VfVerificator.verifyVfDeleted(pnfMetaData, getUser());
238 public void revertPNFMetadataTest() throws Exception{
239 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
241 ResourceReqDetails pvfRevertDetails = new ResourceReqDetails();
242 pvfRevertDetails.setName("ciUpdatedName");
243 pvfRevertDetails.setDescription("kuku");
244 pvfRevertDetails.setCategories(pnfMetaData.getCategories());
245 pvfRevertDetails.setVendorName("updatedVendor");
246 pvfRevertDetails.setVendorRelease("updatedRelease");
247 ResourceUIUtils.fillResourceGeneralInformationPage(pvfRevertDetails, getUser(), false);
249 GeneralPageElements.clickRevertButton();
251 VfVerificator.verifyVFMetadataInUI(pnfMetaData);
255 public void checkoutPnfTest() throws Exception{
256 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
258 ResourceGeneralPage.clickCheckinButton(pnfMetaData.getName());
259 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
260 GeneralPageElements.clickCheckoutButton();
262 pnfMetaData.setVersion("0.2");
263 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
264 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
265 //TODO Andrey should click on certify button
266 ResourceGeneralPage.clickCertifyButton(pnfMetaData.getName());
268 /*reloginWithNewRole(UserRoleEnum.TESTER);
269 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
270 TesterOperationPage.certifyComponent(pnfMetaData.getName());
272 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
273 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
274 ResourceGeneralPage.clickCheckoutButton();
276 pnfMetaData.setVersion("1.1");
277 pnfMetaData.setUniqueId(null);
278 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
279 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
282 public ResourceReqDetails createPNFWithGenerateName() throws Exception {
283 ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser());
284 ResourceUIUtils.createPNF(pnfMetaData, getUser());
289 public void verifyPNF_UI_Limitations() throws Exception {
290 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
292 SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Artifact Left Side Menu not exist");
293 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("Deployment ArtifactLeftSideMenu"));
294 SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Left Side Menu not exist");
295 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("DeploymentLeftSideMenu"));
299 public void filteringCatalogByPNF() throws Exception {
300 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
302 String pnfName = pnfMetaData.getName();
303 //TODO Andrey should click on certify button
304 ResourceGeneralPage.clickCertifyButton(pnfName);
305 /*reloginWithNewRole(UserRoleEnum.TESTER);
306 GeneralUIUtils.findComponentAndClick(pnfName);
307 TesterOperationPage.certifyComponent(pnfName);*/
309 pnfMetaData.setVersion("1.0");
310 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
312 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
313 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
314 CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf("PNF"));
315 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s found", pnfName));
316 GeneralUIUtils.clickOnElementByTestId(pnfName);
320 public void addPNFtoServiceAndDistribute() throws Exception {
321 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
323 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
324 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
325 CompositionPage.searchForElement("ContrailPort");
326 vfCanvasManager.createElementOnCanvas("ContrailPort");
328 String pnfName = pnfMetaData.getName();
329 //TODO Andrey should click on certify button
330 ResourceGeneralPage.clickCertifyButton(pnfName);
332 /*reloginWithNewRole(UserRoleEnum.TESTER);
333 GeneralUIUtils.findComponentAndClick(pnfName);
334 TesterOperationPage.certifyComponent(pnfName);*/
336 pnfMetaData.setVersion("1.0");
337 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
339 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
340 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
341 ServiceUIUtils.createService(serviceMetadata, getUser());
342 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
343 CanvasManager canvasManager = CanvasManager.getCanvasManager();
344 CompositionPage.searchForElement(pnfName);
345 CanvasElement pnfElement = canvasManager.createElementOnCanvas(pnfName);
346 CanvasElement networkElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.CONTRAIL_VIRTUAL_NETWORK);
348 canvasManager.linkElements(pnfElement, networkElement);
349 String serviceName = serviceMetadata.getName();
350 ServiceGeneralPage.clickSubmitForTestingButton(serviceName);
351 reloginWithNewRole(UserRoleEnum.TESTER);
352 GeneralUIUtils.findComponentAndClick(serviceName);
353 TesterOperationPage.certifyComponent(serviceName);
355 reloginWithNewRole(UserRoleEnum.GOVERNOR);
356 GeneralUIUtils.findComponentAndClick(serviceName);
357 GovernorOperationPage.approveSerivce(serviceName);
359 reloginWithNewRole(UserRoleEnum.OPS);
360 GeneralUIUtils.findComponentAndClick(serviceName);
361 OpsOperationPage.distributeService();
365 public void checkInfomationArtifactUploadLimitation() throws Exception {
366 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
367 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
368 List<WebElement> webElements = GeneralUIUtils.getWebElementsListBy(By.xpath(DataTestIdEnum.ArtifactPageEnum.ADD_OTHER_ARTIFACT_BUTTON.getValue()));
369 int numberOfElements = webElements.size();
370 String buttonText = webElements.get(0).getText();
371 SetupCDTest.getExtendTest().log(Status.INFO, "Verifying only one button exist: Add Other Artifact");
372 assertTrue(buttonText.equalsIgnoreCase(("Add Other Artifact")));
373 assertTrue(1==numberOfElements, "There should be only one option for uploading artifact in PNF");
377 public void checkNonCPVLObjectsNotExistInComosition() throws Exception {
378 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
379 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
380 String pnfName = pnfMetaData.getName();
381 // Searching for VFC element and make sure it not exist in PNF composition (Only VL/CP are allowed).
382 CompositionPage.searchForElement("BlockStorage");
383 SetupCDTest.getExtendTest().log(Status.INFO, "Verifying Element found");
384 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("BlockStorage"));
388 protected UserRoleEnum getRole() {
389 return UserRoleEnum.DESIGNER;