re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / US / NewArtifactTypeGuide.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.US;
22
23 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
24 import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
25 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
27 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
28 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
29 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
30 import org.openecomp.sdc.ci.tests.pages.InformationalArtifactPage;
31 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
32 import org.openecomp.sdc.ci.tests.pages.UploadArtifactPopup;
33 import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
34 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
35 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
36 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
37 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
38 import org.testng.Assert;
39 import org.testng.annotations.Test;
40
41 import static org.testng.AssertJUnit.assertTrue;
42
43
44 public class NewArtifactTypeGuide extends SetupCDTest {
45         
46         private String folder ="";
47
48         // US820276
49         // Upload information artifact of type GUIDE to VF
50         @Test
51         public void crudGuideInformationArtifactForVf() throws Exception {
52                 String filePath = FileHandling.getFilePath(folder);
53
54                 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
55                 ResourceUIUtils.createVF(resourceMetaData, getUser());
56                         
57                 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
58                 
59                 ArtifactInfo informationArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "GUIDE");
60
61                 InformationalArtifactPage.clickAddNewArtifact();
62                 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationArtifact);
63                 
64                 assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1));
65                 
66                 String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText();
67                 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "1", informationArtifact.getArtifactType(), true, true, true, false);
68                 
69                 InformationalArtifactPage.clickEditArtifact(informationArtifact.getArtifactLabel());
70                 UploadArtifactPopup artifactPopup = new UploadArtifactPopup();
71                 artifactPopup.loadFile(filePath, "CP.yml");
72                 artifactPopup.clickDoneButton();
73                 
74                 assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1));
75                 Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(), artifactUUID);
76                 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "2", informationArtifact.getArtifactType(), true, true, true, false);
77                 
78                 InformationalArtifactPage.clickDeleteArtifact(informationArtifact.getArtifactLabel());
79                 InformationalArtifactPage.clickOK();
80         }
81         
82         // US820276
83         // Upload information artifact of type GUIDE to VFC
84         @Test
85         public void crudGuideInformationArtifactForVfc() throws Exception {
86                 String filePath = FileHandling.getFilePath(folder);
87
88                 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VFC, getUser());
89                 ResourceUIUtils.importVfc(resourceMetaData, filePath, "guidevFW_VFC.yml", getUser());
90                         
91                 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
92                 
93                 ArtifactInfo informationArtifact = new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "GUIDE");
94
95                 InformationalArtifactPage.clickAddNewArtifact();
96                 ArtifactUIUtils.fillAndAddNewArtifactParameters(informationArtifact);
97                 
98                 assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1));
99                 String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText();
100                 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "1", informationArtifact.getArtifactType(), true, true, true, false);
101                 
102                 InformationalArtifactPage.clickEditArtifact(informationArtifact.getArtifactLabel());
103                 UploadArtifactPopup artifactPopup = new UploadArtifactPopup();
104                 artifactPopup.loadFile(filePath, "CP.yml");
105                 artifactPopup.clickDoneButton();
106                 
107                 assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1));
108                 Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + informationArtifact.getArtifactLabel()).getText(), artifactUUID);
109                 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(informationArtifact.getArtifactLabel(), null, "2", informationArtifact.getArtifactType(), true, true, true, false);
110                 
111                 InformationalArtifactPage.clickDeleteArtifact(informationArtifact.getArtifactLabel());
112                 InformationalArtifactPage.clickOK();
113         }
114
115         
116
117         @Override
118         protected UserRoleEnum getRole() {
119                 return UserRoleEnum.DESIGNER;
120         }
121
122 }