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