Increase junit TCs
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / VfAPI.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.be.model.Resource;
26 import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
27 import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
28 import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
29 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
30 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders;
31 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
32 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ResourceMetadataEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ToscaArtifactsScreenEnum;
34 import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
35 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
36 import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
38 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
42 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
43 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
44 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
45 import org.openecomp.sdc.ci.tests.execute.setup.AttFtpClient;
46 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
47 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
48 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
49 import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
50 import org.openecomp.sdc.ci.tests.pages.HomePage;
51 import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage;
52 import org.openecomp.sdc.ci.tests.pages.InputsPage;
53 import org.openecomp.sdc.ci.tests.pages.PropertiesPage;
54 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
55 import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage;
56 import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
57 import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
58 import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis;
59 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
60 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
61 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
62 import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils;
63 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
64 import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
65 import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
66 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
67 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
68 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
69 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
70 import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
71 import org.openecomp.sdc.ci.tests.verificator.VfModuleVerificator;
72 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
73 import org.openqa.selenium.By;
74 import org.openqa.selenium.WebElement;
75 import org.testng.AssertJUnit;
76 import org.testng.annotations.BeforeClass;
77 import org.testng.annotations.BeforeMethod;
78 import org.testng.annotations.Test;
79
80 import java.io.File;
81 import java.util.ArrayList;
82 import java.util.Arrays;
83 import java.util.HashMap;
84 import java.util.List;
85 import java.util.Map;
86
87 import static org.assertj.core.api.Assertions.assertThat;
88
89
90 public class VfAPI extends SetupCDTest {
91
92     private String filePath;
93
94     @BeforeClass
95     public void beforeClass() {
96         filePath = FileHandling.getFilePath("");
97     }
98
99     @BeforeMethod
100     public void beforeTest() {
101         System.out.println("File repository is : " + filePath);
102         getExtendTest().log(Status.INFO, "File repository is : " + filePath);
103     }
104
105     private ResourceReqDetails createVFviaAPI() {
106         ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
107         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Creating VF %s", vfMetaData.getName()));
108         AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
109         return vfMetaData;
110     }
111
112
113     @Test
114     public void updateVF() throws Exception {
115
116         // create Resource
117         ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
118         ResourceUIUtils.createVF(resourceMetaData, getUser());
119
120         // update Resource
121         ResourceReqDetails updatedResource = new ResourceReqDetails();
122         updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName());
123         updatedResource.setDescription("kuku");
124         updatedResource.setVendorName("updatedVendor");
125         updatedResource.setVendorRelease("updatedRelease");
126         updatedResource.setContactId("ab0001");
127         updatedResource.setCategories(resourceMetaData.getCategories());
128         updatedResource.setVersion("0.1");
129         updatedResource.setResourceType(ResourceTypeEnum.VF.getValue());
130         List<String> newTags = resourceMetaData.getTags();
131         newTags.remove(resourceMetaData.getName());
132         newTags.add(updatedResource.getName());
133         updatedResource.setTags(newTags);
134         ResourceUIUtils.updateResource(updatedResource, getUser());
135
136         VfVerificator.verifyVFMetadataInUI(updatedResource);
137         VfVerificator.verifyVFUpdated(updatedResource, getUser());
138     }
139
140
141     @Test
142     public void vfcLinkedToComputeInVfFlowApi() throws Exception {
143         String fileName = "vFW_VFC2.yml";
144         ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
145
146         try {
147             //Create VFC via API
148             Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value();
149             atomicResourceMetaData.setName(vfc.getName());
150
151             //Certify VFC via API
152             vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
153
154             //Create VF via API
155             ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
156             AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
157
158             //Go to Catalog and find the created VF
159             CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
160             GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
161
162             //Composition - drag the created VFC and another element, link between them
163             DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
164             CanvasManager canvasManager = CanvasManager.getCanvasManager();
165             CompositionPage.searchForElement(String.format("%s %s", LeftPanelCanvasItems.COMPUTE.getValue(), "1.0"));
166             CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
167             CompositionPage.searchForElement(atomicResourceMetaData.getName());
168             CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
169             AssertJUnit.assertNotNull(cpElement);
170             ServiceVerificator.verifyNumOfComponentInstances(vfMetaData, "0.1", 2, getUser());
171             canvasManager.linkElements(cpElement, computeElement);
172
173             vfMetaData.setVersion("0.1");
174             VfVerificator.verifyLinkCreated(vfMetaData, getUser(), 1);
175         } finally {
176             ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
177         }
178
179     }
180
181
182     @Test
183     public void addUpdateDeleteDeploymentArtifactToVfTestApi() throws Exception {
184         //Create VF via API
185         ResourceReqDetails vfMetaData = createVFviaAPI();
186
187         //Go to Catalog and find the created VF
188         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
189         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
190
191         ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
192
193         List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
194         deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
195         deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
196         for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
197             DeploymentArtifactPage.clickAddNewArtifact();
198             ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
199         }
200         AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
201
202         String newDescription = "new description";
203         DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel());
204         DeploymentArtifactPage.artifactPopup().insertDescription(newDescription);
205         DeploymentArtifactPage.artifactPopup().clickDoneButton();
206         String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
207         AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
208
209         DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
210         DeploymentArtifactPage.clickOK();
211         AssertJUnit.assertTrue("artifact " + deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1));
212
213         AssertJUnit.assertTrue("artifact " + deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed());
214     }
215
216
217     @Test
218     public void addUpdateDeleteInformationalArtifactApi() throws Exception {
219         //Create VF via API
220         ResourceReqDetails vfMetaData = createVFviaAPI();
221
222         //Go to Catalog and find the created VF
223         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
224         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
225
226         ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
227
228         ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
229         InformationalArtifactPage.clickAddNewArtifact();
230         ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
231
232         AssertJUnit.assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1));
233
234         String newDescription = "new description";
235         InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel());
236         InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
237         InformationalArtifactPage.artifactPopup().clickDoneButton();
238         String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel());
239         AssertJUnit.assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
240
241         InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
242         InformationalArtifactPage.clickOK();
243         AssertJUnit.assertTrue("artifact " + informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0));
244     }
245
246
247     @Test
248     public void addPropertiesToVfcInstanceInVfTestApi() throws Exception {
249
250         String fileName = "vFW_VFC.yml";
251         ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
252
253         try {
254             //Create VFC via API
255             Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value();
256             atomicResourceMetaData.setName(vfc.getName());
257
258             //Certify VFC via API
259             vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
260
261             //Create VF via API
262             ResourceReqDetails vfMetaData = createVFviaAPI();
263
264             //Go to Catalog and find the created VF
265             CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
266             GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
267
268             ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
269             CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
270             CompositionPage.searchForElement(atomicResourceMetaData.getName());
271             CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
272
273             vfCanvasManager.clickOnCanvaElement(vfcElement);
274             CompositionPage.showPropertiesAndAttributesTab();
275             List<WebElement> properties = CompositionPage.getProperties();
276             String propertyValue = "abc123";
277             for (int i = 0; i < 2; i++) {
278                 WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label"));
279                 findElement.click();
280                 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue);
281                 PropertiesPage.getPropertyPopup().clickSave();
282
283
284                 findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value"));
285                 AssertJUnit.assertTrue(findElement.getText().equals(propertyValue));
286             }
287         } finally {
288             ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
289         }
290     }
291         
292 /*      @Test
293         public void changeInstanceVersionTest() throws Exception{
294                 
295                 ResourceReqDetails atomicResourceMetaData = null;
296                 ResourceReqDetails vfMetaData = null;
297                 CanvasManager vfCanvasManager;
298                 CanvasElement vfcElement = null;
299                 String fileName = "vFW_VFC3.yml";
300                 try{
301                         atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
302                         ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
303                         ResourceGeneralPage.clickSubmitForTestingButton(atomicResourceMetaData.getName());
304                         
305                         vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
306                         ResourceUIUtils.createVF(vfMetaData, getUser());
307                         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
308                         vfCanvasManager = CanvasManager.getCanvasManager();
309                         CompositionPage.searchForElement(atomicResourceMetaData.getName());
310                         vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
311                         
312                 
313                         CompositionPage.clickSubmitForTestingButton(vfMetaData.getName());
314                         assert(false);
315                 }
316                 catch(Exception e){ 
317                         String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
318                         String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
319                         AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError));
320                         
321                         
322                         reloginWithNewRole(UserRoleEnum.TESTER);
323                         GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
324                         TesterOperationPage.certifyComponent(atomicResourceMetaData.getName());
325                         
326                         reloginWithNewRole(UserRoleEnum.DESIGNER);
327                         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
328                         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
329                         vfCanvasManager = CanvasManager.getCanvasManager();
330                         CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0");
331                         
332                         //verification
333                         VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0");
334                 }
335                         
336                 finally{
337                         ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
338                 }
339                 
340         }*/
341
342     // future removed from ui
343     @Test(enabled = true)
344     public void addUpdateDeleteSimplePropertiesToVfTest() throws Exception {
345         ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
346         ResourceUIUtils.createVF(vfMetaData, getUser());
347
348         ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
349         List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER);
350         int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
351         for (PropertyTypeEnum prop : propertyList) {
352             PropertiesUIUtils.addNewProperty(prop);
353         }
354         AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
355         VfVerificator.verifyPropertiesInUI(propertyList);
356         PropertiesPage.verifyTotalProperitesField(propertiesCount + propertyList.size());
357
358
359         PropertyTypeEnum prop = propertyList.get(0);
360         prop.setDescription("updatedDescription");
361         prop.setValue("value");
362         PropertiesUIUtils.updateProperty(prop);
363
364         PropertiesPage.clickDeletePropertyArtifact(prop.getName());
365         AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size() - 1, () -> PropertiesPage.getElemenetsFromTable()));
366     }
367
368     // future removed from ui
369     @Test(enabled = true)
370     public void vfcInstancesInputScreenTest() throws Exception {
371         ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
372         ResourceUIUtils.createVF(vfMetaData, getUser());
373
374         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
375         CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
376
377         Map<String, String> elementsIntancesMap = new HashMap<String, String>();
378         for (LeftPanelCanvasItems element : Arrays.asList(LeftPanelCanvasItems.DATABASE, LeftPanelCanvasItems.BLOCK_STORAGE)) {
379             CanvasElement elementOnCanvas = vfCanvasManager.createElementOnCanvas(element);
380             vfCanvasManager.clickOnCanvaElement(elementOnCanvas);
381             String selectedInstanceName = CompositionPage.getSelectedInstanceName();
382             elementsIntancesMap.put(selectedInstanceName, element.getValue());
383         }
384
385         CompositionPage.moveToInputsScreen();
386         int canvasElementsSize = vfCanvasManager.getCanvasElements().size();
387         AssertJUnit.assertTrue("Instances count is not as expected: " + canvasElementsSize, InputsPage.checkElementsCountInTable(canvasElementsSize));
388
389         for (String element : elementsIntancesMap.keySet()) {
390             String resourceName = elementsIntancesMap.get(element);
391             ResourceReqDetails resource = new ResourceReqDetails();
392             resource.setName(resourceName);
393             resource.setVersion("1.0");
394             resource.setResourceType(ResourceTypeEnum.VFC.toString());
395             RestResponse restResponse = RestCDUtils.getResource(resource, getUser());
396             Map<String, String> propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse);
397
398             List<WebElement> propertyRowsFromTable = InputsPage.getInstancePropertiesList(element);
399             AssertJUnit.assertTrue("Some properties are missing in table. Instance name is : " + element, propertyRowsFromTable.size() == propertiesNameTypeJson.size());
400             VfVerificator.verifyVfInputs(element, propertiesNameTypeJson, propertyRowsFromTable);
401
402             GeneralUIUtils.clickOnElementByText(element);
403         }
404
405     }
406
407
408     @Test
409     public void addAllInformationalArtifactPlaceholdersInVfTestApi() throws Exception {
410         //Create VF via API
411         ResourceReqDetails vfMetaData = createVFviaAPI();
412         //Go to Catalog and find the created VF
413         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
414         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
415
416         ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
417         int fileNameCounter = 0;
418         String fileName;
419         for (InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()) {
420             fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX;
421             ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact,
422                     FileHandling.getFilePath("uniqueFileNames"), fileName,
423                     informArtifact.getValue());
424             fileNameCounter++;
425         }
426         assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue();
427     }
428
429     @Test
430     public void verifyToscaArtifactsExistApi() throws Exception {
431         //Create VF via API
432         ResourceReqDetails vfMetaData = createVFviaAPI();
433
434         //Go to Catalog and find the created VF
435         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
436         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
437
438         final int numOfToscaArtifacts = 2;
439         ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
440         AssertJUnit.assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
441
442         for (int i = 0; i < numOfToscaArtifacts; i++) {
443             String typeFromScreen = ToscaArtifactsPage.getArtifactType(i);
444             AssertJUnit.assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType()));
445         }
446
447         //TODO Andrey should click on certify button
448         ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName());
449         vfMetaData.setVersion("1.0");
450         VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser());
451     }
452
453     @Test(enabled = true)
454     public void testDownload() throws Exception {
455 //              ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
456 //              ResourceUIUtils.createResource(vfMetaData, getUser());
457 //              
458 //              final int numOfToscaArtifacts = 2;
459 //              ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
460 //              assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
461 //              GeneralUIUtils.clickOnElementByTestId("download-Tosca Model");
462 //              System.out.println("download me");
463
464         AttFtpClient attFtpClient = AttFtpClient.getFtpClient();
465
466         File retrieveLastModifiedFileFromFTP = attFtpClient.retrieveLastModifiedFileFromFTP();
467         attFtpClient.deleteFilesFromFTPserver();
468     }
469
470     @Test
471     public void vfCertificationTestApi() throws Exception {
472         //Create VF via API
473         ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
474         Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
475
476         //Certify  VF via API
477         vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
478
479         //Go to Catalog and find the created VF
480         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
481         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
482
483         VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
484     }
485
486     @Test
487     public void deleteVfCheckedoutTestApi() throws Exception {
488         //Create VF via API
489         ResourceReqDetails vfMetaData = createVFviaAPI();
490
491         //Go to Catalog and find the created VF
492         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
493         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
494
495         GeneralPageElements.clickTrashButtonAndConfirm();
496
497         vfMetaData.setVersion("0.1");
498         VfVerificator.verifyVfDeleted(vfMetaData, getUser());
499     }
500
501     @Test
502     public void revertVfMetadataTestApi() throws Exception {
503         //Create VF via API
504         ResourceReqDetails vfMetaData = createVFviaAPI();
505
506         //Go to Catalog and find the created VF
507         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
508         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
509
510         ResourceReqDetails vfRevertDetails = new ResourceReqDetails();
511         vfRevertDetails.setName("ciUpdatedName");
512         vfRevertDetails.setDescription("kuku");
513         vfRevertDetails.setCategories(vfMetaData.getCategories());
514         vfRevertDetails.setVendorName("updatedVendor");
515         vfRevertDetails.setVendorRelease("updatedRelease");
516         ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false);
517
518         GeneralPageElements.clickRevertButton();
519
520         VfVerificator.verifyVFMetadataInUI(vfMetaData);
521
522     }
523
524     @Test
525     public void addDeploymentArtifactInCompositionScreenTestApi() throws Exception {
526         //Create VF via API
527         ResourceReqDetails vfMetaData = createVFviaAPI();
528
529         //Go to Catalog and find the created VF
530         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
531         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
532
533         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
534
535         ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3", "OTHER");
536         CompositionPage.showDeploymentArtifactTab();
537         CompositionPage.clickAddArtifactButton();
538         ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
539
540         List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact"));
541         AssertJUnit.assertEquals(1, actualArtifactList.size());
542     }
543
544     // future removed from ui
545     @Test(enabled = true)
546     public void addPropertyInCompositionScreenTest() throws Exception {
547         ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
548         ResourceUIUtils.createVF(vfMetaData, getUser());
549
550         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
551
552         CompositionPage.showPropertiesAndAttributesTab();
553         List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER);
554         int propertiesCount = CompositionPage.getProperties().size();
555         for (PropertyTypeEnum prop : propertyList) {
556             PropertiesUIUtils.addNewProperty(prop);
557         }
558         AssertJUnit.assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> CompositionPage.getProperties()));
559     }
560
561     @Test
562     public void addDeploymentArtifactAndVerifyInCompositionScreenApi() throws Exception {
563         //Create VF via API
564         ResourceReqDetails vfMetaData = createVFviaAPI();
565
566         //Go to Catalog and find the created VF
567         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
568         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
569
570         ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
571
572         ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
573         DeploymentArtifactPage.clickAddNewArtifact();
574         ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
575         AssertJUnit.assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1));
576
577         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
578
579         CompositionPage.showDeploymentArtifactTab();
580         List<WebElement> deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts();
581         AssertJUnit.assertTrue(1 == deploymentArtifactsFromScreen.size());
582
583         String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText();
584         AssertJUnit.assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName));
585     }
586         
587         /*@Test
588         public void checkoutVfTest() throws Exception{
589                 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
590                 ResourceUIUtils.createVF(vfMetaData, getUser());
591                 
592                 ResourceGeneralPage.clickCheckinButton(vfMetaData.getName());
593                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
594                 GeneralPageElements.clickCheckoutButton();
595                 
596                 vfMetaData.setVersion("0.2");
597                 VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
598                 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
599                 
600                 ResourceGeneralPage.clickSubmitForTestingButton(vfMetaData.getName());
601                 
602                 reloginWithNewRole(UserRoleEnum.TESTER);
603                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
604                 TesterOperationPage.certifyComponent(vfMetaData.getName());
605                 
606                 reloginWithNewRole(UserRoleEnum.DESIGNER);
607                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
608                 ResourceGeneralPage.clickCheckoutButton();
609                 
610                 vfMetaData.setVersion("1.1");
611                 vfMetaData.setUniqueId(null);
612                 VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
613                 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
614         }*/
615
616     @Test
617     public void deleteInstanceFromVfCanvasApi() throws Exception {
618         //Create VF via API
619         ResourceReqDetails vfMetaData = createVFviaAPI();
620
621         //Go to Catalog and find the created VF
622         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
623         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
624
625         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
626         CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
627         CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
628         vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.PORT);
629
630         vfCanvasManager.clickOnCanvaElement(computeElement);
631         vfCanvasManager.deleteElementFromCanvas(computeElement);
632
633         VfVerificator.verifyNumOfComponentInstances(vfMetaData, 1, getUser());
634     }
635
636     @Test
637     public void changeInstanceNameInVfTestApi() throws Exception {
638         //Create VF via API
639         ResourceReqDetails vfMetaData = createVFviaAPI();
640
641         //Go to Catalog and find the created VF
642         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
643         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
644
645         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
646         CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
647         CanvasElement computeElement = vfCanvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
648
649         String updatedInstanceName = "updatedName";
650         vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName);
651
652         String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName();
653         AssertJUnit.assertTrue(updatedInstanceName.equals(actualSelectedInstanceName));
654     }
655         
656         
657         /*@Test
658         public void submitVfForTestingWithNonCertifiedAssetApi() throws Exception{
659                 String fileName = "vFW_VFC4.yml";
660                 ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
661                 
662                 //Create VFC via API
663                 Resource vfc = AtomicOperationUtils.importResource(filePath, fileName).left().value();
664                 atomicResourceMetaData.setName(vfc.getName());
665                 
666                 //Submit VFC for testing via API
667                 vfc = (Resource) AtomicOperationUtils.changeComponentState(vfc, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFICATIONREQUEST, true).getLeft();
668
669                 //Create VF via API
670                 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
671                 AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
672                 
673                 //Go to Catalog and find the created VF
674                 CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
675                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
676                 
677                 DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
678                 CanvasManager canvasManager = CanvasManager.getCanvasManager();
679                 CompositionPage.searchForElement(atomicResourceMetaData.getName());
680                 canvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
681                 
682                 try{
683                         //TODO Andrey should click on certify button
684                         CompositionPage.clickCertifyButton(vfMetaData.getName());
685                         assert(false);
686                 }
687                 catch(Exception e){ 
688                         String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
689                         String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
690                         AssertJUnit.assertTrue(errorMessage.contains(checkUIResponseOnError));  
691                 }
692                 finally{
693                         ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
694                 }
695         }*/
696
697     @Test
698     public void isDisabledAndReadOnlyInCheckinApi() throws Exception {
699         //Create VF via API
700         ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
701         Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
702
703         //Check in  VF via API
704         vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
705
706         //Go to Catalog and find the created VF
707         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
708         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
709
710         ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME,
711                 ResourceMetadataEnum.DESCRIPTION, ResourceMetadataEnum.VENDOR_NAME, ResourceMetadataEnum.VENDOR_RELEASE,
712                 ResourceMetadataEnum.CONTACT_ID};
713
714         for (ResourceMetadataEnum field : fieldsForCheck) {
715             AssertJUnit.assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue()));
716         }
717
718         AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(ResourceMetadataEnum.CATEGORY.getValue()));
719         AssertJUnit.assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue()));
720     }
721
722     @Test
723     public void displayHomeAfterNavigationToOnboardingTest() throws Exception {
724         //Production bug scenario: "Home" - Click on any VF/ Service - Copy the URL - Go to “ONBOARD” - Paste the URL - Review the breadcrumbs
725         // Expected: "Home"       Actual: "Onboarding"
726
727         //Create VF via API
728         ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
729         Resource vf = AtomicOperationUtils.createResourceByResourceDetails(vfMetaData, UserRoleEnum.DESIGNER, true).left().value();
730
731         //Check in  VF via API
732         vf = (Resource) AtomicOperationUtils.changeComponentState(vf, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKIN, true).getLeft();
733
734         //Find the created VF on Home page
735         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
736         HomePage.navigateToHomePage();
737         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
738
739         //Copy current URL, navigate to OB screen and paste URL
740         String url = GeneralUIUtils.copyCurrentURL();
741         CompositionPage.moveToOnboardScreen();
742         GeneralUIUtils.navigateToURL(url);
743         GeneralUIUtils.ultimateWait();
744
745         //Validate that main menu button is Home and not Onboarding
746         String id = DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue();
747         WebElement button = GeneralUIUtils.getWebElementByTestID(id);
748         AssertJUnit.assertTrue(button.getAttribute("text").trim().equals("HOME"));
749     }
750
751     @Test
752     public void exportToscaWithModulePropertiesVFTest() throws Exception {
753         String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip";
754         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
755         VendorSoftwareProductObject vsp = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser());
756         String vspName = vsp.getName();
757         ResourceGeneralPage.clickCertifyButton(vspName);
758         Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, vspName, "1.0");
759         VfModuleVerificator.validateSpecificModulePropertiesFromRequest(resource);
760     }
761
762     @Test
763     public void exportToscaWithModulePropertiesTemplateCheckVFTest() throws Exception {
764         String vnfFile = "1-Vf-zrdm5bpxmc02-092017-(MOBILITY)_v2.0.zip";
765         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
766         OnboardingUiUtils.onboardAndValidate(resourceReqDetails, FileHandling.getVnfRepositoryPath(), vnfFile, getUser());
767         ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
768         GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue());
769         File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir();
770         ToscaDefinition toscaDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir);
771         VfModuleVerificator.validateSpecificModulePropertiesFromFile(toscaDefinition);
772     }
773
774
775     @Override
776     protected UserRoleEnum getRole() {
777         return UserRoleEnum.DESIGNER;
778     }
779
780 }