re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / AmdocsComplexService / PathName.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.AmdocsComplexService;
22
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
25 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
26 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
27 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
28 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
29 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
30 import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
31 import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
32 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
33 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
34 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
35 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
36 import org.testng.annotations.BeforeMethod;
37 import org.testng.annotations.Optional;
38 import org.testng.annotations.Parameters;
39 import org.testng.annotations.Test;
40
41 public class PathName extends SetupCDTest {
42
43     protected static String filePath = FileHandling.getFilePath("ComplexService");
44     private static String fullCompositionFile = "fullComposition.zip";
45     private static String fullCompositionFile2 = "fullCompositionNew.zip";
46     private static String HSSFile = "HSS.zip";
47     private static String VMMEFile = "VMME.zip";
48     private static String makeDistributionValue;
49
50     @Parameters({"makeDistribution"})
51     @BeforeMethod
52     public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) {
53         makeDistributionValue = makeDistributionReadValue;
54     }
55
56     //------------------------------------------Tests-----------------------------------------------------
57
58     // Test#8 Jira issue 6168
59     @Test
60     public void ValidateSameNameTest() throws Exception {
61         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
62         String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile);
63         reloginWithNewRole(UserRoleEnum.DESIGNER);
64         PathUtilities.createService(getUser());
65         String firstPathName = PathUtilities.createPath("Oren",vspName);
66         PathUtilities.createPathWithoutLink(firstPathName,vspName);
67         try {
68             GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue());
69         } catch (Exception e) {
70             throw new Exception("when creating another path with duplicate name, expected error did not appear");
71         }
72     }
73
74     // Test#9 Jira issue 6183
75     @Test
76     public void ValidateEditName() throws Exception {
77         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
78         String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile);
79         reloginWithNewRole(UserRoleEnum.DESIGNER);
80         PathUtilities.createService(getUser());
81         String firstPathName = PathUtilities.createPath("Oren",vspName);
82         String secondPathName = PathUtilities.createPathWithoutLink("blabla",vspName);
83         PathValidations.validateEditToExistingName(firstPathName,secondPathName);
84     }
85
86     // Test#10 Jira issue 6411
87     @Test
88     public void SpacesName() throws Exception {
89         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
90         String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile);
91         reloginWithNewRole(UserRoleEnum.DESIGNER);
92         PathUtilities.createService(getUser());
93         PathUtilities.createPath("              ", vspName);
94         try {
95             GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ComplexServiceAmdocs.OK.getValue());
96         } catch (Exception e) {
97             throw new Exception("service path name cannot be empty or spaces ");
98         }
99     }
100
101     // Test#11 Jira issue 6186
102     @Test
103     public void ValidateNameWithSpaces() throws Exception {
104         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
105         String vspName = onboardAndCertify(resourceReqDetails, filePath, fullCompositionFile);
106         reloginWithNewRole(UserRoleEnum.DESIGNER);
107         PathUtilities.createService(getUser());
108         PathValidations.validateNameWithSpaces("New", vspName);
109     }
110
111     ////////////////////////////////////////////////////////////////////////////////////////
112     //                               flow methods                                         //
113     ////////////////////////////////////////////////////////////////////////////////////////
114
115     // workflow leading to path
116     public String onboardAndCertify(ResourceReqDetails resourceReqDetails, String filePath, String vnfFile) throws Exception {
117         VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUiUtils.onboardAndValidate(resourceReqDetails, filePath, vnfFile, getUser());
118         String vspName = vendorSoftwareProductObject.getName();
119
120         DeploymentArtifactPage.getLeftPanel().moveToCompositionScreen();
121         ExtentTestActions.addScreenshot(Status.INFO, "TopologyTemplate_" + vnfFile, "The topology template for " + vnfFile + " is as follows : ");
122
123         DeploymentArtifactPage.clickSubmitForTestingButton(vspName);
124         SetupCDTest.getExtendTest().log(Status.INFO, "relogin as TESTER");
125         reloginWithNewRole(UserRoleEnum.TESTER);
126         GeneralUIUtils.findComponentAndClick(vspName);
127         TesterOperationPage.certifyComponent(vspName);
128         return vspName;
129     }
130
131     @Override
132     protected UserRoleEnum getRole() {
133         return UserRoleEnum.DESIGNER;
134     }
135
136 }