2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.sanity;
23 import static org.assertj.core.api.Assertions.assertThat;
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.DataTestIdEnum;
29 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders;
30 import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
31 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
32 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
34 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
35 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
36 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
37 import org.openecomp.sdc.ci.tests.pages.*;
38 import org.openecomp.sdc.ci.tests.utilities.*;
39 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
40 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
41 import org.openecomp.sdc.ci.tests.verificator.PropertyVerificator;
42 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
43 import org.testng.Assert;
44 import org.testng.annotations.BeforeClass;
45 import org.testng.annotations.DataProvider;
46 import org.testng.annotations.Test;
48 import java.util.ArrayList;
49 import java.util.Arrays;
50 import java.util.List;
52 import static org.testng.AssertJUnit.assertTrue;
54 @Test(singleThreaded=true)
55 public class ImportVFCAsset extends SetupCDTest {
57 private ResourceReqDetails atomicResourceMetaData;
58 private String filePath;
61 public void beforeClass(){
62 filePath = FileHandling.getFilePath("");
65 @DataProvider(name = "assetFiles", parallel = false)
66 public Object[][] createDataX() {
67 return new Object[][] { { "importVFC_VFC9.yml" }, { "CP.yml" }, {"VL.yml"} };
71 public void importVFCTest() throws Exception {
72 String fileName = "importVFC_VFC1.yml";
73 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
74 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
75 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
79 public void importDuplicateVFCTest() throws Exception {
80 String fileName = "importVFC_VFC2.yml";
81 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
82 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
83 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
84 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
86 ResourceReqDetails atomicResourceMetaDataDup = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
87 ResourceCategoryEnum.NETWORK_L2_3_INFRASTRUCTURE, getUser());
89 ResourceUIUtils.importVfc(atomicResourceMetaDataDup, filePath, fileName, getUser());
93 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
94 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name());
95 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
100 public void badFileVFCTest() throws Exception {
101 String fileName = "importVFC_VFC3.yml";
102 String customFileName = "Heat-File 1.yaml";
104 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
105 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
107 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customFileName, getUser());
111 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
112 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name());
113 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
118 public void validContactAfterCreateVFCTest() throws Exception{
119 String fileName = "importVFC_VFC4.yml";
120 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
121 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
122 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
124 assertTrue("wrong userId", atomicResourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText()));
128 public void validContactAfterUpdateVFCTest() throws Exception{
129 String fileName = "importVFC_VFC5.yml";
130 String userIdUpdated = "up1234";
132 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
133 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
135 ResourceUIUtils.defineUserId(userIdUpdated);
136 assertTrue("userId is not updated",userIdUpdated.equals(ResourceGeneralPage.getContactIdText()));
140 public void addUpdateDeleteDeploymentArtifactToVFCTest() throws Exception {
141 String fileName = "importVFC_VFC6.yml";
142 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
143 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
144 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
146 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
148 List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
149 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
150 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
151 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
152 DeploymentArtifactPage.clickAddNewArtifact();
153 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true) );
155 assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
157 String newDescription = "new description";
158 DeploymentArtifactPage.updateDescription(newDescription, deploymentArtifactList.get(0));
159 String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
160 assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
162 DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
163 DeploymentArtifactPage.clickOK();
164 assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1));
166 assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed());
170 public void addUpdateDeletePlaceholdersInformationalArtifactVFCTest() throws Exception{
171 String fileName = "importVFC_VFC7.yml";
172 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
173 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
174 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
176 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
179 List<ArtifactInfo> informationalArtifactList = new ArrayList<ArtifactInfo>();
180 informationalArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
181 informationalArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuuuuku", "artifact3", "HEAT"));
182 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
183 InformationalArtifactPage.clickAddNewArtifact();
184 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
186 assertThat(InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size())).
187 as("Check that artifact table contains artifacts uploaded").isTrue();
189 // update artifact description
190 String newDescription = "new description";
191 InformationalArtifactPage.clickEditArtifact(informationalArtifactList.get(0).getArtifactLabel());
192 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
193 InformationalArtifactPage.artifactPopup().clickDoneButton();
194 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifactList.get(0).getArtifactLabel());
195 assertThat(actualArtifactDescription).as("Check artifact description update").isEqualTo(newDescription);
198 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
199 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
200 InformationalArtifactPage.clickOK();
203 assertThat(InformationalArtifactPage.checkElementsCountInTable(0)).
204 as("Check that all artifacts were deleted").isTrue();
207 int fileNameCounter = 0;
208 for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){
209 fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX;
210 ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, FileHandling.getFilePath("uniqueFileNames"),
211 fileName, informArtifact.getValue());
214 assertThat(InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length)).isTrue();
218 public void addSimplePropertiesToVFCTest() throws Exception{
219 String fileName = "importVFC_VFC8.yml";
220 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
221 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
222 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
224 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
225 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT);
226 int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
227 for (PropertyTypeEnum prop : propertyList){
228 PropertiesUIUtils.addNewProperty(prop);
230 assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
235 public void updateAfterCheckoutNewSimplePropertiesVFCTest() throws Exception{
236 String fileName = "importVFC_VFC16.yml";
237 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
238 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
239 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
241 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
242 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT);
243 int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
244 for (PropertyTypeEnum prop : propertyList){
245 PropertiesUIUtils.addNewProperty(prop);
247 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
248 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
249 GeneralPageElements.clickCheckoutButton();
250 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
252 for (PropertyTypeEnum prop : propertyList){
253 PropertiesUIUtils.updateProperty(prop);
255 assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
257 for (PropertyTypeEnum prop : propertyList){
258 PropertiesPage.clickOnProperty(prop.getName());
259 PropertyVerificator.validateEditVFCPropertiesPopoverFields(prop);
260 PropertiesPage.getPropertyPopup().clickCancel();
266 @Test(dataProvider = "assetFiles")
267 public void checkinCheckoutChangeDeleteVersionVFCTest(String customfileName) throws Exception{
268 setLog(customfileName);
269 // getExtendTest().setDescription(customfileName);
271 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
272 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
273 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customfileName, getUser());
275 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
276 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
277 GeneralPageElements.clickCheckoutButton();
278 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
280 GeneralPageElements.selectVersion("V0.1");
281 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN);
282 GeneralUIUtils.clickJSOnElementByText("latest version");
284 GeneralPageElements.clickTrashButtonAndConfirm();
285 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
286 String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText();
287 assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1"));
291 public void certificationVFCTest() throws Exception{
292 String fileName = "importVFC_VFC10.yml";
293 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
294 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
295 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
297 String vfName = atomicResourceMetaData.getName();
299 ResourceGeneralPage.clickCheckinButton(vfName);
300 GeneralUIUtils.findComponentAndClick(vfName);
301 //TODO Andrey should click on certify button
302 ResourceGeneralPage.clickCertifyButton(vfName);
304 /*reloginWithNewRole(UserRoleEnum.TESTER);
305 GeneralUIUtils.findComponentAndClick(vfName);
306 TesterOperationPage.certifyComponent(vfName);*/
308 atomicResourceMetaData.setVersion("1.0");
309 VfVerificator.verifyVFLifecycle(atomicResourceMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
311 /*reloginWithNewRole(UserRoleEnum.DESIGNER);*/
312 GeneralUIUtils.findComponentAndClick(vfName);
313 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
317 public void activityLogVFCTest() throws Exception{
318 String fileName = "importVFC_VFC11.yml";
319 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
320 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
321 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
323 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
325 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
326 InformationalArtifactPage.clickAddNewArtifact();
327 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
329 ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen();
331 int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size();
332 assertTrue("Wrong rows number, should be 2", numberOfRows == 2);
336 public void removeFileFromGeneralPageVFCTest() throws Exception{
337 String fileName = "importVFC_VFC12.yml";
339 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
340 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
341 ResourceUIUtils.importVfcNoCreate(atomicResourceMetaData, filePath, fileName, getUser());
343 GeneralPageElements.clickDeleteFile();
346 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), 30);
355 public void maxLengthGeneralInformationVFCTest() throws Exception{
356 String fileName = "importVFC_VFC13.yml";
357 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
358 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
359 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
360 ResourceUIUtils.fillMaxValueResourceGeneralInformationPage(atomicResourceMetaData);
361 // GeneralPageElements.clickUpdateButton();
362 // VFCverificator.verifyVFCUpdatedInUI(atomicResourceMetaData);
363 // GeneralPageElements.clickDeleteVersionButton();
364 // Validate that button disabled
365 assertTrue(GeneralUIUtils.checkForDisabledAttribute(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()));
371 protected UserRoleEnum getRole() {
372 return UserRoleEnum.DESIGNER;