eae7807c9fb73bcc115f8a05cac22696b65b2de7
[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.AmdocsComplexService;
22
23 import com.aventstack.extentreports.Status;
24 import com.clearspring.analytics.util.Pair;
25 import org.onap.sdc.backend.ci.tests.datatypes.enums.CircleSize;
26 import org.onap.sdc.frontend.ci.tests.pages.CompositionPage;
27 import org.onap.sdc.frontend.ci.tests.pages.DeploymentArtifactPage;
28 import org.onap.sdc.frontend.ci.tests.pages.ServiceGeneralPage;
29 import org.onap.sdc.frontend.ci.tests.pages.TesterOperationPage;
30 import org.onap.sdc.frontend.ci.tests.utilities.FileHandling;
31 import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
32 import org.onap.sdc.frontend.ci.tests.utilities.OnboardingUiUtils;
33 import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory;
34 import org.onap.sdc.frontend.ci.tests.datatypes.CanvasElement;
35 import org.onap.sdc.frontend.ci.tests.datatypes.CanvasManager;
36 import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum;
37 import org.onap.sdc.backend.ci.tests.datatypes.ResourceReqDetails;
38 import org.onap.sdc.backend.ci.tests.datatypes.ServiceReqDetails;
39 import org.onap.sdc.backend.ci.tests.datatypes.VendorSoftwareProductObject;
40 import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum;
41 import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
42 import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
43 import org.onap.sdc.frontend.ci.tests.pages.GovernorOperationPage;
44 import org.onap.sdc.frontend.ci.tests.pages.ResourceGeneralPage;
45 import org.testng.annotations.BeforeMethod;
46 import org.testng.annotations.Optional;
47 import org.testng.annotations.Parameters;
48 import org.testng.annotations.Test;
49
50 import java.util.ArrayList;
51 import java.util.List;
52
53
54 public class CreatePath extends SetupCDTest {
55
56     protected static String filePath = FileHandling.getFilePath("ComplexService");
57     private static String fullCompositionFile = "fullComposition.zip";
58     private static String fullCompositionFile2 = "fullCompositionNew.zip";
59     private static String HSSFile = "HSS.zip";
60     private static String VMMEFile = "VMME.zip";
61     private static String makeDistributionValue;
62
63     @Parameters({"makeDistribution"})
64     @BeforeMethod
65     public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) {
66         makeDistributionValue = makeDistributionReadValue;
67     }
68
69     //------------------------------------------Tests-----------------------------------------------------
70
71
72     // Test#1 Jira issue 5610
73     @Test
74     public void AssertPathButtons() throws Exception {
75         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
76         getToPathFlow(resourceReqDetails, filePath, fullCompositionFile);
77         reloginWithNewRole(UserRoleEnum.DESIGNER);
78         PathUtilities.createService(getUser());
79         PathUtilities.openCreatePath();
80         PathValidations.AssertCreatePath();
81         PathValidations.AssertExtendPath();
82     }
83
84     // Test#2 Jira issue 5441
85     @Test
86     public void CreatePathTestSanity() throws Exception {
87         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
88         Pair<String, ServiceReqDetails> pair = getToPathFlow(resourceReqDetails, filePath, fullCompositionFile);
89         String vspName = pair.left;
90         String serviceName = pair.right.getName();
91         String pathName = "Test1";
92         PathUtilities.createPath(pathName, vspName);
93         PathValidations.validateServicePath(serviceName, pathName);
94     }
95
96     // Test#3 Jira issue 5611
97     @Test
98     public void CreatePathCheckIO() throws Exception {
99         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
100         String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile);
101         reloginWithNewRole(UserRoleEnum.DESIGNER);
102         String serviceName = PathUtilities.createService(getUser()).getName();
103         String pathName = PathUtilities.createPath("Test3", vspName);
104
105         // @@ check in @@
106         ResourceGeneralPage.clickCheckinButton(serviceName);
107         GeneralUIUtils.findComponentAndClick(serviceName);
108         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
109         PathValidations.AssertCreatedPathExistInCompositionPage(pathName);
110
111         // @@ check out @@
112         ResourceGeneralPage.clickCheckoutButton();
113         PathValidations.AssertCreatedPathExistInCompositionPage(pathName);
114     }
115
116     // Test#4 Jira issue 5441
117     @Test
118     public void CreateMultiplePaths() throws Exception {
119         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
120         Pair<String, ServiceReqDetails> pair = getToPathFlow(resourceReqDetails, filePath, HSSFile);
121         String vspName = pair.left;
122         PathUtilities.createPath("Test4_path1", vspName);
123         PathUtilities.createPath("Test4_path2", vspName);
124         PathValidations.createPathNumOfRows(7);
125         PathValidations.createPathNumOfRows(6);
126         SetupCDTest.getExtendTest().log(Status.INFO, "multiple paths have been created");
127     }
128
129     // Test#5 Jira issue 5506
130     @Test
131     public void CreatePathWithComplex() throws Exception {
132         List<String> vnfFiles = new ArrayList<>();
133         vnfFiles.add(HSSFile);
134         vnfFiles.add(VMMEFile);
135         Pair<String, String> complex = CreatePathComplexServiceFlow(filePath, vnfFiles);
136         String serviceName = complex.left;
137         String pathName = complex.right;
138         PathValidations.validateServicePath(serviceName, pathName);
139         SetupCDTest.getExtendTest().log(Status.INFO, "path with complex service has been created");
140     }
141
142     // Test#6 Jira issue 5506
143     @Test
144     public void CreateExtendedPathWithComplex() throws Exception {
145         List<String> vnfFiles = new ArrayList<>();
146         vnfFiles.add(fullCompositionFile);
147         vnfFiles.add(fullCompositionFile2);
148         String[] services = getToComplexService(filePath, vnfFiles);
149         PathValidations.validateComplexExtendedPath(services);
150         SetupCDTest.getExtendTest().log(Status.INFO, "path with complex service has been created");
151     }
152
153     // Test#7 Jira issue 5441
154     @Test
155     public void CreatePathExtendedTest() throws Exception {
156         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
157         runCreateExtendedPathFlow(resourceReqDetails, filePath, fullCompositionFile);
158     }
159
160     ////////////////////////////////////////////////////////////////////////////////////////
161     //                               flow methods                                         //
162     ////////////////////////////////////////////////////////////////////////////////////////
163
164     // workflow leading to path
165     public String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception {
166         VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
167         String vspName = vendorSoftwareProductObject.getName();
168
169         DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
170         ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile, "The topology template for " + vnfFile + " is as follows : ");
171
172         DeploymentArtifactPage.clickSubmitForTestingButton(vspName);
173         SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER");
174         reloginWithNewRole(UserRoleEnum.TESTER);
175         GeneralUIUtils.findComponentAndClick(vspName);
176         TesterOperationPage.certifyComponent(vspName);
177         return vspName;
178     }
179
180     public List<String> onboardAndCertifyMultipleVFs(String filePath, List<String> vnfFiles) throws Exception {
181         List<String> VFNames = new ArrayList<>();
182         for (int i = 0; i < vnfFiles.size(); i++) {
183             ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
184             VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFiles.get(i), getUser());
185             VFNames.add(i, vendorSoftwareProductObject.getName());
186             DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
187             ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFiles.get(i), "The topology template for " + vnfFiles.get(i) + " is as follows : ");
188             DeploymentArtifactPage.clickSubmitForTestingButton(VFNames.get(i));
189         }
190         SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER");
191         reloginWithNewRole(UserRoleEnum.TESTER);
192         for (String VFName : VFNames) {
193             GeneralUIUtils.findComponentAndClick(VFName);
194             TesterOperationPage.certifyComponent(VFName);
195         }
196         return VFNames;
197     }
198
199     public Pair<String, ServiceReqDetails> getToPathFlow(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception {
200         String vspName = onboardAndCertify(resourceReqDetails, filepath, vnfFile);
201         reloginWithNewRole(UserRoleEnum.DESIGNER);
202         ServiceReqDetails serviceMetadata = PathUtilities.createService(getUser());
203         return new Pair<>(vspName, serviceMetadata);
204     }
205
206     public String[] getToComplexService(String filepath, List<String> vnfFiles) throws Exception {
207         // create & certify  2 VF
208         List<String> VFNames = onboardAndCertifyMultipleVFs(filepath, vnfFiles);
209         reloginWithNewRole(UserRoleEnum.DESIGNER);
210         ServiceReqDetails serviceMetadata1 = PathUtilities.createService(getUser());
211
212         // create path 1
213         PathUtilities.createPath("newPath", VFNames.get(0));
214         PathUtilities.submitForTesting();
215         GeneralUIUtils.ultimateWait();
216         ServiceReqDetails serviceMetadata2 = PathUtilities.createService(getUser());
217
218         // create path 2
219         PathUtilities.createPath("newPath2", VFNames.get(1));
220         PathUtilities.submitForTesting();
221
222         //tester
223         reloginWithNewRole(UserRoleEnum.TESTER);
224         GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName());
225         TesterOperationPage.certifyComponent(serviceMetadata1.getName());
226         GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName());
227         TesterOperationPage.certifyComponent(serviceMetadata2.getName());
228
229         //governor
230         reloginWithNewRole(UserRoleEnum.GOVERNOR);
231         GeneralUIUtils.findComponentAndClick(serviceMetadata1.getName());
232         GovernorOperationPage.approveService(serviceMetadata1.getName());
233         GeneralUIUtils.findComponentAndClick(serviceMetadata2.getName());
234         GovernorOperationPage.approveService(serviceMetadata2.getName());
235
236         //create service for complex service
237         reloginWithNewRole(UserRoleEnum.DESIGNER);
238         ServiceReqDetails serviceMetadata3 = PathUtilities.createService(getUser());
239         return new String[]{serviceMetadata1.getName(), serviceMetadata2.getName(), serviceMetadata3.getName()};
240     }
241
242     public Pair<String, String> CreatePathComplexServiceFlow(String filepath, List<String> vnfFiles) throws Exception {
243         String[] servicesName = getToComplexService(filepath, vnfFiles);
244         CanvasManager canvasManager = CanvasManager.getCanvasManager();
245         CompositionPage.searchForElement(servicesName[0]);
246         CanvasElement service1 = canvasManager.createElementOnCanvas(servicesName[0]);
247         CompositionPage.searchForElement(servicesName[1]);
248         CanvasElement service2 = canvasManager.createElementOnCanvas(servicesName[1]);
249         canvasManager.linkElements(service1, CircleSize.SERVICE, service2, CircleSize.SERVICE);
250
251         // create path
252         String pathName = "name1";
253         PathUtilities.openCreatePath();
254         PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1");
255         PathUtilities.selectFirstLineParam();
256         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue()).click();
257         return new Pair<>(servicesName[2], pathName);
258     }
259
260     public void runCreateExtendedPathFlow(ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception {
261         Pair<String, ServiceReqDetails> pair = getToPathFlow(resourceReqDetails, filepath, vnfFile);
262         String vspName = pair.left;
263         PathUtilities.linkVFs(vspName, 4);
264
265         //create path
266         PathUtilities.openCreatePath();
267         String pathName = "name1";
268         PathUtilities.insertValues(pathName, "pathProtocol1", "pathPortNumbers1");
269         PathUtilities.selectFirstLineParam();
270         int numOfLines = 3;
271         PathValidations.extendPath(numOfLines);
272
273         //delete line
274         PathUtilities.deleteLines(1, numOfLines);
275         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.CREATE_BUTTON.getValue());
276         ExtentTestActions.log(Status.INFO, "path has been created");
277
278         // check path is on the list
279         PathUtilities.openPathList();
280         String PathListName1 = GeneralUIUtils.findByText(pathName).getText();
281         String newPathName = "name2";
282         PathUtilities.editPathName(pathName, newPathName);
283         GeneralUIUtils.findElementsByXpath("//*[@data-tests-id='" + DataTestIdEnum.ComplexServiceAmdocs.PATH_MENU_BUTTON.getValue() + "']/parent::*").get(0).click();
284         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.PATH_LIST_BUTTON.getValue());
285         String PathListName2 = GeneralUIUtils.findByText(newPathName).getText();
286         PathValidations.AssertNameChangeFromPathList(PathListName1, PathListName2);
287
288         // delete path and validate
289         PathValidations.ValidateAndDeletePathFromPathList(newPathName);
290         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.PropertiesAssignmentScreen.INPUT_DELETE_DIALOG_CLOSE.getValue());
291         SetupCDTest.getExtendTest().log(Status.INFO, "Path has been created");
292     }
293
294     @Override
295     protected UserRoleEnum getRole() {
296         return UserRoleEnum.DESIGNER;
297     }
298
299 }