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