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;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
29 import org.openecomp.sdc.be.dao.api.ActionStatus;
30 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
31 import org.openecomp.sdc.be.model.LifecycleStateEnum;
32 import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
33 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
34 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.InformationalArtifactsPlaceholders;
35 import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
36 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
37 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
38 import org.openecomp.sdc.ci.tests.datatypes.enums.PropertyTypeEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
41 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
42 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
43 import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
44 import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage;
45 import org.openecomp.sdc.ci.tests.pages.PropertiesPage;
46 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
47 import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
48 import org.openecomp.sdc.ci.tests.pages.UploadArtifactPopup;
49 import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
50 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
51 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
52 import org.openecomp.sdc.ci.tests.utilities.PropertiesUIUtils;
53 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
54 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
55 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
56 import org.openecomp.sdc.ci.tests.verificator.PropertyVerificator;
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.DataProvider;
63 import org.testng.annotations.Test;
65 public class ImportVFCAsset extends SetupCDTest {
67 private ResourceReqDetails atomicResourceMetaData;
69 private String filePath;
71 public void beforeClass(){
72 filePath = FileHandling.getFilePath("");
75 @DataProvider(name = "assetFiles", parallel = false)
76 public Object[][] createDataX() {
77 return new Object[][] { { "importVFC_VFC9.yml" }, { "CP.yml" }, {"VL.yml"} };
81 public void importVFCTest() throws Exception {
82 String fileName = "importVFC_VFC1.yml";
83 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
84 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
85 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
89 public void importDuplicateVFCTest() throws Exception {
90 String fileName = "importVFC_VFC2.yml";
91 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
92 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
93 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
94 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
96 ResourceReqDetails atomicResourceMetaDataDup = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
97 ResourceCategoryEnum.NETWORK_L2_3_INFRASTRUCTURE, getUser());
99 ResourceUIUtils.importVfc(atomicResourceMetaDataDup, filePath, fileName, getUser());
103 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
104 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.RESOURCE_ALREADY_EXISTS.name());
105 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
110 public void badFileVFCTest() throws Exception {
111 String fileName = "importVFC_VFC3.yml";
112 String customFileName = "Heat-File 1.yaml";
114 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
115 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
117 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customFileName, getUser());
121 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
122 String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.INVALID_TOSCA_TEMPLATE.name());
123 Assert.assertTrue(errorMessage.contains(checkUIResponseOnError));
128 public void validContactAfterCreateVFCTest() throws Exception{
129 String fileName = "importVFC_VFC4.yml";
130 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
131 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
132 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
134 assertTrue("wrong userId", atomicResourceMetaData.getContactId().equals(ResourceGeneralPage.getContactIdText()));
138 public void validContactAfterUpdateVFCTest() throws Exception{
139 String fileName = "importVFC_VFC5.yml";
140 String userIdUpdated = "up1234";
142 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
143 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
145 ResourceUIUtils.defineUserId(userIdUpdated);
146 assertTrue("userId is not updated",userIdUpdated.equals(ResourceGeneralPage.getContactIdText()));
150 public void addUpdateDeleteDeploymentArtifactToVFCTest() throws Exception {
151 String fileName = "importVFC_VFC6.yml";
152 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
153 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
154 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
156 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
158 List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
159 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
160 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "YANG_XML"));
161 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
162 DeploymentArtifactPage.clickAddNewArtifact();
163 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true) );
165 assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
167 String newDescription = "new description";
168 DeploymentArtifactPage.updateDescription(newDescription, deploymentArtifactList.get(0));
169 String actualArtifactDescription = DeploymentArtifactPage.getArtifactDescription(deploymentArtifactList.get(0).getArtifactLabel());
170 assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
172 DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifactList.get(0).getArtifactLabel());
173 DeploymentArtifactPage.clickOK();
174 assertTrue("artifact "+ deploymentArtifactList.get(0).getArtifactLabel() + "is not deleted", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size() - 1));
176 assertTrue("artifact "+ deploymentArtifactList.get(1).getArtifactLabel() + "is not displayed", DeploymentArtifactPage.clickOnArtifactDescription(deploymentArtifactList.get(1).getArtifactLabel()).isDisplayed());
180 public void addUpdateDeletePlaceholdersInformationalArtefactVFCTest() throws Exception{
181 String fileName = "importVFC_VFC7.yml";
182 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
183 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
184 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
186 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
189 List<ArtifactInfo> informationalArtifactList = new ArrayList<ArtifactInfo>();
190 informationalArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER"));
191 informationalArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuuuuku", "artifact3", "HEAT"));
192 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
193 InformationalArtifactPage.clickAddNewArtifact();
194 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
196 assertTrue("artifact table does not contain artifacts uploaded", InformationalArtifactPage.checkElementsCountInTable(informationalArtifactList.size()));
198 // update artifact description
199 String newDescription = "new description";
200 InformationalArtifactPage.clickEditArtifact(informationalArtifactList.get(0).getArtifactLabel());
201 InformationalArtifactPage.artifactPopup().insertDescription(newDescription);
202 InformationalArtifactPage.artifactPopup().clickDoneButton();
203 String actualArtifactDescription = InformationalArtifactPage.getArtifactDescription(informationalArtifactList.get(0).getArtifactLabel());
204 assertTrue("artifact description is not updated", newDescription.equals(actualArtifactDescription));
207 for (ArtifactInfo informationalArtifact : informationalArtifactList) {
208 InformationalArtifactPage.clickDeleteArtifact(informationalArtifact.getArtifactLabel());
209 InformationalArtifactPage.clickOK();
212 assertTrue("not all artifacts is deleted", InformationalArtifactPage.checkElementsCountInTable(0));
215 for(InformationalArtifactsPlaceholders informArtifact : InformationalArtifactsPlaceholders.values()){
216 ArtifactUIUtils.fillPlaceHolderInformationalArtifact(informArtifact, filePath,"asc_heat 0 2.yaml", informArtifact.getValue());
218 InformationalArtifactPage.checkElementsCountInTable(InformationalArtifactsPlaceholders.values().length);
222 public void addSimplePropertiesToVFCTest() throws Exception{
223 String fileName = "importVFC_VFC8.yml";
224 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
225 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
226 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
228 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
229 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT);
230 int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
231 for (PropertyTypeEnum prop : propertyList){
232 PropertiesUIUtils.addNewProperty(prop);
234 assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
239 public void updateAfterCheckoutNewSimplePropertiesVFCTest() throws Exception{
240 String fileName = "importVFC_VFC16.yml";
241 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
242 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
243 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
245 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
246 List<PropertyTypeEnum> propertyList = Arrays.asList(PropertyTypeEnum.STRING, PropertyTypeEnum.INTEGER, PropertyTypeEnum.FLOAT);
247 int propertiesCount = PropertiesPage.getElemenetsFromTable().size();
248 for (PropertyTypeEnum prop : propertyList){
249 PropertiesUIUtils.addNewProperty(prop);
251 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
252 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
253 GeneralPageElements.clickCheckoutButton();
254 ResourceGeneralPage.getLeftMenu().moveToPropertiesScreen();
256 for (PropertyTypeEnum prop : propertyList){
257 PropertiesUIUtils.updateProperty(prop);
259 assertTrue(GeneralUIUtils.checkElementsCountInTable(propertiesCount + propertyList.size(), () -> PropertiesPage.getElemenetsFromTable()));
261 for (PropertyTypeEnum prop : propertyList){
262 PropertiesPage.clickOnProperty(prop.getName());
263 PropertyVerificator.validateEditVFCPropertiesPopoverFields(prop);
264 PropertiesPage.getPropertyPopup().clickCancel();
270 @Test(dataProvider = "assetFiles")
271 public void checkinCheckoutChangeDeleteVersionVFCTest(String customfileName) throws Exception{
272 setLog(customfileName);
273 // getExtendTest().setDescription(customfileName);
275 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
276 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
277 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, customfileName, getUser());
279 ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
280 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
281 GeneralPageElements.clickCheckoutButton();
282 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
284 GeneralPageElements.selectVersion("V0.1");
285 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKIN);
286 GeneralUIUtils.clickJSOnElementByText("latest version");
288 GeneralPageElements.clickTrashButtonAndConfirm();
289 GeneralUIUtils.findComponentAndClick(atomicResourceMetaData.getName());
290 String actualVersion = GeneralUIUtils.getSelectedElementFromDropDown(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue()).getText();
291 assertTrue("Expected version: V0.1, Actual version: " + actualVersion, actualVersion.equals("V0.1"));
295 public void certificationVFCTest() throws Exception{
296 String fileName = "importVFC_VFC10.yml";
297 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
298 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
299 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
301 String vfName = atomicResourceMetaData.getName();
303 ResourceGeneralPage.clickCheckinButton(vfName);
304 GeneralUIUtils.findComponentAndClick(vfName);
305 ResourceGeneralPage.clickSubmitForTestingButton(vfName);
307 reloginWithNewRole(UserRoleEnum.TESTER);
308 GeneralUIUtils.findComponentAndClick(vfName);
309 TesterOperationPage.certifyComponent(vfName);
311 atomicResourceMetaData.setVersion("1.0");
312 VfVerificator.verifyVFLifecycle(atomicResourceMetaData, getUser(), LifecycleStateEnum.CERTIFIED);
314 reloginWithNewRole(UserRoleEnum.DESIGNER);
315 GeneralUIUtils.findComponentAndClick(vfName);
316 VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CERTIFIED);
320 public void activityLogVFCTest() throws Exception{
321 String fileName = "importVFC_VFC11.yml";
322 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
323 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
324 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
326 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
328 ArtifactInfo informationalArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "OTHER");
329 InformationalArtifactPage.clickAddNewArtifact();
330 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationalArtifact);
332 ResourceGeneralPage.getLeftMenu().moveToActivityLogScreen();
334 int numberOfRows = GeneralUIUtils.getElementsByCSS("div[class^='flex-container']").size();
335 assertTrue("Wrong rows number, should be 2", numberOfRows == 2);
339 public void removeFileFromGeneralPageVFCTest() throws Exception{
340 String fileName = "importVFC_VFC12.yml";
342 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
343 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
344 ResourceUIUtils.importVfcNoCreate(atomicResourceMetaData, filePath, fileName, getUser());
346 GeneralPageElements.clickDeleteFile();
349 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue(), 30);
358 public void maxLengthGeneralInformationVFCTest() throws Exception{
359 String fileName = "importVFC_VFC13.yml";
360 atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC, NormativeTypesEnum.ROOT,
361 ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
362 ResourceUIUtils.importVfc(atomicResourceMetaData, filePath, fileName, getUser());
363 ResourceUIUtils.fillMaxValueResourceGeneralInformationPage(atomicResourceMetaData);
364 // GeneralPageElements.clickUpdateButton();
365 // VFCverificator.verifyVFCUpdatedInUI(atomicResourceMetaData);
366 // GeneralPageElements.clickDeleteVersionButton();
367 // Validate that button disabled
368 assertTrue(GeneralUIUtils.checkForDisabledAttribute(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue()));
374 protected UserRoleEnum getRole() {
375 return UserRoleEnum.DESIGNER;