f9cb233448ad70b18d2de9da4db3de7d7666e254
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / ImportDCAE.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.dao.api.ActionStatus;
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.be.model.LifecycleStateEnum;
27 import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
28 import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
29 import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
30 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders;
32 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.LeftPanelCanvasItems;
33 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ResourceMetadataEnum;
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.enums.ArtifactTypeEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
38 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
42 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
43 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
44 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
45 import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
46 import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage;
47 import org.openecomp.sdc.ci.tests.pages.InputsPage;
48 import org.openecomp.sdc.ci.tests.pages.PropertiesPage;
49 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
50 import org.openecomp.sdc.ci.tests.pages.ToscaArtifactsPage;
51 import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
52 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
53 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
54 import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils;
55 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
56 import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
57 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
58 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
59 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
60 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
61 import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
62 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
63 import org.openqa.selenium.By;
64 import org.openqa.selenium.WebElement;
65 import org.testng.Assert;
66 import org.testng.annotations.BeforeMethod;
67 import org.testng.annotations.Test;
68
69 import java.util.ArrayList;
70 import java.util.Arrays;
71 import java.util.HashMap;
72 import java.util.List;
73 import java.util.Map;
74
75 import static org.assertj.core.api.Assertions.assertThat;
76 import static org.testng.AssertJUnit.assertTrue;
77
78 public class ImportDCAE extends SetupCDTest {
79
80     private static final int CLICKING_ON_ELEMENT_TIMEOUT = 30;
81
82     private static final String SERVICE_INPUT_TEST_VF2_CSAR = "service_input_test_VF2.csar";
83     private String filePath;
84
85     @BeforeMethod
86     public void beforeTest() {
87         filePath = FileHandling.getFilePath("");
88     }
89
90     @Test
91     public void updateDCAEAsset() throws Exception {
92         ResourceReqDetails resourceMetaData = createDCAEAsset();
93
94         // update Resource
95         ResourceReqDetails updatedResource = new ResourceReqDetails();
96         updatedResource.setName(ElementFactory.getResourcePrefix() + "UpdatedName" + resourceMetaData.getName());
97         updatedResource.setDescription("kuku");
98         updatedResource.setVendorName("updatedVendor");
99         updatedResource.setVendorRelease("updatedRelease");
100         updatedResource.setContactId("ab0001");
101         updatedResource.setCategories(resourceMetaData.getCategories());
102         updatedResource.setVersion("0.1");
103         List<String> newTags = resourceMetaData.getTags();
104         newTags.remove(resourceMetaData.getName());
105         newTags.add(updatedResource.getName());
106         updatedResource.setTags(newTags);
107         ResourceUIUtils.updateResource(updatedResource, getUser());
108
109         VfVerificator.verifyVFMetadataInUI(updatedResource);
110         VfVerificator.verifyVFUpdated(updatedResource, getUser());
111     }
112
113     @Test
114     public void vfcLinkedToComputeInDCAEAssetFlowTest() throws Exception {
115         final int expectedNumberOfComponentInstances = 4;
116         String fileName = "importVFC_VFC14.yml";
117         ResourceReqDetails atomicResourceMetaData =
118                 ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(
119                         ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
120                         ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
121
122         try {
123             ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
124             //TODO Andrey should click on certify button
125             ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName());
126                         
127                         /*reloginWithNewRole(UserRoleEnum.TESTER);
128                         GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
129                         TesterOperationPage.certifyComponent(atomicResourceMetaData.getName());
130         
131                         reloginWithNewRole(UserRoleEnum.DESIGNER);*/
132             ResourceReqDetails resourceMetaData = createDCAEAsset();
133
134             DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
135             CanvasManager canvasManager = CanvasManager.getCanvasManager();
136             CanvasElement computeElement = canvasManager.createElementOnCanvas(LeftPanelCanvasItems.COMPUTE);
137             CompositionPage.searchForElement(atomicResourceMetaData.getName());
138             CanvasElement cpElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
139             Assert.assertNotNull(cpElement);
140             ServiceVerificator.verifyNumOfComponentInstances(
141                     resourceMetaData, "0.1",
142                     expectedNumberOfComponentInstances, getUser());
143
144             canvasManager.linkElements(cpElement, computeElement);
145
146             resourceMetaData.setVersion("0.1");
147             VfVerificator.verifyLinkCreated(resourceMetaData, getUser(), 1);
148         } finally {
149             ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
150         }
151
152     }
153
154     @Test
155     public void addUpdateDeleteDeploymentArtifactToDCAEAssetTest() throws Exception {
156         createDCAEAsset();
157         ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
158
159         List<ArtifactInfo> deploymentArtifactList = new ArrayList<>();
160         deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType()));
161         deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", ArtifactTypeEnum.YANG_XML.getType()));
162         for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
163             DeploymentArtifactPage.clickAddNewArtifact();
164             ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
165         }
166         assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
167
168         String newDescription = "new description";
169         DeploymentArtifactPage.clickEditArtifact(deploymentArtifactList.get(0).getArtifactLabel());
170         DeploymentArtifactPage.artifactPopup().insertDescription(newDescription);
171         DeploymentArtifactPage.artifactPopup().clickDoneButton();
172         String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
173         assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
174
175         DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
176         DeploymentArtifactPage.clickOK();
177         assertTrue("artifact " + deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1));
178
179         assertTrue("artifact " + deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed());
180     }
181
182     @Test
183     public void addUpdateDeleteInformationalArtifactDCAEAssetTest() throws Exception {
184         createDCAEAsset();
185         ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
186
187         ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType());
188         InformationalArtifactPage.clickAddNewArtifact();
189         ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
190
191         assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(1));
192
193         String newDescription = "new description";
194         InformationalArtifactPage.clickEditArtifact(informationalArtifact.getArtifactLabel());
195         InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
196         InformationalArtifactPage.artifactPopup().clickDoneButton();
197         String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifact.getArtifactLabel());
198         assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
199
200         InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
201         InformationalArtifactPage.clickOK();
202         assertTrue("artifact " + informationalArtifact.getArtifactLabel() + "is not deleted", InformationalArtifactPage.checkElementsCountInTable(0));
203     }
204
205     @Test
206     public void addPropertiesToVfcInstanceInDCAEAssetTest() throws Exception {
207
208         if (true) {
209 //                      throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance  on Composition screen");
210             SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance  on Composition screen");
211         }
212
213         String fileName = "importVFC_VFC15.yml";
214         ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
215
216         try {
217             ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
218             ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
219
220             createDCAEAsset();
221
222             ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
223             CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
224             CompositionPage.searchForElement(atomicResourceMetaData.getName());
225             CanvasElement vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
226
227             vfCanvasManager.clickOnCanvaElement(vfcElement);
228             CompositionPage.showPropertiesAndAttributesTab();
229             List<WebElement> properties = CompositionPage.getProperties();
230             String propertyValue = "abc123";
231             for (int i = 0; i < 2; i++) {
232                 WebElement findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-and-attribute-label"));
233                 findElement.click();
234                 PropertiesPage.getPropertyPopup().insertPropertyDefaultValue(propertyValue);
235                 PropertiesPage.getPropertyPopup().clickSave();
236
237                 findElement = properties.get(i).findElement(By.className("i-sdc-designer-sidebar-section-content-item-property-value"));
238                 assertTrue(findElement.getText().equals(propertyValue));
239             }
240         } finally {
241             ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
242         }
243     }
244
245     @Test
246     public void changeInstanceVersionDCAEAssetTest() throws Exception {
247         ResourceReqDetails atomicResourceMetaData = null;
248         ResourceReqDetails vfMetaData = null;
249         CanvasManager vfCanvasManager;
250         CanvasElement vfcElement = null;
251         String fileName = "importVFC_VFC16.yml";
252         try {
253             atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
254             ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
255             //TODO Andrey changed to click on checkIn button
256             ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
257
258             vfMetaData = createDCAEAsset();
259             ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
260             vfCanvasManager = CanvasManager.getCanvasManager();
261             CompositionPage.searchForElement(atomicResourceMetaData.getName());
262             vfcElement = vfCanvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
263             //TODO Andrey should click on certify button
264             CompositionPage.clickCertifyButton(vfMetaData.getName());
265             assert (false);
266         } catch (Exception e) {
267             String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
268             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
269             Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
270             GeneralUIUtils.closeErrorMessage();
271             GeneralPageElements.clickOnHomeButton();
272
273             GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
274             ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName());
275
276             GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
277             ResourceGeneralPage.clickCheckoutButton();
278             ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
279             vfMetaData.setVersion("0.2");
280             vfCanvasManager = CanvasManager.getCanvasManager();
281             CompositionPage.changeComponentVersion(vfCanvasManager, vfcElement, "1.0");
282
283             //verfication
284             VfVerificator.verifyInstanceVersion(vfMetaData, getUser(), atomicResourceMetaData.getName(), "1.0");
285         } finally {
286             ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "1.0");
287         }
288
289     }
290
291     // future removed from ui
292     @Test(enabled = false)
293     public void addUpdateDeleteSimplePropertiesToDCAEAssetTest() throws Exception {
294         createDCAEAsset();
295
296         ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
297         List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER);
298         int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
299         for (PropertyTypeEnum prop : propertyList) {
300             PropertiesUIUtils.addNewProperty(prop);
301         }
302         assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
303         VfVerificator.verifyPropertiesInUI(propertyList);
304         PropertiesPage.verifyTotalProperitesField(propertiesCount + propertyList.size());
305
306         PropertyTypeEnum prop = propertyList.get(0);
307         prop.setDescription("updatedDescription");
308         prop.setValue("value");
309         PropertiesUIUtils.updateProperty(prop);
310
311         PropertiesPage.clickDeletePropertyArtifact(prop.getName());
312         assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size() - 1, () -> PropertiesPage.getElemenetsFromTable()));
313     }
314
315     // future removed from ui
316     @Test(enabled = false)
317     public void DCAEAssetInstancesInputScreenTest() throws Exception {
318         createDCAEAsset();
319
320         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
321         CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
322
323         Map<String, String> elementsIntancesMap = new HashMap<String, String>();
324         for (LeftPanelCanvasItems element : Arrays.asList(LeftPanelCanvasItems.DATABASE)) {
325             CanvasElement elementOnCanvas = vfCanvasManager.createElementOnCanvas(element);
326             vfCanvasManager.clickOnCanvaElement(elementOnCanvas);
327             String selectedInstanceName = CompositionPage.getSelectedInstanceName();
328             elementsIntancesMap.put(selectedInstanceName, element.getValue());
329         }
330
331         CompositionPage.moveToInputsScreen();
332         int canvasElementsSize = vfCanvasManager.getCanvasElements().size() + 2;
333         List<String> inputsNamesFromTable = InputsPage.getVFCInstancesNamesFromTable();
334         assertTrue(String.format("Instances count is not as Expected: %s Actual: %s", canvasElementsSize, inputsNamesFromTable.size()), inputsNamesFromTable.size() == canvasElementsSize);
335
336         for (String instanceName : inputsNamesFromTable) {
337             String resourceName = instanceName.split(" ")[0];
338             ResourceReqDetails resource = new ResourceReqDetails();
339             resource.setName(resourceName);
340             resource.setVersion("1.0");
341             if (resourceName.equals("Port")) {
342                 resource.setResourceType(ResourceTypeEnum.CP.toString());
343             } else {
344                 resource.setResourceType(ResourceTypeEnum.VFC.toString());
345             }
346             RestResponse restResponse = RestCDUtils.getResource(resource, getUser());
347             Map<String, String> propertiesNameTypeJson = ResponseParser.getPropertiesNameType(restResponse);
348
349             List<WebElement> propertyRowsFromTable = InputsPage.getInstancePropertiesList(resourceName);
350             assertTrue("Some properties are missing in table. Instance name is : " + resourceName, propertyRowsFromTable.size() == propertiesNameTypeJson.size());
351             VfVerificator.verifyVfInputs(instanceName, propertiesNameTypeJson, propertyRowsFromTable);
352
353             GeneralUIUtils.clickOnElementByText(resourceName);
354         }
355     }
356
357     @Test
358     public void addAllInformationalArtifactPlaceholdersInDCAEAssetTest() throws Exception {
359         createDCAEAsset();
360         ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
361         int fileNameCounter = 0;
362         String fileName;
363         for (InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()) {
364             fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX;
365             ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact,
366                     FileHandling.getFilePath("uniqueFileNames"), fileName, informArtifact.getValue());
367             fileNameCounter++;
368         }
369
370         assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue();
371     }
372
373     @Test
374     public void verifyToscaArtifactsExistDCAEAssetTest() throws Exception {
375         ResourceReqDetails vfMetaData = createDCAEAsset();
376
377         final int numOfToscaArtifacts = 2;
378         ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
379         assertTrue(ToscaArtifactsPage.checkElementsCountInTable(numOfToscaArtifacts));
380
381         for (int i = 0; i < numOfToscaArtifacts; i++) {
382             String typeFromScreen = ToscaArtifactsPage.getArtifactType(i);
383             assertTrue(typeFromScreen.equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) || typeFromScreen.equals(ArtifactTypeEnum.TOSCA_TEMPLATE.getType()));
384         }
385         //TODO Andrey should click on certify button
386         ToscaArtifactsPage.clickCertifyButton(vfMetaData.getName());
387         vfMetaData.setVersion("1.0");
388         VfVerificator.verifyToscaArtifactsInfo(vfMetaData, getUser());
389     }
390
391     @Test
392     public void DCAEAssetCertificationTest() throws Exception {
393         ResourceReqDetails vfMetaData = createDCAEAsset();
394
395         String vfName = vfMetaData.getName();
396
397         ResourceGeneralPage.clickCheckinButton(vfName);
398         GeneralUIUtils.findComponentAndClick(vfName);
399         //TODO Andrey should click on certify button
400         ResourceGeneralPage.clickCertifyButton(vfName);
401                 
402                 /*reloginWithNewRole(UserRoleEnum.TESTER);
403                 GeneralUIUtils.findComponentAndClick(vfName);
404                 TesterOperationPage.certifyComponent(vfName);*/
405
406         vfMetaData.setVersion("1.0");
407         VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
408
409         /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
410         GeneralUIUtils.findComponentAndClick(vfName);
411         VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
412     }
413
414     @Test
415     public void deleteDCAEAssetCheckedoutTest() throws Exception {
416         ResourceReqDetails vfMetaData = createDCAEAsset();
417
418         GeneralPageElements.clickTrashButtonAndConfirm();
419
420         vfMetaData.setVersion("0.1");
421         VfVerificator.verifyVfDeleted(vfMetaData, getUser());
422     }
423
424     @Test
425     public void revertDCAEAssetMetadataTest() throws Exception {
426         ResourceReqDetails vfMetaData = createDCAEAsset();
427
428         ResourceReqDetails vfRevertDetails = new ResourceReqDetails();
429         vfRevertDetails.setName("ciUpdatedName");
430         vfRevertDetails.setDescription("kuku");
431         vfRevertDetails.setCategories(vfMetaData.getCategories());
432         vfRevertDetails.setVendorName("updatedVendor");
433         vfRevertDetails.setVendorRelease("updatedRelease");
434         ResourceUIUtils.fillResourceGeneralInformationPage(vfRevertDetails, getUser(), false);
435
436         GeneralPageElements.clickRevertButton();
437
438         VfVerificator.verifyVFMetadataInUI(vfMetaData);
439     }
440
441     @Test
442     public void addDeploymentArtifactInCompositionScreenDCAEAssetTest() throws Exception {
443         createDCAEAsset();
444
445         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
446
447         ArtifactInfo artifact = new ArtifactInfo(filePath, "Heat-File.yaml", "kuku", "artifact3", ArtifactTypeEnum.OTHER.getType());
448         CompositionPage.showDeploymentArtifactTab();
449         CompositionPage.clickAddArtifactButton();
450         ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
451
452         List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className("i-sdc-designer-sidebar-section-content-item-artifact"));
453         Assert.assertEquals(1, actualArtifactList.size());
454     }
455
456     // future removed from ui
457     @Test(enabled = false)
458     public void addPropertyInCompositionScreenDCAEAssetTest() throws Exception {
459         createDCAEAsset();
460
461         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
462
463         CompositionPage.showPropertiesAndAttributesTab();
464         List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER);
465         int propertiesCount = CompositionPage.getProperties().size();
466         for (PropertyTypeEnum prop : propertyList) {
467             PropertiesUIUtils.addNewProperty(prop);
468         }
469         assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> CompositionPage.getProperties()));
470     }
471
472     @Test
473     public void addDeploymentArtifactAndVerifyInCompositionScreenDCAEAssetTest() throws Exception {
474         createDCAEAsset();
475
476         ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
477
478         ArtifactInfo deploymentArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType());
479         DeploymentArtifactPage.clickAddNewArtifact();
480         ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact);
481         assertTrue(DeploymentArtifactPage.checkElementsCountInTable(1));
482
483         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
484
485         CompositionPage.showDeploymentArtifactTab();
486         List<WebElement> deploymentArtifactsFromScreen = CompositionPage.getDeploymentArtifacts();
487         assertTrue(1 == deploymentArtifactsFromScreen.size());
488
489         String actualArtifactFileName = deploymentArtifactsFromScreen.get(0).getText();
490         assertTrue("asc_heat-0-2.yaml".equals(actualArtifactFileName));
491     }
492
493     @Test
494     public void checkoutDCAEAssetTest() throws Exception {
495         ResourceReqDetails vfMetaData = createDCAEAsset();
496
497         ResourceGeneralPage.clickCheckinButton(vfMetaData.getName());
498         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
499         GeneralPageElements.clickCheckoutButton();
500
501         vfMetaData.setVersion("0.2");
502         VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
503         VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
504         //TODO Andrey should click on certify button
505         ResourceGeneralPage.clickCertifyButton(vfMetaData.getName());
506                 
507                 /*reloginWithNewRole(UserRoleEnum.TESTER);
508                 GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
509                 TesterOperationPage.certifyComponent(vfMetaData.getName());
510                 
511                 reloginWithNewRole(UserRoleEnum.DESIGNER);*/
512         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
513         ResourceGeneralPage.clickCheckoutButton();
514
515         vfMetaData.setVersion("1.1");
516         vfMetaData.setUniqueId(null);
517         VfVerificator.verifyVFLifecycle(vfMetaData, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
518         VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
519     }
520
521     @Test
522     public void deleteInstanceFromDCAEAssetCanvas() throws Exception {
523         ResourceReqDetails vfMetaData = createDCAEAsset();
524
525         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
526         CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
527         CanvasElement computeElement = CompositionPage.addElementToCanvasScreen(LeftPanelCanvasItems.COMPUTE, vfCanvasManager);
528
529         vfCanvasManager.clickOnCanvaElement(computeElement);
530         vfCanvasManager.deleteElementFromCanvas(computeElement);
531
532         VfVerificator.verifyNumOfComponentInstances(vfMetaData, 2, getUser());
533     }
534
535     @Test
536     public void changeInstanceNameInDCAEAssetTest() throws Exception {
537         createDCAEAsset();
538
539         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
540         CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
541         CanvasElement computeElement = CompositionPage.addElementToCanvasScreen(LeftPanelCanvasItems.COMPUTE, vfCanvasManager);
542
543         String updatedInstanceName = "updatedName";
544         vfCanvasManager.updateElementNameInCanvas(computeElement, updatedInstanceName);
545
546         String actualSelectedInstanceName = CompositionPage.getSelectedInstanceName();
547         assertTrue(updatedInstanceName.equals(actualSelectedInstanceName));
548     }
549
550     @Test
551     public void submitDCAEAssetForTestingWithNonCertifiedAsset() throws Exception {
552         String fileName = "importVFC_VFC17.yml";
553
554         ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
555         ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
556         //TODO Andrey changed to click on checkIn button
557         ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
558
559         ResourceReqDetails vfMetaData = createDCAEAsset();
560         DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
561         CanvasManager canvasManager = CanvasManager.getCanvasManager();
562         CompositionPage.addElementToCanvasScreen(atomicResourceMetaData.getName(), canvasManager);
563
564         try {
565             //TODO Andrey should click on certify button
566             CompositionPage.clickCertifyButton(vfMetaData.getName());
567             assert (false);
568         } catch (Exception e) {
569             String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
570             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
571             Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
572         } finally {
573             ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
574         }
575     }
576
577     @Test
578     public void isDisabledAndReadOnlyInCheckinDCAEAssetTest() throws Exception {
579         ResourceReqDetails vfMetaData = createDCAEAsset();
580         ResourceGeneralPage.clickCheckinButton(vfMetaData.getName());
581         GeneralUIUtils.findComponentAndClick(vfMetaData.getName());
582
583         ResourceMetadataEnum[] fieldsForCheck = {ResourceMetadataEnum.RESOURCE_NAME,
584                 ResourceMetadataEnum.DESCRIPTION,
585                 ResourceMetadataEnum.VENDOR_NAME,
586                 ResourceMetadataEnum.VENDOR_RELEASE,
587                 ResourceMetadataEnum.CONTACT_ID,
588                 ResourceMetadataEnum.CATEGORY,
589                 ResourceMetadataEnum.TAGS};
590
591         for (ResourceMetadataEnum field : fieldsForCheck) {
592             VfVerificator.verifyIsElementDisabled(field.getValue(), field.name());
593         }
594         VfVerificator.verifyIsElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue(), DataTestIdEnum.LifeCyleChangeButtons.CREATE.name());
595     }
596
597     @Test
598     public void removeFileFromGeneralPageDCAEAssetTest() throws Exception {
599         String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR;
600         ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
601         ResourceUIUtils.importVfFromCsarNoCreate(resourceMetaData, filePath, fileName2, getUser());
602         GeneralPageElements.clickDeleteFile();
603
604         try {
605             GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), CLICKING_ON_ELEMENT_TIMEOUT);
606             assert (false);
607         } catch (Exception e) {
608             assert (true);
609         }
610     }
611
612     @Test
613     public void activityLogDCAEAssetTest() throws Exception {
614         createDCAEAsset();
615
616         ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
617
618         ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", ArtifactTypeEnum.OTHER.getType());
619         InformationalArtifactPage.clickAddNewArtifact();
620         ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
621
622         ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen();
623
624         int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size();
625         assertTrue("Wrong rows number, should be 2", numberOfRows == 2);
626     }
627
628     @Test
629     public void checkinCheckoutChangeDeleteVersionDCAEAssetTest() throws Exception {
630         ResourceReqDetails atomicResourceMetaData = createDCAEAsset();
631
632         ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
633         GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
634         GeneralPageElements.clickCheckoutButton();
635         VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
636
637         GeneralPageElements.selectVersion("V0.1");
638         VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN);
639         GeneralUIUtils.clickJSOnElementByText("latest version");
640
641         GeneralPageElements.clickTrashButtonAndConfirm();
642         GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
643         String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText();
644         assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1"));
645     }
646
647     @Test
648     public void badFileDCAEAssetTest() throws Exception {
649         String customFileName = "badVF.csar";
650         ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
651         try {
652             ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, customFileName, getUser());
653             assert (false);
654         } catch (Exception e) {
655             String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
656             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.CSAR_INVALID.name());
657             SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating error messdge..."));
658             Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
659         }
660     }
661
662     @Test
663     public void validContactAfterCreateDCAEAssetTest() throws Exception {
664         ResourceReqDetails resourceMetaData = createDCAEAsset();
665         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating that userID equal to user that was logged in..."));
666         assertTrue("Wrong userId", resourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText()));
667     }
668
669     public ResourceReqDetails createDCAEAsset() throws Exception {
670         String fileName2 = SERVICE_INPUT_TEST_VF2_CSAR;
671         ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
672         ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser());
673         resourceMetaData.setVersion("0.1");
674         return resourceMetaData;
675     }
676
677     @Override
678     protected UserRoleEnum getRole() {
679         return UserRoleEnum.DESIGNER;
680     }
681
682 }