2 * ============LICENSE_START=======================================================
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
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.datatypes.enums.ResourceTypeEnum;
25 import org.openecomp.sdc.be.model.Resource;
26 import org.openecomp.sdc.ci.tests.datatypes.*;
27 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders;
28 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
29 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ResourceMetadataEnum;
30 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ToscaArtifactsScreenEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.enums.*;
32 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
33 import org.openecomp.sdc.ci.tests.execute.setup.AttFtpClient;
34 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
35 import org.openecomp.sdc.ci.tests.pages.*;
36 import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
37 import org.openecomp.sdc.ci.tests.utilities.*;
38 import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
39 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
40 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
41 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
42 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
43 import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
44 import org.openecomp.sdc.ci.tests.verificator.VfModuleVerificator;
45 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
46 import org.openqa.selenium.By;
47 import org.openqa.selenium.WebElement;
48 import org.testng.AssertJUnit;
49 import org.testng.annotations.BeforeClass;
50 import org.testng.annotations.BeforeMethod;
51 import org.testng.annotations.Test;
55 import static org.assertj.core.api.Assertions.assertThat;
58 public class VfAPI extends SetupCDTest {
60 private String filePath;
63 public void beforeClass(){
64 filePath = FileHandling.getFilePath("");
68 public void beforeTest(){
69 System.out.println("File repository is : " + filePath);
70 getExtendTest().log(Status.INFO, "File repository is : " + filePath);
73 private ResourceReqDetails createVFviaAPI() {
74 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
75 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating VF %s", vfMetaData.getName()));
76 AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
82 public void updateVF() throws Exception {
85 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
86 ResourceUIUtils.createVF(resourceMetaData, getUser());
89 ResourceReqDetails updatedResource = new ResourceReqDetails();
90 updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName());
91 updatedResource.setDescription("kuku");
92 updatedResource.setVendorName("updatedVendor");
93 updatedResource.setVendorRelease("updatedRelease");
94 updatedResource.setContactId("ab0001");
95 updatedResource.setCategories(resourceMetaData.getCategories());
96 updatedResource.setVersion("0.1");
97 updatedResource.setResourceType(ResourceTypeEnum.VF.getValue());
98 List<String> newTags = resourceMetaData.getTags();
99 newTags.remove(resourceMetaData.getName());
100 newTags.add(updatedResource.getName());
101 updatedResource.setTags(newTags);
102 ResourceUIUtils.updateResource(updatedResource, getUser());
104 VfVerificator.verifyVFMetadataInUI(updatedResource);
105 VfVerificator.verifyVFUpdated(updatedResource, getUser());
111 public void vfcLinkedToComputeInVfFlowApi() throws Exception {
112 String fileName = "vFW_VFC2.yml";
113 ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
117 Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value();
118 atomicResourceMetaData.setName(vfc.getName());
120 //Certify VFC via API
121 vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
124 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
125 AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
127 //Go to Catalog and find the created VF
128 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
129 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
131 //Composition - drag the created VFC and another element, link between them
132 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
133 CanvasManager canvasManager = CanvasManager.getCanvasManager();
134 CompositionPage.searchForElement(String.format("%s %s", LeftPanelCanvasItems.COMPUTE.getValue() , "1.0"));
135 CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
136 CompositionPage.searchForElement(atomicResourceMetaData.getName());
137 CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
138 AssertJUnit.assertNotNull(cpElement);
139 ServiceVerificator.verifyNumOfComponentInstances(vfMetaData, "0.1", 2, getUser());
140 canvasManager.linkElements(cpElement, computeElement);
142 vfMetaData.setVersion("0.1");
143 VfVerificator.verifyLinkCreated(vfMetaData, getUser(), 1);
146 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
153 public void addUpdateDeleteDeploymentArtifactToVfTestApi() throws Exception {
155 ResourceReqDetails vfMetaData = createVFviaAPI();
157 //Go to Catalog and find the created VF
158 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
159 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
161 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
163 List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
164 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
165 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
166 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
167 DeploymentArtifactPage.clickAddNewArtifact();
168 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
170 AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
172 String newDescription = "new description";
173 DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel());
174 DeploymentArtifactPage.artifactPopup().insertDescription(newDescription);
175 DeploymentArtifactPage.artifactPopup().clickDoneButton();
176 String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
177 AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
179 DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
180 DeploymentArtifactPage.clickOK();
181 AssertJUnit.assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1));
183 AssertJUnit.assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed());
188 public void addUpdateDeleteInformationalArtifactApi() throws Exception {
190 ResourceReqDetails vfMetaData = createVFviaAPI();
192 //Go to Catalog and find the created VF
193 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
194 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
196 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
198 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
199 InformationalArtifactPage.clickAddNewArtifact();
200 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
202 AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1));
204 String newDescription = "new description";
205 InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel());
206 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
207 InformationalArtifactPage.artifactPopup().clickDoneButton();
208 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel());
209 AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
211 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
212 InformationalArtifactPage.clickOK();
213 AssertJUnit.assertTrue("artifact "+ informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0));
218 public void addPropertiesToVfcInstanceInVfTestApi() throws Exception {
220 String fileName = "vFW_VFC.yml";
221 ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
225 Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value();
226 atomicResourceMetaData.setName(vfc.getName());
228 //Certify VFC via API
229 vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
232 ResourceReqDetails vfMetaData = createVFviaAPI();
234 //Go to Catalog and find the created VF
235 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
236 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
238 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
239 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
240 CompositionPage.searchForElement(atomicResourceMetaData.getName());
241 CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
243 vfCanvasManager.clickOnCanvaElement(vfcElement);
244 CompositionPage.showPropertiesAndAttributesTab();
245 List<WebElement> properties = CompositionPage.getProperties();
246 String propertyValue = "abc123";
247 for (int i = 0; i < 2; i++) {
248 WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label"));
250 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue);
251 PropertiesPage.getPropertyPopup().clickSave();
254 findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value"));
255 AssertJUnit.assertTrue(findElement.getText().equals(propertyValue));
259 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
264 public void changeInstanceVersionTest() throws Exception{
266 ResourceReqDetails atomicResourceMetaData = null;
267 ResourceReqDetails vfMetaData = null;
268 CanvasManager vfCanvasManager;
269 CanvasElement vfcElement = null;
270 String fileName = "vFW_VFC3.yml";
272 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
273 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
274 ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName());
276 vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
277 ResourceUIUtils.createVF(vfMetaData, getUser());
278 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
279 vfCanvasManager = CanvasManager.getCanvasManager();
280 CompositionPage.searchForElement(atomicResourceMetaData.getName());
281 vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
284 CompositionPage.clickSubmitForTestingButton(vfMetaData.getName());
288 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
289 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
290 AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError));
293 reloginWithNewRole(UserRoleEnum.TESTER);
294 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
295 TesterOperationPage.certifyComponent(atomicResourceMetaData.getName());
297 reloginWithNewRole(UserRoleEnum.DESIGNER);
298 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
299 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
300 vfCanvasManager = CanvasManager.getCanvasManager();
301 CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0");
304 VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0");
308 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
313 // future removed from ui
314 @Test(enabled = false)
315 public void addUpdateDeleteSimplePropertiesToVfTest() throws Exception{
316 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
317 ResourceUIUtils.createVF(vfMetaData, getUser());
319 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
320 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER);
321 int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
322 for (PropertyTypeEnum prop : propertyList){
323 PropertiesUIUtils.addNewProperty(prop);
325 AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
326 VfVerificator.verifyPropertiesInUI(propertyList);
327 PropertiesPage.verifyTotalProperitesField(propertiesCount + propertyList.size());
330 PropertyTypeEnum prop = propertyList.get(0);
331 prop.setDescription("updatedDescription");
332 prop.setValue("value");
333 PropertiesUIUtils.updateProperty(prop);
335 PropertiesPage.clickDeletePropertyArtifact(prop.getName());
336 AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size() - 1, () -> PropertiesPage.getElemenetsFromTable()));
339 // future removed from ui
340 @Test(enabled = false)
341 public void vfcInstancesInputScreenTest() throws Exception{
342 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
343 ResourceUIUtils.createVF(vfMetaData, getUser());
345 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
346 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
348 Map<String, String> elementsIntancesMap = new HashMap<String, String>();
349 for (LeftPanelCanvasItems element : Arrays.asList(LeftPanelCanvasItems.DATABASE, LeftPanelCanvasItems.BLOCK_STORAGE)){
350 CanvasElement elementOnCanvas = vfCanvasManager.createElementOnCanvas(element);
351 vfCanvasManager.clickOnCanvaElement(elementOnCanvas);
352 String selectedInstanceName = CompositionPage.getSelectedInstanceName();
353 elementsIntancesMap.put(selectedInstanceName, element.getValue());
356 CompositionPage.moveToInputsScreen();
357 int canvasElementsSize = vfCanvasManager.getCanvasElements().size();
358 AssertJUnit.assertTrue("Instances count is not as expected: " + canvasElementsSize, InputsPage.checkElementsCountInTable(canvasElementsSize));
360 for (String element : elementsIntancesMap.keySet()){
361 String resourceName = elementsIntancesMap.get(element);
362 ResourceReqDetails resource = new ResourceReqDetails();
363 resource.setName(resourceName);
364 resource.setVersion("1.0");
365 resource.setResourceType(ResourceTypeEnum.VFC.toString());
366 RestResponse restResponse = RestCDUtils.getResource(resource, getUser());
367 Map<String, String> propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse);
369 List<WebElement> propertyRowsFromTable = InputsPage.getInstancePropertiesList(element);
370 AssertJUnit.assertTrue("Some properties are missing in table. Instance name is : " + element, propertyRowsFromTable.size() == propertiesNameTypeJson.size());
371 VfVerificator.verifyVfInputs(element, propertiesNameTypeJson, propertyRowsFromTable);
373 GeneralUIUtils.clickOnElementByText(element);
380 public void addAllInformationalArtifactPlaceholdersInVfTestApi() throws Exception{
382 ResourceReqDetails vfMetaData = createVFviaAPI();
383 //Go to Catalog and find the created VF
384 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
385 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
387 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
388 int fileNameCounter = 0;
390 for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){
391 fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX;
392 ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact,
393 FileHandling.getFilePath("uniqueFileNames"),fileName,
394 informArtifact.getValue());
397 assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue();
401 public void verifyToscaArtifactsExistApi() throws Exception{
403 ResourceReqDetails vfMetaData = createVFviaAPI();
405 //Go to Catalog and find the created VF
406 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
407 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
409 final int numOfToscaArtifacts = 2;
410 ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
411 AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
413 for(int i = 0; i < numOfToscaArtifacts; i++){
414 String typeFromScreen = ToscaArtifactsPage.getArtifactType(i);
415 AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType()));
418 //TODO Andrey should click on certify button
419 ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName());
420 vfMetaData.setVersion("1.0");
421 VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser());
425 public void testDownload() throws Exception{
426 // ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
427 // ResourceUIUtils.createResource(vfMetaData, getUser());
429 // final int numOfToscaArtifacts = 2;
430 // ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
431 // assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
432 // GeneralUIUtils.clickOnElementByTestId("download-Tosca Model");
433 // System.out.println("download me");
435 AttFtpClient attFtpClient = AttFtpClient.getInstance();
437 File retrieveLastModifiedFileFromFTP = attFtpClient.retrieveLastModifiedFileFromFTP();
438 attFtpClient.deleteFilesFromFTPserver();
442 public void vfCertificationTestApi() throws Exception{
444 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
445 Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
448 vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
450 //Go to Catalog and find the created VF
451 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
452 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
454 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
458 public void deleteVfCheckedoutTestApi() throws Exception{
460 ResourceReqDetails vfMetaData = createVFviaAPI();
462 //Go to Catalog and find the created VF
463 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
464 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
466 GeneralPageElements.clickTrashButtonAndConfirm();
468 vfMetaData.setVersion("0.1");
469 VfVerificator.verifyVfDeleted(vfMetaData, getUser());
473 public void revertVfMetadataTestApi() throws Exception{
475 ResourceReqDetails vfMetaData = createVFviaAPI();
477 //Go to Catalog and find the created VF
478 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
479 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
481 ResourceReqDetails vfRevertDetails = new ResourceReqDetails();
482 vfRevertDetails.setName("ciUpdatedName");
483 vfRevertDetails.setDescription("kuku");
484 vfRevertDetails.setCategories(vfMetaData.getCategories());
485 vfRevertDetails.setVendorName("updatedVendor");
486 vfRevertDetails.setVendorRelease("updatedRelease");
487 ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false);
489 GeneralPageElements.clickRevertButton();
491 VfVerificator.verifyVFMetadataInUI(vfMetaData);
496 public void addDeploymentArtifactInCompositionScreenTestApi() throws Exception{
498 ResourceReqDetails vfMetaData = createVFviaAPI();
500 //Go to Catalog and find the created VF
501 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
502 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
504 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
506 ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3","OTHER");
507 CompositionPage.showDeploymentArtifactTab();
508 CompositionPage.clickAddArtifactButton();
509 ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
511 List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact"));
512 AssertJUnit.assertEquals(1, actualArtifactList.size());
515 // future removed from ui
516 @Test(enabled = false)
517 public void addPropertyInCompositionScreenTest() throws Exception{
518 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
519 ResourceUIUtils.createVF(vfMetaData, getUser());
521 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
523 CompositionPage.showPropertiesAndAttributesTab();
524 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER);
525 int propertiesCount = CompositionPage.getProperties().size();
526 for (PropertyTypeEnum prop : propertyList){
527 PropertiesUIUtils.addNewProperty(prop);
529 AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> CompositionPage.getProperties()));
533 public void addDeploymentArtifactAndVerifyInCompositionScreenApi() throws Exception{
535 ResourceReqDetails vfMetaData = createVFviaAPI();
537 //Go to Catalog and find the created VF
538 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
539 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
541 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
543 ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
544 DeploymentArtifactPage.clickAddNewArtifact();
545 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
546 AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1));
548 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
550 CompositionPage.showDeploymentArtifactTab();
551 List<WebElement> deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts();
552 AssertJUnit.assertTrue(1 == deploymentArtifactsFromScreen.size());
554 String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText();
555 AssertJUnit.assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName));
559 public void checkoutVfTest() throws Exception{
560 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
561 ResourceUIUtils.createVF(vfMetaData, getUser());
563 ResourceGeneralPage.clickCheckinButton(vfMetaData.getName());
564 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
565 GeneralPageElements.clickCheckoutButton();
567 vfMetaData.setVersion("0.2");
568 VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
569 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
571 ResourceGeneralPage.clickSubmitForTestingButton(vfMetaData.getName());
573 reloginWithNewRole(UserRoleEnum.TESTER);
574 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
575 TesterOperationPage.certifyComponent(vfMetaData.getName());
577 reloginWithNewRole(UserRoleEnum.DESIGNER);
578 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
579 ResourceGeneralPage.clickCheckoutButton();
581 vfMetaData.setVersion("1.1");
582 vfMetaData.setUniqueId(null);
583 VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
584 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
588 public void deleteInstanceFromVfCanvasApi() throws Exception{
590 ResourceReqDetails vfMetaData = createVFviaAPI();
592 //Go to Catalog and find the created VF
593 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
594 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
596 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
597 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
598 CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
599 vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT);
601 vfCanvasManager.clickOnCanvaElement(computeElement);
602 vfCanvasManager.deleteElementFromCanvas(computeElement);
604 VfVerificator.verifyNumOfComponentInstances(vfMetaData, 1, getUser());
608 public void changeInstanceNameInVfTestApi() throws Exception{
610 ResourceReqDetails vfMetaData = createVFviaAPI();
612 //Go to Catalog and find the created VF
613 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
614 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
616 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
617 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
618 CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
620 String updatedInstanceName = "updatedName";
621 vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName);
623 String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName();
624 AssertJUnit.assertTrue(updatedInstanceName.equals(actualSelectedInstanceName));
629 public void submitVfForTestingWithNonCertifiedAssetApi() throws Exception{
630 String fileName = "vFW_VFC4.yml";
631 ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
634 Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value();
635 atomicResourceMetaData.setName(vfc.getName());
637 //Submit VFC for testing via API
638 vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFICATIONREQUEST, true).getLeft();
641 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
642 AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
644 //Go to Catalog and find the created VF
645 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
646 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
648 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
649 CanvasManager canvasManager = CanvasManager.getCanvasManager();
650 CompositionPage.searchForElement(atomicResourceMetaData.getName());
651 canvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
654 //TODO Andrey should click on certify button
655 CompositionPage.clickCertifyButton(vfMetaData.getName());
659 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
660 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
661 AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError));
664 ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
669 public void isDisabledAndReadOnlyInCheckinApi() throws Exception{
671 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
672 Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
674 //Check in VF via API
675 vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
677 //Go to Catalog and find the created VF
678 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
679 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
681 ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME,
682 ResourceMetadataEnum.DESCRIPTION, ResourceMetadataEnum.VENDOR_NAME, ResourceMetadataEnum.VENDOR_RELEASE,
683 ResourceMetadataEnum.CONTACT_ID};
685 for (ResourceMetadataEnum field: fieldsForCheck){
686 AssertJUnit.assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue()));
689 AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(ResourceMetadataEnum.CATEGORY.getValue()));
690 AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue()));
694 public void displayHomeAfterNavigationToOnboardingTest() throws Exception{
695 //Production bug scenario: "Home" - Click on any VF/ Service - Copy the URL - Go to “ONBOARD” - Paste the URL - Review the breadcrumbs
696 // Expected: "Home" Actual: "Onboarding"
699 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
700 Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
702 //Check in VF via API
703 vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
705 //Find the created VF on Home page
706 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
707 HomePage.navigateToHomePage();
708 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
710 //Copy current URL, navigate to OB screen and paste URL
711 String url = GeneralUIUtils.copyCurrentURL();
712 CompositionPage.moveToOnboardScreen();
713 GeneralUIUtils.navigateToURL(url);
714 GeneralUIUtils.ultimateWait();
716 //Validate that main menu button is Home and not Onboarding
717 String id = DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue();
718 WebElement button = GeneralUIUtils.getWebElementByTestID(id);
719 AssertJUnit.assertTrue(button.getAttribute("text").trim().equals("HOME"));
723 public void exportToscaWithModulePropertiesVFTest() throws Exception {
724 String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip";
725 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
726 VendorSoftwareProductObject vsp= OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser());
727 String vspName = vsp.getName();
728 ResourceGeneralPage.clickCertifyButton(vspName);
729 Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "1.0");
730 VfModuleVerificator.validateSpecificModulePropertiesFromRequest(resource);
734 public void exportToscaWithModulePropertiesTemplateCheckVFTest() throws Exception {
735 String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip";
736 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
737 OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser());
738 ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
739 GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue());
740 File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir();
741 ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir);
742 VfModuleVerificator.validateSpecificModulePropertiesFromFile(toscaDefinition);
748 protected UserRoleEnum getRole() {
749 return UserRoleEnum.DESIGNER;