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