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