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.testng.AssertJUnit.assertTrue;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.List;
30 import org.openecomp.sdc.be.dao.api.ActionStatus;
31 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
32 import org.openecomp.sdc.be.model.LifecycleStateEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
34 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
35 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders;
36 import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
38 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
42 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
43 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
44 import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
45 import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage;
46 import org.openecomp.sdc.ci.tests.pages.PropertiesPage;
47 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
48 import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
49 import org.openecomp.sdc.ci.tests.pages.UploadArtifactPopup;
50 import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
51 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
52 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
53 import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils;
54 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
55 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
56 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
57 import org.openecomp.sdc.ci.tests.verificator.VFCverificator;
58 import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
59 import org.testng.Assert;
60 import org.testng.SkipException;
61 import org.testng.annotations.BeforeClass;
62 import org.testng.annotations.BeforeMethod;
63 import org.testng.annotations.DataProvider;
64 import org.testng.annotations.Test;
66 import com.aventstack.extentreports.Status;
68 public class ImportVFCAsset extends SetupCDTest {
70 private ResourceReqDetails atomicResourceMetaData;
72 private String filePath;
74 public void beforeClass(){
75 filePath = System.getProperty("filepath");
76 if (filePath == null && System.getProperty("os.name").contains("Windows")) {
77 filePath = FileHandling.getResourcesFilesPath();
79 else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
80 filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "";
84 @DataProvider(name = "assetFiles", parallel = false)
85 public Object[][] createDataX() {
86 return new Object[][] { { "importVFC_VFC9.yml" }, { "CP.yml" }, {"VL.yml"} };
90 public void importVFCTest() throws Exception {
91 String fileName = "importVFC_VFC1.yml";
92 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
93 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
94 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
98 public void importDuplicateVFCTest() throws Exception {
99 String fileName = "importVFC_VFC2.yml";
100 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
101 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
102 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
103 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
105 ResourceReqDetails atomicResourceMetaDataDup = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
106 ResourceCategoryEnum.NETWORK_L2_3_INFRASTRUCTURE, getUser());
108 ResourceUIUtils.importVfc(atomicResourceMetaDataDup, filePath, fileName, getUser());
112 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
113 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name());
114 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
119 public void badFileVFCTest() throws Exception {
120 String fileName = "importVFC_VFC3.yml";
121 String customFileName = "Heat-File 1.yaml";
123 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
124 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
126 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customFileName, getUser());
130 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
131 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name());
132 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
137 public void validContactAfterCreateVFCTest() throws Exception{
138 String fileName = "importVFC_VFC4.yml";
139 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
140 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
141 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
143 assertTrue("wrong userId", atomicResourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText()));
147 public void validContactAfterUpdateVFCTest() throws Exception{
148 String fileName = "importVFC_VFC5.yml";
149 String userIdUpdated = "up1234";
151 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
152 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
154 ResourceUIUtils.defineUserId(userIdUpdated);
155 assertTrue("userId is not updated",userIdUpdated.equals(ResourceGeneralPage.getContactIdText()));
159 public void addUpdateDeleteDeploymentArtifactToVFCTest() throws Exception {
160 String fileName = "importVFC_VFC6.yml";
161 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
162 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
163 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
165 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
167 List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
168 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
169 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
170 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
171 DeploymentArtifactPage.clickAddNewArtifact();
172 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true) );
174 assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
176 String newDescription = "new description";
177 DeploymentArtifactPage.updateDescription(newDescription, deploymentArtifactList.get(0));
178 String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
179 assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
181 DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
182 DeploymentArtifactPage.clickOK();
183 assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1));
185 assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed());
189 public void addUpdateDeletePlaceholdersInformationalArtefactVFCTest() throws Exception{
190 String fileName = "importVFC_VFC7.yml";
191 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
192 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
193 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
195 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
198 List<ArtifactInfo> informationalArtifactList = new ArrayList<ArtifactInfo>();
199 informationalArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
200 informationalArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuuuuku", "artifact3", "HEAT"));
201 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
202 InformationalArtifactPage.clickAddNewArtifact();
203 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
205 assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size()));
207 // update artifact description
208 String newDescription = "new description";
209 InformationalArtifactPage.clickEditArtifact(informationalArtifactList.get(0).getArtifactLabel());
210 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
211 InformationalArtifactPage.artifactPopup().clickDoneButton();
212 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifactList.get(0).getArtifactLabel());
213 assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
216 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
217 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
218 InformationalArtifactPage.clickOK();
221 assertTrue("not all artifacts is deleted", InformationalArtifactPage.checkElementsCountInTable(0));
224 for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){
225 ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath,"asc_heat 0 2.yaml", informArtifact.getValue());
227 InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length);
231 public void addSimplePropertiesToVFCTest() throws Exception{
232 String fileName = "importVFC_VFC8.yml";
233 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
234 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
235 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
237 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
238 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT);
239 int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
240 for (PropertyTypeEnum prop : propertyList){
241 PropertiesUIUtils.addNewProperty(prop);
243 assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
248 @Test(dataProvider = "assetFiles")
249 public void checkinCheckoutChangeDeleteVersionVFCTest(String customfileName) throws Exception{
250 setLog(customfileName);
251 // getExtendTest().setDescription(customfileName);
253 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
254 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
255 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customfileName, getUser());
257 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
258 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
259 GeneralPageElements.clickCheckoutButton();
260 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
262 GeneralPageElements.selectVersion("V0.1");
263 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN);
264 GeneralUIUtils.clickJSOnElementByText("latest version");
266 GeneralPageElements.clickTrashButtonAndConfirm();
267 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
268 String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText();
269 assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1"));
273 public void certificationVFCTest() throws Exception{
274 String fileName = "importVFC_VFC10.yml";
275 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
276 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
277 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
279 String vfName = atomicResourceMetaData.getName();
281 ResourceGeneralPage.clickCheckinButton(vfName);
282 GeneralUIUtils.findComponentAndClick(vfName);
283 ResourceGeneralPage.clickSubmitForTestingButton(vfName);
285 reloginWithNewRole(UserRoleEnum.TESTER);
286 GeneralUIUtils.findComponentAndClick(vfName);
287 TesterOperationPage.certifyComponent(vfName);
289 atomicResourceMetaData.setVersion("1.0");
290 VfVerificator.verifyVFLifecycle(atomicResourceMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
292 reloginWithNewRole(UserRoleEnum.DESIGNER);
293 GeneralUIUtils.findComponentAndClick(vfName);
294 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
298 public void activityLogVFCTest() throws Exception{
301 throw new SkipException("Open bug 291623");
304 String fileName = "importVFC_VFC11.yml";
305 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
306 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
307 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
309 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
311 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
312 InformationalArtifactPage.clickAddNewArtifact();
313 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
315 ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen();
317 int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size();
318 assertTrue("Wrong rows number, should be 2", numberOfRows == 2);
322 public void removeFileFromGeneralPageVFCTest() throws Exception{
323 String fileName = "importVFC_VFC12.yml";
325 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
326 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
327 ResourceUIUtils.importVfcNoCreate(atomicResourceMetaData, filePath, fileName, getUser());
329 GeneralPageElements.clickDeleteFile();
332 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), 30);
341 public void maxLengthGeneralInformationVFCTest() throws Exception{
342 String fileName = "importVFC_VFC13.yml";
343 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
344 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
345 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
346 ResourceUIUtils.fillMaxValueResourceGeneralInformationPage(atomicResourceMetaData);
347 GeneralPageElements.clickUpdateButton();
348 VFCverificator.verifyVFCUpdatedInUI(atomicResourceMetaData);
349 GeneralPageElements.clickDeleteVersionButton();
355 protected UserRoleEnum getRole() {
356 return UserRoleEnum.DESIGNER;