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