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