re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / VfDeploymentInformationalArtifacts.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.execute.sanity;
22
23 import org.openecomp.sdc.be.dao.api.ActionStatus;
24 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
25 import org.openecomp.sdc.be.model.User;
26 import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
27 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.Dashboard;
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.CompositionPage;
33 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
34 import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
35 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
36 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
37 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
38 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
39 import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
40 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
41 import org.openqa.selenium.WebElement;
42 import org.testng.annotations.Test;
43
44 import java.util.ArrayList;
45 import java.util.List;
46
47 import static org.assertj.core.api.Assertions.assertThat;
48
49
50 public class VfDeploymentInformationalArtifacts extends SetupCDTest {
51         
52         
53         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
54         // START US824719
55         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
56         
57         // US824719 - Import VSP - VF informational artifacts
58         // TC1434241 - Import VF Artifacts - Deployment Artifacts - One Artifact, One Type
59         @Test
60         public void importVfArtifactsDeploymentArtifactsOneArtifactOneType() throws Exception {
61                 String fileName = "TC1434241.csar";
62                 String folder ="US825779";
63                 
64                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
65                 deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
66                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
67                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
68                 
69                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, null);
70         }
71         
72         // US824719 - Import VSP - VF informational artifacts
73         // TC1434245 - Import VF Artifacts - Deployment Artifacts - Multiple Artifacts, Multiple Types
74         @Test
75         public void importVfArtifactsDeploymentArtifactsMultipleArtifactsMultipleTypes() throws Exception {
76                 String fileName = "TC1434245.csar";
77                 String folder ="US825779";
78                 
79                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
80                 deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
81                 deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
82                 
83                 deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
84                 deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
85                 deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
86                 
87                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
88                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
89                 
90                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName,folder, deploymentArtifacts, null);
91         }
92         
93         // US824719 - Import VSP - VF informational artifacts
94         // TC1434247 - Import VF Artifacts - Informational Artifacts - One Artifact, One Type
95         @Test
96         public void importVfArtifactsInformationalArtifactsOneArtifactOneType() throws Exception {
97                 String fileName = "TC1434247.csar";
98                 String folder ="US825779";
99                 
100                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
101                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
102                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
103                 
104                 List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
105                 informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
106                 
107                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder, deploymentArtifacts, informationalArtifacts);
108         }
109         
110         // US824719 - Import VSP - VF informational artifacts
111         // TC1434248 -  Import VF Artifacts - Informational Artifacts - Multiple Artifacts, Multiple Types
112         @Test
113         public void importVfArtifactsInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception {
114                 String fileName = "TC1434248.csar";
115                 String folder ="US825779";
116                 
117                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
118                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
119                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
120                 
121                 List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
122                 informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
123                 informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
124                 informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
125                 
126                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName,  folder, deploymentArtifacts, informationalArtifacts);
127         }
128         
129         // US824719 - Import VSP - VF informational artifacts
130         // TC1434249 -  Import VF Artifacts - Deployment and Informational Artifacts - Multiple Artifacts, Multiple Types
131         @Test
132         public void importVfArtifactsDeploymentAndInformationalArtifactsMultipleArtifactsMultipleTypes() throws Exception {
133                 String fileName = "TC1434249.csar";
134                 String folder ="US825779";
135                 
136                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
137                 deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
138                 deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1"));
139                 deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
140                 deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
141                 deploymentArtifacts.add(new ArtifactInfo(null, "HeatVolArtifactName3.yaml", null, "HeatVolArtifactName3", ArtifactTypeEnum.HEAT_VOL.getType(), "1"));
142                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
143                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
144                 
145                 List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
146                 informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
147                 informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1"));
148                 informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1"));
149                 
150                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, informationalArtifacts);
151         }
152         
153         // TODO: there is defect in flow: "Updated button enabled for artifact in invalid type folder"
154         // TODO: re-check it after defect fix
155         // US824719 - Import VSP - VF informational artifacts
156         // TC1438310 - Import VF Artifacts - Deployment Artifacts - Artifact Type Invalid
157         @Test
158         public void importVFArtifactsDeploymentArtifactsArtifactTypeInvalid() throws Exception {
159                 String fileName = "DeploymentArtifactWithInvalidType.csar";
160                 String folder ="US825779";
161                 
162                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
163                 deploymentArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1"));
164                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
165                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
166                 
167                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, null);
168         }
169         
170         // US824719 - Import VSP - VF informational artifacts
171         // TC1438311 - Import VF Artifacts - Informational Artifacts - Artifact Type Invalid
172         @Test
173         public void importVfArtifactsInformationalArtifactsArtifactTypeInvalid() throws Exception {
174                 String fileName = "InformationArtifactWithInvalidType.csar";
175                 String folder ="US825779";
176                 
177                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
178                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
179                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
180                 
181                 List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
182                 informationalArtifacts.add(new ArtifactInfo(null, "ArtifactName.yaml", null, "ArtifactName", ArtifactTypeEnum.OTHER.getType(), "1"));
183                 
184                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, informationalArtifacts);
185         }
186         
187         // US824719 - Import VSP - VF informational artifacts
188         // TC1438231 -  Import VF Artifacts - Deployment Artifacts - Artifact Name To Long
189         @Test
190         public void importVfArtifactsDeploymentArtifactsArtifactNameToLong() throws Exception {         
191                 String folder = "US825779";
192                 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
193         
194                 String fileName = "DeploymentArtifactWithLongName.csar";
195                 
196                 importVfFromCsar(resourceMetaData, folder, fileName, getUser());        
197                 
198                 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
199         String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name());
200         assertThat(errorMessage).contains(checkUIResponseOnError);
201         }
202         
203         // US824719 - Import VSP - VF informational artifacts
204         // TC1438232 - Import VF Artifacts - Informational Artifacts - Artifact Name To Long
205         // TODO: make informational artifact name longer then 255
206         // TODO: windows/linux not allowed it
207         @Test(enabled=false)
208         public void importVfArtifactsInformationalArtifactsArtifactNameToLong() throws Exception {
209                 String folder ="US825779";
210                 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
211         
212                 String fileName = "InformationArtifactWithLongName.csar";
213                 
214                 importVfFromCsar(resourceMetaData, folder, fileName, getUser());        
215                 
216                 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
217             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name());
218                 assertThat(errorMessage).contains(checkUIResponseOnError);
219         }
220         
221         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
222         // END US824719
223         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
224         
225         
226         
227         
228         
229         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
230         // START US825779
231         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
232
233         // US825779 - Story: [BE] Import VSP - VF informational artifacts  - Update
234         // TC1443954 - Update With Multiple Changes In Deployment And Informational Artifacts
235         @Test
236         public void updateWithMultipleChangesInDeploymentAndInformationalArtifacts() throws Exception {
237                 String folder ="US825779";
238                 String fileName =  "ImportTC1443954.csar";
239                 
240                 ArtifactInfo deploymentHeat1 = new ArtifactInfo(null, "heatartifactname1.yaml", null, "heatartifactname1", ArtifactTypeEnum.HEAT.getType(), "1");
241                 ArtifactInfo deploymentHeat2 = new ArtifactInfo(null, "heatartifactname2.yaml", null, "heatartifactname2", ArtifactTypeEnum.HEAT.getType(), "1");
242                 ArtifactInfo deploymentHeat3 = new ArtifactInfo(null, "heatartifactname3.yaml", null, "heatartifactname3", ArtifactTypeEnum.HEAT.getType(), "1");
243                 
244                 ArtifactInfo deploymentHeatVol1 = new ArtifactInfo(null, "HeatVolArtifactName1.yaml", null, "HeatVolArtifactName1", ArtifactTypeEnum.HEAT_VOL.getType(), "1");
245                 ArtifactInfo deploymentHeatVol2 = new ArtifactInfo(null, "HeatVolArtifactName2.yaml", null, "HeatVolArtifactName2", ArtifactTypeEnum.HEAT_VOL.getType(), "1");
246                 
247                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
248                 deploymentArtifacts.add(deploymentHeat1);
249                 deploymentArtifacts.add(deploymentHeat2);
250                 deploymentArtifacts.add(deploymentHeat3);
251                 deploymentArtifacts.add(deploymentHeatVol1);
252                 deploymentArtifacts.add(deploymentHeatVol2);
253                 
254                 ArtifactInfo infoGuide1 = new ArtifactInfo(null, "GuideInfoArtifact1.yml", null, "GuideInfoArtifact1", ArtifactTypeEnum.GUIDE.getType(), "1");
255                 ArtifactInfo infoGuide2 = new ArtifactInfo(null, "GuideInfoArtifact2.yml", null, "GuideInfoArtifact2", ArtifactTypeEnum.GUIDE.getType(), "1");
256                 
257                 ArtifactInfo infoOther1 = new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1");
258                 ArtifactInfo infoOther2 = new ArtifactInfo(null, "artifactname2.txt", null, "artifactname2", ArtifactTypeEnum.OTHER.getType(), "1");
259                 ArtifactInfo infoOther3 = new ArtifactInfo(null, "artifactname3.txt", null, "artifactname3", ArtifactTypeEnum.OTHER.getType(), "1");
260                 
261                 List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
262                 informationalArtifacts.add(infoGuide1);
263                 informationalArtifacts.add(infoGuide2);
264                 informationalArtifacts.add(infoOther1);
265                 informationalArtifacts.add(infoOther2);
266                 informationalArtifacts.add(infoOther3);
267                         
268                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, informationalArtifacts);
269                 
270                 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
271                         
272                 fileName = "UpdateTC1443954.csar";
273                 
274                 List<ArtifactInfo> informationalArtifactsNotExist = new ArrayList<ArtifactInfo>();
275                 List<ArtifactInfo> deploymentArtifactsNotExist = new ArrayList<ArtifactInfo>();
276                 
277                 // Changes in deployment artifacts
278                 deploymentArtifactsNotExist.add(deploymentHeat1);
279                 deploymentArtifactsNotExist.add(deploymentHeat2);
280                 deploymentArtifacts.remove(deploymentHeat1);
281                 deploymentArtifacts.remove(deploymentHeat2);
282                 deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname4.yaml", null, "heatartifactname4", ArtifactTypeEnum.HEAT.getType(), "1"));
283                 deploymentArtifacts.add(new ArtifactInfo(null, "heatartifactname5.yaml", null, "heatartifactname5", ArtifactTypeEnum.HEAT.getType(), "1"));
284                 deploymentHeatVol1.setArtifactVersion("2");
285                 deploymentHeatVol2.setArtifactVersion("2");
286                 
287                 // Changes in informational artifacts
288                 infoGuide1.setArtifactVersion("2");
289                 infoOther1.setArtifactVersion("2");
290                 informationalArtifactsNotExist.add(infoGuide2);
291                 informationalArtifactsNotExist.add(infoOther2);
292                 informationalArtifacts.remove(infoGuide2);
293                 informationalArtifacts.remove(infoOther2);
294                 informationalArtifacts.add(new ArtifactInfo(null, "GuideInfoArtifact3.yml", null, "GuideInfoArtifact3", ArtifactTypeEnum.GUIDE.getType(), "1"));
295                 informationalArtifacts.add(new ArtifactInfo(null, "artifactname4.txt", null, "artifactname4", ArtifactTypeEnum.OTHER.getType(), "1"));
296                         
297                 updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, deploymentArtifacts, informationalArtifacts, deploymentArtifactsNotExist, informationalArtifactsNotExist);
298         }
299         
300         
301         // US825779 - Story: [BE] Import VSP - VF informational artifacts  - Update
302         // TC1444206 - Update With Existed Deployment Artifact By Artifact With Different Type
303         @Test
304         public void updateWithExistedDeploymentArtifactByArtifactWithDifferentType() throws Exception {
305                 String folder ="US825779";
306                 String fileName =  "ImportTC1444206.csar";
307                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
308                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
309                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));                     
310                 deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
311                         
312                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, null);
313                 
314                 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
315                         
316                 fileName = "UpdateTC1444206.csar";
317                 String filePath = FileHandling.getFilePath(folder); ;
318                         
319                 ResourceUIUtils.updateVfWithCsar(filePath, fileName);
320                 
321                 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
322             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name());
323                 assertThat(errorMessage).contains(checkUIResponseOnError);
324         }
325         
326         // US825779 - Story: [BE] Import VSP - VF informational artifacts  - Update
327         // TC1444207 - Update With Existed Informational Artifact By Artifact With Different Type
328         @Test
329         public void updateWithExistedInformationalArtifactByArtifactWithDifferentType() throws Exception {
330                 String folder ="US825779";
331                 String fileName =  "ImportTC1444207.csar";
332                         
333                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
334                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
335                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));             
336                 
337                 List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
338                 informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
339                         
340                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, informationalArtifacts);
341                 
342                 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
343                 
344                 fileName = "UpdateTC1444207.csar";
345                 String filePath = FileHandling.getFilePath(folder);
346                         
347                 ResourceUIUtils.updateVfWithCsar(filePath, fileName);
348                 
349                 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
350             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name());
351                 assertThat(errorMessage).contains(checkUIResponseOnError);
352         }
353         
354         
355         // US825779 - Story: [BE] Import VSP - VF informational artifacts  - Update
356         // TC1444208 - Update With Existed Informational Artifact By Deployment Artifact With Different Type
357         @Test
358         public void updateWithExistedInformationalArtifactByDeploymentArtifactWithDifferentType() throws Exception {            
359                 String folder ="US825779";
360                 String fileName =  "ImportTC1444208.csar";
361                         
362                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
363                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
364                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));             
365                 deploymentArtifacts.add(new ArtifactInfo(null, "artifactname1.yaml", null, "artifactname1", ArtifactTypeEnum.HEAT.getType(), "1"));
366                         
367                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, null);
368                 
369                 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
370                 
371                 fileName = "UpdateTC1444208.csar";
372                 String filePath = FileHandling.getFilePath(folder); ;
373                                 
374                 ResourceUIUtils.updateVfWithCsar(filePath, fileName);
375                 
376                 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
377             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.ARTIFACT_EXIST.name());
378             assertThat(errorMessage).contains(checkUIResponseOnError);
379         }
380         
381         // US825779 - Story: [BE] Import VSP - VF informational artifacts  - Update
382         // TC1444520 - Update Deployment Artifact With Name To Long
383         @Test
384         public void updateDeploymentArtifactWithNameToLong() throws Exception {
385                 String folder ="US825779";
386                 
387                 String fileName =  "ImportTC1444520.csar";
388                         
389                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  null, null);
390                 
391                 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
392                 
393                 fileName = "UpdateTC1444520.csar";
394                 String filePath = FileHandling.getFilePath(folder); ;
395                                 
396                 ResourceUIUtils.updateVfWithCsar(filePath, fileName);
397                 
398                 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
399             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name());
400             assertThat(errorMessage).contains(checkUIResponseOnError);
401         }
402         
403         // US825779 - Story: [BE] Import VSP - VF informational artifacts  - Update
404         // TC1444521 - Update Informational Artifact With Name To Long
405         @Test
406         public void updateInformationalArtifactWithNameToLong() throws Exception {
407                 
408                 String folder = "US825779";
409                 String fileName =  "ImportTC1444521.csar";
410                         
411                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  null, null);
412                 
413                 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
414                 
415                 fileName = "UpdateTC1444521.csar";
416                 String filePath = FileHandling.getFilePath(folder); ;
417                                 
418                 ResourceUIUtils.updateVfWithCsar(filePath, fileName);
419                 
420                 String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
421             String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.EXCEEDS_LIMIT.name());
422             assertThat(errorMessage).contains(checkUIResponseOnError);
423         }
424
425         // US825779 - Story: [BE] Import VSP - VF informational artifacts  - Update
426         // TC1444531 - Update Informational Artifact With Invalid Type
427         @Test
428         public void updateInformationalArtifactWithInvalidType() throws Exception {             
429                 String folder ="US825779";
430                 String fileName =  "ImportTC1444531.csar";
431                 
432                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  null, null);
433                 
434                 GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
435                 
436                 fileName = "UpdateTC1444531.csar";
437                 
438                 List<ArtifactInfo> informationalArtifacts = new ArrayList<ArtifactInfo>();
439                 informationalArtifacts.add(new ArtifactInfo(null, "artifactname1.xml", null, "artifactname1", ArtifactTypeEnum.OTHER.getType(), "1"));
440                 
441                 updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, fileName, null, informationalArtifacts, null, null);
442         }
443         
444         
445         @Test
446         public void importValidInformationalArtifactInInvalidFolerTest_TC1438313() throws Exception{
447                 String fileName =  "ValidArtifactNameInInvalidFolder.csar";
448                 String folder = "US824719";
449                 
450                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
451                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "1"));
452                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));                     
453                 
454                 importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(fileName, folder,  deploymentArtifacts, null);
455         }
456         
457         @Test
458         public void updateValidInformationalArtifactInInvalidFolerTest_TC1444533() throws Exception{
459                 String fileName =  "ImportTC1444533.csar";
460                 String folder = "US824719";
461                 String filePath = FileHandling.getFilePath(folder);
462                 
463                 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
464                 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser());
465                 
466                 String updatedCsarFileName = "UpdateTC1444533.csar";
467                 
468                 List<ArtifactInfo> deploymentArtifacts = new ArrayList<ArtifactInfo>();
469                 deploymentArtifacts.add(new ArtifactInfo(null, "base_ldsa.yaml", null, "base_ldsa", ArtifactTypeEnum.HEAT.getType(), "2"));
470                 deploymentArtifacts.add(new ArtifactInfo(null, "module_1_ldsa.yaml", null, "module_1_ldsa", ArtifactTypeEnum.HEAT.getType(), "4"));                     
471                 
472                 updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(folder, updatedCsarFileName, deploymentArtifacts, null, null, null);
473         }
474         
475         
476         
477         
478         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
479         // END US825779
480         //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
481         
482         
483         
484         public void updateVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(String folder, String fileName,
485                         List<ArtifactInfo> deploymentArtifacts, List<ArtifactInfo> informationalArtifacts,
486                         List<ArtifactInfo> deploymentArtifactsNotExist, List<ArtifactInfo> informationalArtifactsNotExist) throws Exception {
487                 String filePath = FileHandling.getFilePath(folder);
488                 ResourceUIUtils.updateVfWithCsar(filePath, fileName);
489                 
490                 validateDeploymentArtifactPage(deploymentArtifacts, null);
491                 validateInformationalArtifactPage(informationalArtifacts, null);
492                 
493                 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
494                 
495                 validateDeploymentArtifactInComposition(deploymentArtifacts, null);
496                 validateInformationalArtifactInComposition(informationalArtifacts, null);
497                 
498         }
499         
500
501         public void importVfFromCsar(ResourceReqDetails resourceMetaData, String folder, String fileName, User user) {
502                 String filePath = FileHandling.getFilePath(folder);
503                 GeneralUIUtils.hoverOnAreaByTestId(Dashboard.IMPORT_AREA.getValue());
504                 // Insert file to the browse dialog
505                 WebElement browseWebElement = GeneralUIUtils.getInputElement(DataTestIdEnum.Dashboard.IMPORT_VF_FILE.getValue());
506                 browseWebElement.sendKeys(filePath + fileName);
507
508                 // Fill the general page fields.
509                 GeneralUIUtils.waitForLoader();
510                 ResourceUIUtils.fillResourceGeneralInformationPage(resourceMetaData, getUser(), true);
511                 GeneralUIUtils.clickOnAreaJS(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue());
512         }
513
514         
515         
516         
517         public void importVfAndValidateInformationalDeploymentArtifactPagesOnPagesAndComposition(String fileName, String folder, List<ArtifactInfo> deploymentArtifacts, List<ArtifactInfo> informationalArtifacts) throws Exception {
518                 String filePath = FileHandling.getFilePath(folder);
519                 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
520                 ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser());
521                 
522                 validateDeploymentArtifactPage(deploymentArtifacts, null);
523                 validateInformationalArtifactPage(informationalArtifacts, null);
524                 
525                 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
526                 
527                 validateDeploymentArtifactInComposition(deploymentArtifacts, null);
528                 validateInformationalArtifactInComposition(informationalArtifacts, null);
529         }
530         
531         public void validateInformationalArtifactInComposition(List<ArtifactInfo> informationalArtifacts, List<ArtifactInfo> informationalArtifactsNotExist) throws Exception {
532                 CompositionPage.showInformationArtifactTab();
533                 // Composition informational
534                 if(informationalArtifacts != null && informationalArtifacts.size() > 0) {
535                         validateEachArtifactOnCompositionRightMenuInformationPage(informationalArtifacts);
536                 }
537                 if(informationalArtifactsNotExist != null && informationalArtifactsNotExist.size() > 0) {
538                         validateEachArtifactNotExistOnCompositionRightMenuInformationPage(informationalArtifactsNotExist);
539                 }
540         }
541         
542         public void validateDeploymentArtifactInComposition(List<ArtifactInfo> deploymentArtifacts, List<ArtifactInfo> deploymentArtifactsNotExist) throws Exception {
543                 CompositionPage.showDeploymentArtifactTab();
544                 // Composition deployment
545                 if(deploymentArtifacts != null && deploymentArtifacts.size() > 0) {
546                         validateEachArtifactOnCompositionRightMenuDeploymentPage(deploymentArtifacts);
547                 }
548                 if(deploymentArtifactsNotExist != null && deploymentArtifactsNotExist.size() > 0) {
549                         validateEachArtifactNotExistOnCompositionRightMenuDeploymentPage(deploymentArtifactsNotExist);
550                 }
551         }
552         
553         public void validateInformationalArtifactPage(List<ArtifactInfo> informationalArtifacts, List<ArtifactInfo> informationalArtifactsNotExist) {
554                 ResourceGeneralPage.getLeftMenu().moveToInformationalArtifactScreen();
555                 // Informational page
556                 if(informationalArtifacts != null && informationalArtifacts.size() > 0) {       
557                         validateEachArtifactInformationPage(informationalArtifacts);
558                 }
559                 if(informationalArtifactsNotExist != null && informationalArtifactsNotExist.size() > 0) {       
560                         validateEachArtifactNotExistInformationPage(informationalArtifactsNotExist);
561                 }
562         }
563         
564         public void validateDeploymentArtifactPage(List<ArtifactInfo> deploymentArtifacts, List<ArtifactInfo> deploymentArtifactsNotExist) {
565                 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
566                 // Deployment page
567                 if(deploymentArtifacts != null && deploymentArtifacts.size() > 0) {
568                         validateEachArtifactOnDeploymentPage(deploymentArtifacts);
569                 }
570                 if(deploymentArtifactsNotExist != null && deploymentArtifactsNotExist.size() > 0) {
571                         validateEachArtifactNotExistOnDeploymentPage(deploymentArtifactsNotExist);
572                 }
573         }
574         
575         // TODO: add validation that if not editable / deleteable then button should not appear
576         public void validateEachArtifactOnDeploymentPage(List<ArtifactInfo> artifactInfoList) {
577                 for(ArtifactInfo artifact: artifactInfoList) {
578                         String type = artifact.getArtifactType();
579                         String label = artifact.getArtifactLabel();
580                         String version = artifact.getArtifactVersion();
581                         
582                         if (type.equals(ArtifactTypeEnum.HEAT.getType()) || type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) || type.equals(ArtifactTypeEnum.HEAT_NET.getType())){
583                                 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(label, null, version, type, true, false, false, true);
584                         }
585                         else{
586                                 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(label, null, version, type, true, true, true, false);
587                         }
588                 }
589         }
590         
591         public void validateEachArtifactNotExistOnDeploymentPage(List<ArtifactInfo> artifactInfoList) {
592                 for(ArtifactInfo artifact: artifactInfoList) {
593                         ArtifactUIUtils.validateNotExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel());
594                 }
595         }
596         
597         public void validateEachArtifactInformationPage(List<ArtifactInfo> artifactInfoList) {
598                 for(ArtifactInfo artifact: artifactInfoList) {
599                         ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel(), null, artifact.getArtifactVersion(), artifact.getArtifactType(), true, true, true, false);
600                 }
601         }
602         
603         public void validateEachArtifactNotExistInformationPage(List<ArtifactInfo> artifactInfoList) {
604                 for(ArtifactInfo artifact: artifactInfoList) {
605                         ArtifactUIUtils.validateNotExistArtifactOnDeploymentInformationPage(artifact.getArtifactLabel());
606                 }
607         }
608         
609         public void validateEachArtifactOnCompositionRightMenuDeploymentPage(List<ArtifactInfo> artifactInfoList) {
610                 for(ArtifactInfo artifact: artifactInfoList) {
611                         
612                         String type = artifact.getArtifactType();
613                         String label = artifact.getArtifactLabel();
614                         String filename = artifact.getFilename();
615                         
616                         if (type.equals(ArtifactTypeEnum.HEAT.getType()) || type.equals(ArtifactTypeEnum.HEAT_VOL.getType()) || type.equals(ArtifactTypeEnum.HEAT_NET.getType())){
617                                 ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(filename, label, false, true, true, false);
618                         }
619                         else{
620                                 ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(filename, label, true, false, true, true);
621                         }
622                 }
623         }
624         
625         public void validateEachArtifactNotExistOnCompositionRightMenuDeploymentPage(List<ArtifactInfo> artifactInfoList) {
626                 for(ArtifactInfo artifact: artifactInfoList) {
627                         ArtifactUIUtils.validateNotExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getArtifactLabel());
628                 }
629         }
630         
631         // TODO: there is defect in this flow
632         // TODO: change isEditable to false when defect fix
633         public void validateEachArtifactOnCompositionRightMenuInformationPage(List<ArtifactInfo> artifactInfoList) {
634                 for(ArtifactInfo artifact: artifactInfoList) {
635                         ArtifactUIUtils.validateExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getFilename(), artifact.getArtifactLabel(), true, false, true, true);
636                 }
637         }
638         
639         public void validateEachArtifactNotExistOnCompositionRightMenuInformationPage(List<ArtifactInfo> artifactInfoList) {
640                 for(ArtifactInfo artifact: artifactInfoList) {
641                         ArtifactUIUtils.validateNotExistArtifactOnCompositionRightMenuDeploymentInformationPage(artifact.getArtifactLabel());
642                 }
643         }
644
645
646
647         @Override
648         protected UserRoleEnum getRole() {
649                 return UserRoleEnum.DESIGNER;
650         }
651
652 }