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.annotations.BeforeClass;
61 import org.testng.annotations.BeforeMethod;
62 import org.testng.annotations.DataProvider;
63 import org.testng.annotations.Test;
65 import com.aventstack.extentreports.Status;
67 public class ImportVFCAsset extends SetupCDTest {
69 private ResourceReqDetails atomicResourceMetaData;
71 private String filePath;
73 public void beforeClass(){
74 filePath = System.getProperty("filepath");
75 if (filePath == null && System.getProperty("os.name").contains("Windows")) {
76 filePath = FileHandling.getResourcesFilesPath();
78 else if(filePath.isEmpty() && !System.getProperty("os.name").contains("Windows")){
79 filePath = FileHandling.getBasePath() + File.separator + "Files" + File.separator + "";
83 @DataProvider(name = "assetFiles", parallel = false)
84 public Object[][] createDataX() {
85 return new Object[][] { { "importVFC_VFC9.yml" }, { "CP.yml" }, {"VL.yml"} };
89 public void importVFCTest() throws Exception {
90 String fileName = "importVFC_VFC1.yml";
91 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
92 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
93 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
97 public void importDuplicateVFCTest() throws Exception {
98 String fileName = "importVFC_VFC2.yml";
99 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
100 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
101 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
102 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
104 ResourceReqDetails atomicResourceMetaDataDup = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
105 ResourceCategoryEnum.NETWORK_L2_3_INFRASTRUCTURE, getUser());
107 ResourceUIUtils.importVfc(atomicResourceMetaDataDup, filePath, fileName, getUser());
111 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
112 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name());
113 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
118 public void badFileVFCTest() throws Exception {
119 String fileName = "importVFC_VFC3.yml";
120 String customFileName = "Heat-File 1.yaml";
122 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
123 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
125 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customFileName, getUser());
129 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
130 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name());
131 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
136 public void validContactAfterCreateVFCTest() throws Exception{
137 String fileName = "importVFC_VFC4.yml";
138 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
139 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
140 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
142 assertTrue("wrong userId", atomicResourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText()));
146 public void validContactAfterUpdateVFCTest() throws Exception{
147 String fileName = "importVFC_VFC5.yml";
148 String userIdUpdated = "up1234";
150 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
151 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
153 ResourceUIUtils.defineUserId(userIdUpdated);
154 assertTrue("userId is not updated",userIdUpdated.equals(ResourceGeneralPage.getContactIdText()));
158 public void addUpdateDeleteDeploymentArtifactToVFCTest() throws Exception {
159 String fileName = "importVFC_VFC6.yml";
160 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
161 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
162 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
164 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
166 List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
167 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
168 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
169 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
170 DeploymentArtifactPage.clickAddNewArtifact();
171 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true) );
173 assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
175 String newDescription = "new description";
176 DeploymentArtifactPage.updateDescription(newDescription, deploymentArtifactList.get(0));
177 String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
178 assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
180 DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
181 DeploymentArtifactPage.clickOK();
182 assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1));
184 assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed());
188 public void addUpdateDeletePlaceholdersInformationalArtefactVFCTest() throws Exception{
189 String fileName = "importVFC_VFC7.yml";
190 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
191 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
192 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
194 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
197 List<ArtifactInfo> informationalArtifactList = new ArrayList<ArtifactInfo>();
198 informationalArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
199 informationalArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuuuuku", "artifact3", "HEAT"));
200 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
201 InformationalArtifactPage.clickAddNewArtifact();
202 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
204 assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size()));
206 // update artifact description
207 String newDescription = "new description";
208 InformationalArtifactPage.clickEditArtifact(informationalArtifactList.get(0).getArtifactLabel());
209 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
210 InformationalArtifactPage.artifactPopup().clickDoneButton();
211 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifactList.get(0).getArtifactLabel());
212 assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
215 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
216 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
217 InformationalArtifactPage.clickOK();
220 assertTrue("not all artifacts is deleted", InformationalArtifactPage.checkElementsCountInTable(0));
223 for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){
224 ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath,"asc_heat 0 2.yaml", informArtifact.getValue());
226 InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length);
230 public void addSimplePropertiesToVFCTest() throws Exception{
231 String fileName = "importVFC_VFC8.yml";
232 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
233 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
234 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
236 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
237 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT);
238 int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
239 for (PropertyTypeEnum prop : propertyList){
240 PropertiesUIUtils.addNewProperty(prop);
242 assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
247 @Test(dataProvider = "assetFiles")
248 public void checkinCheckoutChangeDeleteVersionVFCTest(String customfileName) throws Exception{
249 setLog(customfileName);
250 // getExtendTest().setDescription(customfileName);
252 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
253 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
254 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customfileName, getUser());
256 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
257 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
258 GeneralPageElements.clickCheckoutButton();
259 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
261 GeneralPageElements.selectVersion("V0.1");
262 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN);
263 GeneralUIUtils.clickJSOnElementByText("latest version");
265 GeneralPageElements.clickTrashButtonAndConfirm();
266 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
267 String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText();
268 assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1"));
272 public void certificationVFCTest() throws Exception{
273 String fileName = "importVFC_VFC10.yml";
274 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
275 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
276 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
278 String vfName = atomicResourceMetaData.getName();
280 ResourceGeneralPage.clickCheckinButton(vfName);
281 GeneralUIUtils.findComponentAndClick(vfName);
282 ResourceGeneralPage.clickSubmitForTestingButton(vfName);
284 reloginWithNewRole(UserRoleEnum.TESTER);
285 GeneralUIUtils.findComponentAndClick(vfName);
286 TesterOperationPage.certifyComponent(vfName);
288 atomicResourceMetaData.setVersion("1.0");
289 VfVerificator.verifyVFLifecycle(atomicResourceMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
291 reloginWithNewRole(UserRoleEnum.DESIGNER);
292 GeneralUIUtils.findComponentAndClick(vfName);
293 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
297 public void activityLogVFCTest() throws Exception{
298 String fileName = "importVFC_VFC11.yml";
299 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
300 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
301 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
303 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
305 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
306 InformationalArtifactPage.clickAddNewArtifact();
307 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
309 ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen();
311 int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size();
312 assertTrue("Wrong rows number, should be 2", numberOfRows == 2);
316 public void removeFileFromGeneralPageVFCTest() throws Exception{
317 String fileName = "importVFC_VFC12.yml";
319 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
320 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
321 ResourceUIUtils.importVfcNoCreate(atomicResourceMetaData, filePath, fileName, getUser());
323 GeneralPageElements.clickDeleteFile();
326 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), 30);
335 public void maxLengthGeneralInformationVFCTest() throws Exception{
336 String fileName = "importVFC_VFC13.yml";
337 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
338 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
339 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
340 ResourceUIUtils.fillMaxValueResourceGeneralInformationPage(atomicResourceMetaData);
341 GeneralPageElements.clickUpdateButton();
342 VFCverificator.verifyVFCUpdatedInUI(atomicResourceMetaData);
343 GeneralPageElements.clickDeleteVersionButton();
349 protected UserRoleEnum getRole() {
350 return UserRoleEnum.DESIGNER;