2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.US;
23 import org.apache.commons.io.FileUtils;
24 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.*;
27 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
28 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
29 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
30 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
31 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
32 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
33 import org.openecomp.sdc.ci.tests.pages.UploadArtifactPopup;
34 import org.openecomp.sdc.ci.tests.utilities.*;
35 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
36 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
37 import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
38 import org.testng.Assert;
39 import org.testng.annotations.DataProvider;
40 import org.testng.annotations.Test;
43 import java.util.ArrayList;
44 import java.util.List;
46 import static org.testng.AssertJUnit.assertTrue;
49 public class MIBsArtifactsOnResourceInstance extends SetupCDTest {
51 private String folder ="";
53 @DataProvider(name="mibsArtifactCRUDUi")
54 public static Object[][] dataProviderMibsArtifactCRUDUi() {
55 return new Object[][] {
56 {"mibsvFW_VFC.yml", ResourceTypeEnum.VFC},
57 {"mibsVL.yml", ResourceTypeEnum.VL},
58 {"mibsCP.yml", ResourceTypeEnum.CP}
63 // Artifact UI CRUD on VFC/VL/CP
64 // TODO: Change download validation from download artifact via external API to UI
65 @Test(dataProvider="mibsArtifactCRUDUi")
66 public void mibsArtifactCRUDUi(String fileName, ResourceTypeEnum resourceTypeEnum) throws Exception {
68 String filePath = FileHandling.getFilePath(folder);
71 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser());
72 ResourceUIUtils.importVfc(resourceMetaData, filePath, fileName, getUser());
74 // get resourceUUID from BE
75 String resourceUUID = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1").getUUID();
77 // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL.
78 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
80 List<ArtifactInfo> deploymentArtifactList = new ArrayList<>();
81 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP"));
82 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL"));
83 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
84 DeploymentArtifactPage.clickAddNewArtifact();
85 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true));
87 assertTrue("Only created artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1));
89 String artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText();
90 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(deploymentArtifact.getArtifactLabel(), null, "1", deploymentArtifact.getArtifactType(), true, true, true, false);
92 // Verify that uploaded correct file by download artifact via external api
93 RestResponse restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE.toString());
94 File file = new File(deploymentArtifact.getFilepath() + deploymentArtifact.getFilename());
96 String readFileToString = FileUtils.readFileToString(file);
97 Assert.assertEquals(restResponse.getResponse(), readFileToString);
99 DeploymentArtifactPage.clickEditArtifact(deploymentArtifact.getArtifactLabel());
100 UploadArtifactPopup artifactPopup = new UploadArtifactPopup(true);
101 artifactPopup.loadFile(filePath, "CP.yml");
102 artifactPopup.clickDoneButton();
104 assertTrue("Only updated artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(1));
105 Assert.assertNotEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText(), artifactUUID);
106 ArtifactUIUtils.validateExistArtifactOnDeploymentInformationPage(deploymentArtifact.getArtifactLabel(), null, "2", deploymentArtifact.getArtifactType(), true, true, true, false);
108 // Verify that updated correct file by download artifact via external api
109 artifactUUID = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ArtifactPageEnum.UUID.getValue() + deploymentArtifact.getArtifactLabel()).getText();
110 restResponse = ArtifactRestUtils.getResourceDeploymentArtifactExternalAPI(resourceUUID, artifactUUID, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER), ComponentTypeEnum.RESOURCE.toString());
111 file = new File(deploymentArtifact.getFilepath() + "CP.yml");
112 readFileToString = FileUtils.readFileToString(file);
113 Assert.assertEquals(restResponse.getResponse(), readFileToString);
115 DeploymentArtifactPage.clickDeleteArtifact(deploymentArtifact.getArtifactLabel());
116 DeploymentArtifactPage.clickOK();
118 assertTrue("No artifact need to be exist", DeploymentArtifactPage.checkElementsCountInTable(0));
123 @DataProvider(name="mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption")
124 public static Object[][] dataProviderMibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption() {
125 return new Object[][] {
126 // {"mibs1vFW_VFC.yml", ResourceTypeEnum.VFC},
127 // TODO: delete comment below when we will have support for VL on canvas
128 // {"mibs1VL.yml", ResourceTypeEnum.VL},
129 {"mibs1CP.yml", ResourceTypeEnum.CP}
134 // Import VFC/VL/CP, upload MIBs artifacts then drag it on VF & verify that deployment artifact have only download option
135 @Test(dataProvider="mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption")
136 public void mibsArtifacsOnResourceInstanceShouldOnlyHaveDownloadOption(String fileName, ResourceTypeEnum resourceTypeEnum) throws Exception {
138 // if(resourceTypeEnum.equals(ResourceTypeEnum.CP)){
139 // throw new SkipException("Open bug 322930");
144 String filePath = FileHandling.getFilePath(folder);
147 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(resourceTypeEnum, getUser());
148 ResourceUIUtils.importVfc(resourceMetaData, filePath, fileName, getUser());
150 // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL.
151 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
153 List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
154 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP"));
155 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL"));
156 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
157 DeploymentArtifactPage.clickAddNewArtifact();
158 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true));
160 assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
162 // 3. Check-in DataProvider resource.
163 ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName());
166 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
167 ResourceUIUtils.createVF(vfMetaData, getUser());
169 // 5. Click on composition.
170 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
172 // 6. Drag created DataProvider resource to canvas.
173 CanvasManager vfCanvasManager = CanvasManager.getCanvasManager();
174 CompositionPage.searchForElement(resourceMetaData.getName());
175 CanvasElement resourceInstance = vfCanvasManager.createElementOnCanvas(resourceMetaData.getName());
177 // 7. Click on DataProvider resource.
178 vfCanvasManager.clickOnCanvaElement(resourceInstance);
180 // 8. Click on deployment artifacts in right menu.
181 CompositionPage.showDeploymentArtifactTab();
183 // 9. Verify that each uploaded MIBs artifacts shows in deployment artifacts.
184 // 10. Verify that only have download option.
185 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
186 // Hover over webelement -> check that only dowload button displayed
187 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel());
188 Assert.assertEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DOWNLOAD.getValue() + deploymentArtifact.getArtifactLabel()).isDisplayed(), true);
189 Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + deploymentArtifact.getArtifactLabel()), false);
190 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel());
191 Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPopup.MODAL_WINDOW.getValue()), false);
198 // Create VF, upload MIBs artifacts then drag it on service & verify that deployment artifact have only download option
200 public void mibsArtifacsOnVFInstanceShouldOnlyHaveDownloadOption() throws Exception {
201 String filePath = FileHandling.getFilePath(folder);
204 ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
205 ResourceUIUtils.createVF(resourceMetaData, getUser());
207 // 2. Upload MIBs artifacts - SNMP_TRAP & SNMP_POLL.
208 ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
210 List<ArtifactInfo> deploymentArtifactList = new ArrayList<ArtifactInfo>();
211 deploymentArtifactList.add(new ArtifactInfo(filePath, "asc_heat 0 2.yaml", "kuku", "artifact1", "SNMP_TRAP"));
212 deploymentArtifactList.add(new ArtifactInfo(filePath, "sample-xml-alldata-1-1.xml", "cuku", "artifact2", "SNMP_POLL"));
213 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
214 DeploymentArtifactPage.clickAddNewArtifact();
215 ArtifactUIUtils.fillAndAddNewArtifactParameters(deploymentArtifact, new UploadArtifactPopup(true));
217 assertTrue("artifact table does not contain artifacts uploaded", DeploymentArtifactPage.checkElementsCountInTable(deploymentArtifactList.size()));
220 ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName());
222 // 4. Create service.
223 ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
224 ServiceUIUtils.createService(serviceMetadata, getUser());
226 // 5. Click on composition.
227 ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
229 // 6. Drag created DataProvider s to canvas.
230 CanvasManager canvasManager = CanvasManager.getCanvasManager();
231 CompositionPage.searchForElement(resourceMetaData.getName());
232 CanvasElement resourceInstance = canvasManager.createElementOnCanvas(resourceMetaData.getName());
234 // 7. Click on DataProvider resource.
235 canvasManager.clickOnCanvaElement(resourceInstance);
237 // 8. Click on deployment artifacts in right menu.
238 CompositionPage.showDeploymentArtifactTab();
240 // 9. Verify that each uploaded MIBs artifacts shows in deployment artifacts.
241 // 10. Verify that only have download option.
242 for (ArtifactInfo deploymentArtifact : deploymentArtifactList) {
243 // Hover over webelement -> check that only dowload button displayed
244 GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel());
245 Assert.assertEquals(GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DOWNLOAD.getValue() + deploymentArtifact.getArtifactLabel()).isDisplayed(), true);
246 Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + deploymentArtifact.getArtifactLabel()), false);
247 GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_DISPLAY_NAME.getValue() + deploymentArtifact.getArtifactLabel());
248 Assert.assertEquals(GeneralUIUtils.isWebElementExistByTestId(DataTestIdEnum.ArtifactPopup.MODAL_WINDOW.getValue()), false);
255 protected UserRoleEnum getRole() {
256 return UserRoleEnum.DESIGNER;