Added oparent to sdc main
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / ArchiveRestoreTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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 com.aventstack.extentreports.Status;
24 import fj.data.Either;
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.be.model.ComponentInstance;
27 import org.openecomp.sdc.be.model.Resource;
28 import org.openecomp.sdc.be.model.Service;
29 import org.openecomp.sdc.be.model.User;
30 import org.openecomp.sdc.ci.tests.datatypes.*;
31 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
32 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
34 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
35 import org.openecomp.sdc.ci.tests.pages.*;
36 import org.openecomp.sdc.ci.tests.utilities.*;
37 import org.openecomp.sdc.ci.tests.utils.general.*;
38 import org.testng.annotations.Test;
39
40 import static org.testng.AssertJUnit.assertTrue;
41
42 public class ArchiveRestoreTest extends SetupCDTest {
43
44     private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
45
46
47     @Test
48     public void updateVSP_WhenVF_Archived() throws Throwable {
49
50         String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip";
51         String vnfFile2 = "2-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0_Added2TestParameters.zip";
52
53 //      1. Import VSP v1.0
54         String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
55         AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails);
56         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
57         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
58         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
59         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, this.sdncDesignerDetails, amdocsLicenseMembers, null);
60 //              2. Create VF from VSP, certify - v1.0 is created
61         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
62         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
63         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
64         getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
65         getExtendTest().log(Status.INFO, String.format("Certify the VF"));
66 //              3. Create Service add to it the certified VF and certify the Service v1.0
67         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
68         org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
69         getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
70         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
71         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
72         getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
73 //              4. archive VF(1.0)
74         GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName());
75 //      5. service certification should send error message - unable to certify, service contains archived resource  via UI
76         HomeUtils.findComponentAndClick(service.getName());
77         GeneralPageElements.clickSubmitForTestingButtonErrorCase(service.getName());
78 //              6. Update VSP to v2.0 - onboard level
79         getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2);
80         VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, vnfFile2);
81         getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: ", vnfFile2));
82         VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails);
83 //              7. Update the VF from VSP when it archived  and restore - via UI
84         getExtendTest().log(Status.INFO, String.format("Going to update VF %s with VSP v2.0", resourceReqDetails.getName()));
85         CompositionPage.moveToHomeScreen();
86         HomePage.showVspRepository();
87         OnboardingUiUtils.updateVSP(vendorSoftwareProductObject, true);
88 //              8. Certify and update restored VF from with VSP v2.0
89         GeneralPageElements.clickCertifyButton(resource.getName());
90 //              9. Update the Service with the VFi version 2.0 and certify
91         HomeUtils.findComponentAndClick(service.getName());
92         GeneralPageElements.clickSubmitForTestingButton(service.getName());
93     }
94
95 //    https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestScript&id=896098
96     @Test
97     public void certifyVF_WhenVSP_Archived() throws Exception {
98
99         String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip";
100
101 //      1. Import VSP v1.0
102         String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
103         AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails);
104         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
105         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
106         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
107         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, this.sdncDesignerDetails, amdocsLicenseMembers, null);
108 //              2. Create VF from VSP, certify - v1.0 is created
109         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
110         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
111         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
112         getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
113         getExtendTest().log(Status.INFO, String.format("Certify the VF"));
114 //      3. Archive VSP (onboarding page-Amdocs side)
115         getExtendTest().log(Status.INFO, String.format("Going to archive component OB side: %s", resource.getName()));
116         VendorSoftwareProductRestUtils.archiveVendorSoftwareProduct(vendorSoftwareProductObject, sdncDesignerDetails);
117         getExtendTest().log(Status.INFO, String.format("Succeed to archive component %s, OB side", resource.getName()));
118 //      4. chekout resource and check that VF is archived
119         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
120         HomeUtils.findComponentAndClick(resource.getName());
121         GeneralPageElements.clickCheckoutButton();
122         resource = AtomicOperationUtils.getResourceObject(resource.getUniqueId());
123         getExtendTest().log(Status.INFO, String.format("Going to validate is VSP archived: %s", resource.getName()));
124         assertTrue("Validate isVspArchived flag, expected: true, but was: " + resource.isVspArchived(), resource.isVspArchived().equals(true));
125         String expectedText = "VSP is archived";
126         getExtendTest().log(Status.INFO, String.format("Going to validate text box message, expected: %s", expectedText));
127         String actualElementText = GeneralPageElements.getWebElementTextByTestId(DataTestIdEnum.ResourceMetadataEnum.SELECT_VSP.getValue());
128         assertTrue("Validate text box message, expected: [" + expectedText + "], but was: " + actualElementText, actualElementText.equals(expectedText));
129 //      5. certify new resource - should fail, via API
130         getExtendTest().log(Status.INFO, String.format("Going to certify archived on OB side resource %s , expected failure certification", resource.getName()));
131         GeneralPageElements.clickCertifyButtonNoUpgradePopupDismissErrorCase(resource.getName());
132 //      6. restore
133         getExtendTest().log(Status.INFO, String.format("Going to restore component OB side: %s", resource.getName()));
134         VendorSoftwareProductRestUtils.restoreVendorSoftwareProduct(vendorSoftwareProductObject, sdncDesignerDetails);
135         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Succeed to restore component %s, OB side", resource.getName()));
136 //      7. certify - should pass
137         getExtendTest().log(Status.INFO, String.format("Going to certify resource %s ", resource.getName()));
138         GeneralPageElements.clickCertifyButtonNoUpgradePopupDismiss(resource.getName());
139         resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "2.0");
140         assertTrue("Validate isVspArchived flag, expected: false, but was: " + resource.isVspArchived(), resource.isVspArchived().equals(false));
141     }
142
143     @Test
144     public void distributeServiceIncludedArchivedResource() throws Exception {
145
146         String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip";
147 //      1. Import VSP v1.0
148         String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
149         AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails);
150         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
151         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
152         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
153         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, this.sdncDesignerDetails, amdocsLicenseMembers, null);
154 //              2. Create VF from VSP, certify - v1.0 is created
155         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
156         getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
157         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
158         getExtendTest().log(Status.INFO, String.format("Certify the VF"));
159         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
160 //              3. Create Service add to it the certified VF and certify the Service v1.0
161         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
162         org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
163         getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
164         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
165         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
166         getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
167         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
168
169         reloginWithNewRole(UserRoleEnum.GOVERNOR);
170         GeneralUIUtils.findComponentAndClick(service.getName());
171         GovernorOperationPage.approveSerivce(service.getName());
172 //              4. archive VF(1.0)
173         reloginWithNewRole(UserRoleEnum.DESIGNER);
174         GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName());
175 //      5. Distribute service - should pass
176         reloginWithNewRole(UserRoleEnum.OPS);
177         GeneralUIUtils.findComponentAndClick(service.getName());
178         OpsOperationPage.distributeService();
179
180     }
181
182
183     @Test
184     public void certificationOfArchivedCR() throws Exception {
185
186         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.CR, getUser());
187         ResourceUIUtils.createCR(resourceReqDetails, sdncDesignerDetails);
188         GeneralPageElements.clickCertifyButtonNoUpgradePopupDismiss(resourceReqDetails.getName());
189         GeneralUIUtils.ultimateWait();
190         Resource resource = (Resource) AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceReqDetails.getName(), "1.0");
191 //              1. Create Service add to it the certified CR and certify the Service v1.0
192         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
193         org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
194         getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
195         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
196         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
197         getExtendTest().log(Status.INFO, String.format("Adding CR instance to Service"));
198 //              2. archive CR(1.0)
199         GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName());
200 //      3. service certification should send error message - unable to certify, service contains archived resource  via UI
201         HomeUtils.findComponentAndClick(service.getName());
202         GeneralPageElements.clickSubmitForTestingButtonErrorCase(service.getName());
203 //      4. restore CR
204         GeneralPageElements.restoreComponentFromArchivedCatalog(resource.getName());
205 //              5. Certify and update restored CR(v2.0)
206         GeneralPageElements.clickCheckoutButton();
207         GeneralPageElements.clickCertifyButton(resource.getName());
208 //              6. Update the Service with the CRi version 2.0 and certify service
209         HomeUtils.findComponentAndClick(service.getName());
210         GeneralPageElements.clickSubmitForTestingButton(service.getName());
211     }
212
213     @Override
214     protected UserRoleEnum getRole() {
215         return UserRoleEnum.DESIGNER;
216     }
217 }