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.enums.*;
9 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
10 import org.openecomp.sdc.ci.tests.pages.*;
11 import org.openecomp.sdc.ci.tests.utilities.*;
12 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
13 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
14 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
15 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
16 import org.openqa.selenium.By;
17 import org.openqa.selenium.WebElement;
18 import org.testng.AssertJUnit;
19 import org.testng.SkipException;
20 import org.testng.annotations.BeforeClass;
21 import org.testng.annotations.BeforeMethod;
22 import org.testng.annotations.Test;
24 import java.util.List;
26 import static org.testng.Assert.assertTrue;
28 public class PNF extends SetupCDTest {
30 private String filePath;
32 public void beforeClass(){
33 filePath = FileHandling.getFilePath("");
37 public void beforeTest(){
38 System.out.println("File repository is : " + filePath);
39 getExtendTest().log(Status.INFO, "File repository is : " + filePath);
43 public void updatePNF() throws Exception {
45 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
48 ResourceReqDetails updatedResource = new ResourceReqDetails();
49 updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + pnfMetaData.getName());
50 updatedResource.setDescription("kuku");
51 updatedResource.setVendorName("updatedVendor");
52 updatedResource.setVendorRelease("updatedRelease");
53 updatedResource.setContactId("ab0001");
54 updatedResource.setCategories(pnfMetaData.getCategories());
55 updatedResource.setVersion("0.1");
56 updatedResource.setResourceType(ResourceTypeEnum.VF.getValue());
57 List<String> newTags = pnfMetaData.getTags();
58 newTags.remove(pnfMetaData.getName());
59 newTags.add(updatedResource.getName());
60 updatedResource.setTags(newTags);
61 ResourceUIUtils.updateResource(updatedResource, getUser());
63 VfVerificator.verifyVFMetadataInUI(updatedResource);
64 VfVerificator.verifyVFUpdated(updatedResource, getUser());
68 public void addUpdateDeleteInformationalArtifactPNFTest() throws Exception {
69 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
71 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
73 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
74 InformationalArtifactPage.clickAddNewArtifact();
75 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
77 AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1));
79 String newDescription = "new description";
80 InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel());
81 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
82 InformationalArtifactPage.artifactPopup().clickDoneButton();
83 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel());
84 AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
86 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
87 InformationalArtifactPage.clickOK();
88 AssertJUnit.assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0));
92 public void addPropertiesToVfcInstanceInPNFTest() throws Exception {
95 throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance on Composition screen");
98 String fileName = "CP02.yml";
99 ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
102 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
103 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
105 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
107 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
108 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
109 CompositionPage.searchForElement(atomicResourceMetaData.getName());
110 CanvasElement cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
112 vfCanvasManager.clickOnCanvaElement(cpElement);
113 CompositionPage.showPropertiesAndAttributesTab();
114 List<WebElement> properties = CompositionPage.getProperties();
115 String propertyValue = "abc123";
116 for (int i = 0; i < 2; i++) {
117 WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label"));
119 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue);
120 PropertiesPage.getPropertyPopup().clickSave();
122 findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value"));
123 SetupCDTest.getExtendTest().log(Status.INFO, "Validating properties");
124 AssertJUnit.assertTrue(findElement.getText().equals(propertyValue));
128 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
133 public void changeInstanceVersionPNFTest() throws Exception{
135 ResourceReqDetails atomicResourceMetaData = null;
136 ResourceReqDetails pnfMetaData = null;
137 CanvasManager vfCanvasManager;
138 CanvasElement cpElement = null;
139 String fileName = "CP03.yml";
141 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.CP, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
142 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
143 ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName());
145 pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser());
146 ResourceUIUtils.createPNF(pnfMetaData, getUser());
147 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
148 vfCanvasManager = CanvasManager.getCanvasManager();
149 CompositionPage.searchForElement(atomicResourceMetaData.getName());
150 cpElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
153 CompositionPage.clickSubmitForTestingButton(pnfMetaData.getName());
157 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
158 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
159 AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError));
162 reloginWithNewRole(UserRoleEnum.TESTER);
163 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
164 TesterOperationPage.certifyComponent(atomicResourceMetaData.getName());
166 reloginWithNewRole(UserRoleEnum.DESIGNER);
167 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
168 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
169 vfCanvasManager = CanvasManager.getCanvasManager();
170 CompositionPage.changeComponentVersion(vfCanvasManager, cpElement, "1.0");
173 VfVerificator.verifyInstanceVersion(pnfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0");
177 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
183 public void verifyToscaArtifactsExistPNFTest() throws Exception{
184 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
186 final int numOfToscaArtifacts = 2;
187 ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
188 AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
190 for(int i = 0; i < numOfToscaArtifacts; i++){
191 String typeFromScreen = ToscaArtifactsPage.getArtifactType(i);
192 AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType()));
195 ToscaArtifactsPage.clickSubmitForTestingButton(pnfMetaData.getName());
196 VfVerificator.verifyToscaArtifactsInfo(pnfMetaData, getUser());
200 public void pnfCertificationTest() throws Exception{
201 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
203 String vfName = pnfMetaData.getName();
205 ResourceGeneralPage.clickCheckinButton(vfName);
206 GeneralUIUtils.findComponentAndClick(vfName);
207 ResourceGeneralPage.clickSubmitForTestingButton(vfName);
209 reloginWithNewRole(UserRoleEnum.TESTER);
210 GeneralUIUtils.findComponentAndClick(vfName);
211 TesterOperationPage.certifyComponent(vfName);
213 pnfMetaData.setVersion("1.0");
214 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
216 reloginWithNewRole(UserRoleEnum.DESIGNER);
217 GeneralUIUtils.findComponentAndClick(vfName);
218 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
222 public void deletePNFTest() throws Exception{
223 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
225 GeneralPageElements.clickTrashButtonAndConfirm();
227 pnfMetaData.setVersion("0.1");
228 VfVerificator.verifyVfDeleted(pnfMetaData, getUser());
232 public void revertPNFMetadataTest() throws Exception{
233 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
235 ResourceReqDetails pvfRevertDetails = new ResourceReqDetails();
236 pvfRevertDetails.setName("ciUpdatedName");
237 pvfRevertDetails.setDescription("kuku");
238 pvfRevertDetails.setCategories(pnfMetaData.getCategories());
239 pvfRevertDetails.setVendorName("updatedVendor");
240 pvfRevertDetails.setVendorRelease("updatedRelease");
241 ResourceUIUtils.fillResourceGeneralInformationPage(pvfRevertDetails, getUser(), false);
243 GeneralPageElements.clickRevertButton();
245 VfVerificator.verifyVFMetadataInUI(pnfMetaData);
249 public void checkoutPnfTest() throws Exception{
250 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
252 ResourceGeneralPage.clickCheckinButton(pnfMetaData.getName());
253 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
254 GeneralPageElements.clickCheckoutButton();
256 pnfMetaData.setVersion("0.2");
257 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
258 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
260 ResourceGeneralPage.clickSubmitForTestingButton(pnfMetaData.getName());
262 reloginWithNewRole(UserRoleEnum.TESTER);
263 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
264 TesterOperationPage.certifyComponent(pnfMetaData.getName());
266 reloginWithNewRole(UserRoleEnum.DESIGNER);
267 GeneralUIUtils.findComponentAndClick(pnfMetaData.getName());
268 ResourceGeneralPage.clickCheckoutButton();
270 pnfMetaData.setVersion("1.1");
271 pnfMetaData.setUniqueId(null);
272 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
273 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
276 public ResourceReqDetails createPNFWithGenerateName() throws Exception {
277 ResourceReqDetails pnfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.PNF, getUser());
278 ResourceUIUtils.createPNF(pnfMetaData, getUser());
283 public void verifyPNF_UI_Limitations() throws Exception {
284 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
286 SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Artifact Left Side Menu not exist");
287 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("Deployment ArtifactLeftSideMenu"));
288 SetupCDTest.getExtendTest().log(Status.INFO, "Validating Deployment Left Side Menu not exist");
289 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("DeploymentLeftSideMenu"));
293 public void filteringCatalogByPNF() throws Exception {
294 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
296 String pnfName = pnfMetaData.getName();
297 ResourceGeneralPage.clickSubmitForTestingButton(pnfName);
298 reloginWithNewRole(UserRoleEnum.TESTER);
299 GeneralUIUtils.findComponentAndClick(pnfName);
300 TesterOperationPage.certifyComponent(pnfName);
302 pnfMetaData.setVersion("1.0");
303 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
305 reloginWithNewRole(UserRoleEnum.DESIGNER);
306 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
307 CatalogUIUtilitis.catalogFilterTypeChecBox(TypesEnum.valueOf("PNF"));
308 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating resource %s found", pnfName));
309 GeneralUIUtils.clickOnElementByTestId(pnfName);
313 public void addPNFtoServiceAndDistribute() throws Exception {
314 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
316 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
317 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
318 CompositionPage.searchForElement("ContrailPort");
319 vfCanvasManager.createElementOnCanvas("ContrailPort");
321 String pnfName = pnfMetaData.getName();
322 ResourceGeneralPage.clickSubmitForTestingButton(pnfName);
324 reloginWithNewRole(UserRoleEnum.TESTER);
325 GeneralUIUtils.findComponentAndClick(pnfName);
326 TesterOperationPage.certifyComponent(pnfName);
328 pnfMetaData.setVersion("1.0");
329 VfVerificator.verifyVFLifecycle(pnfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
331 reloginWithNewRole(UserRoleEnum.DESIGNER);
332 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
333 ServiceUIUtils.createService(serviceMetadata, getUser());
334 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
335 CanvasManager canvasManager = CanvasManager.getCanvasManager();
336 CompositionPage.searchForElement(pnfName);
337 CanvasElement pnfElement = canvasManager.createElementOnCanvas(pnfName);
338 CompositionPage.searchForElement("Network");
339 CanvasElement networkElement = canvasManager.createElementOnCanvas("Network");
341 canvasManager.linkElements(pnfElement, CircleSize.VF, networkElement, CircleSize.NORMATIVE);
342 String serviceName = serviceMetadata.getName();
343 ServiceGeneralPage.clickSubmitForTestingButton(serviceName);
344 reloginWithNewRole(UserRoleEnum.TESTER);
345 GeneralUIUtils.findComponentAndClick(serviceName);
346 TesterOperationPage.certifyComponent(serviceName);
348 reloginWithNewRole(UserRoleEnum.GOVERNOR);
349 GeneralUIUtils.findComponentAndClick(serviceName);
350 GovernorOperationPage.approveSerivce(serviceName);
352 reloginWithNewRole(UserRoleEnum.OPS);
353 GeneralUIUtils.findComponentAndClick(serviceName);
354 OpsOperationPage.distributeService();
358 public void checkInfomationArtifactUploadLimitation() throws Exception {
359 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
360 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
361 List<WebElement> webElements = GeneralUIUtils.getWebElementsListBy(By.xpath("//button[@class='add-button ng-scope']"));
362 int numberOfElements = webElements.size();
363 String buttonText = webElements.get(0).getText();
364 SetupCDTest.getExtendTest().log(Status.INFO, "Verifying only one button exist: Add Other Artifact");
365 assertTrue(buttonText.equalsIgnoreCase(("Add Other Artifact")));
366 assertTrue(1==numberOfElements, "There should be only one option for uploading artifact in PNF");
370 public void checkNonCPVLObjectsNotExistInComosition() throws Exception {
371 ResourceReqDetails pnfMetaData = createPNFWithGenerateName();
372 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
373 String pnfName = pnfMetaData.getName();
374 // Searching for VFC element and make sure it not exist in PNF composition (Only VL/CP are allowed).
375 CompositionPage.searchForElement("BlockStorage");
376 SetupCDTest.getExtendTest().log(Status.INFO, "Verifying Element found");
377 assertTrue(GeneralUIUtils.isElementInvisibleByTestId("BlockStorage"));
381 protected UserRoleEnum getRole() {
382 return UserRoleEnum.DESIGNER;